shoot de missile et tuer les ennemis

This commit is contained in:
FrancisGallant 2015-11-16 18:24:36 -05:00
parent 8426a784f8
commit 97abe3ae11
12 changed files with 153 additions and 6 deletions

37
Assets/MissileTravel.cs Normal file
View File

@ -0,0 +1,37 @@
using UnityEngine;
using System.Collections;
public class MissileTravel : MonoBehaviour {
public float missileSpeed;
private Transform missilePos;
private bool inContact = false;
// ajouter du damage
// Use this for initialization
void Start () {
this.missilePos = this.transform;
}
// Update is called once per frame
void Update () {
if (!inContact)
{
this.missilePos.Translate(new Vector3(missileSpeed, 0, 0) * Time.deltaTime);
}
}
void OnCollisionEnter2D(Collision2D other) {
print("missile touche");
if (other.gameObject.tag == "Ennemy") {
// do shits to player
print("touchee");
Destroy(this.gameObject);
Destroy(other.gameObject);
}
if (other.gameObject.tag == "Floor") {
Destroy(this.gameObject);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fb20d6c6a0d8d8743a840286880b4b00
timeCreated: 1447713283
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d7295f14b4e29684f865cdde9266feb0
timeCreated: 1447715205
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -16,7 +16,7 @@ public class DirectionChangeTrigger : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other) {
if( other.gameObject.tag == "Ennemy" ){
other.gameObject.GetComponent<Patrolling>().setDirection(- other.gameObject.GetComponent<Patrolling>().getDirection());
print("TriggerEnter");
//print("TriggerEnter");
}
}
}

View File

@ -18,7 +18,7 @@ public class Jump : MonoBehaviour {
// Update is called once per frame
void Update () {
if (Input.GetButton("Fire1") && isOnGround == true)
if (Input.GetKeyUp(KeyCode.Space) && isOnGround == true)
{
player.velocity = new Vector2(player.velocity.x, playerSpeedY);
}

View File

@ -4,7 +4,7 @@ using System.Collections;
public class Patrolling : MonoBehaviour {
private float direction = 0.5f;
public float speed;
// Use this for initialization
void Start () {
@ -13,18 +13,18 @@ public class Patrolling : MonoBehaviour {
// Update is called once per frame
void Update () {
this.transform.Translate(direction, 0, 0);
this.transform.Translate(new Vector3(speed, 0, 0) * Time.deltaTime);
}
void FixedUpdate() {
}
public void setDirection(float value) {
direction = value;
speed = value;
}
public float getDirection() {
return direction;
return speed;
}
}

22
Assets/ShootingScript.cs Normal file
View File

@ -0,0 +1,22 @@
using UnityEngine;
using System.Collections;
public class ShootingScript : MonoBehaviour {
public float attackSpeed;
private float nextShootTime = 0.0f;
public GameObject Missile;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetButton("Fire1") && Time.time > nextShootTime){
print("pewpew");
nextShootTime = Time.time + attackSpeed;
//avancer le missile au depart quand il va apparaitre (quand je vais avoir anim de combat)
GameObject clone = Instantiate( Missile,transform.position,transform.rotation) as GameObject;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 86aea67c20f4c264393299ede07339a3
timeCreated: 1447714560
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 931 B

View File

@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: 51a9c79b88f593f4aa24a058515df7f1
timeCreated: 1447713192
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 1
linearTexture: 0
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 8
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant: