mirror of
https://github.com/ConjureETS/Labo_2_Equ_1_a15.git
synced 2026-03-24 01:50:58 +00:00
shoot de missile et tuer les ennemis
This commit is contained in:
parent
8426a784f8
commit
97abe3ae11
37
Assets/MissileTravel.cs
Normal file
37
Assets/MissileTravel.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
Assets/MissileTravel.cs.meta
Normal file
12
Assets/MissileTravel.cs.meta
Normal 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:
|
||||||
BIN
Assets/Prefabs/Missile.prefab
Normal file
BIN
Assets/Prefabs/Missile.prefab
Normal file
Binary file not shown.
8
Assets/Prefabs/Missile.prefab.meta
Normal file
8
Assets/Prefabs/Missile.prefab.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d7295f14b4e29684f865cdde9266feb0
|
||||||
|
timeCreated: 1447715205
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@ -16,7 +16,7 @@ public class DirectionChangeTrigger : MonoBehaviour {
|
|||||||
void OnTriggerEnter2D(Collider2D other) {
|
void OnTriggerEnter2D(Collider2D other) {
|
||||||
if( other.gameObject.tag == "Ennemy" ){
|
if( other.gameObject.tag == "Ennemy" ){
|
||||||
other.gameObject.GetComponent<Patrolling>().setDirection(- other.gameObject.GetComponent<Patrolling>().getDirection());
|
other.gameObject.GetComponent<Patrolling>().setDirection(- other.gameObject.GetComponent<Patrolling>().getDirection());
|
||||||
print("TriggerEnter");
|
//print("TriggerEnter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ public class Jump : MonoBehaviour {
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update () {
|
void Update () {
|
||||||
|
|
||||||
if (Input.GetButton("Fire1") && isOnGround == true)
|
if (Input.GetKeyUp(KeyCode.Space) && isOnGround == true)
|
||||||
{
|
{
|
||||||
player.velocity = new Vector2(player.velocity.x, playerSpeedY);
|
player.velocity = new Vector2(player.velocity.x, playerSpeedY);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using System.Collections;
|
|||||||
public class Patrolling : MonoBehaviour {
|
public class Patrolling : MonoBehaviour {
|
||||||
|
|
||||||
|
|
||||||
private float direction = 0.5f;
|
public float speed;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
@ -13,18 +13,18 @@ public class Patrolling : MonoBehaviour {
|
|||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update () {
|
void Update () {
|
||||||
this.transform.Translate(direction, 0, 0);
|
this.transform.Translate(new Vector3(speed, 0, 0) * Time.deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate() {
|
void FixedUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDirection(float value) {
|
public void setDirection(float value) {
|
||||||
direction = value;
|
speed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getDirection() {
|
public float getDirection() {
|
||||||
return direction;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
22
Assets/ShootingScript.cs
Normal file
22
Assets/ShootingScript.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/ShootingScript.cs.meta
Normal file
12
Assets/ShootingScript.cs.meta
Normal 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:
|
||||||
BIN
Assets/Sprites/missile (1).gif
Normal file
BIN
Assets/Sprites/missile (1).gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 931 B |
56
Assets/Sprites/missile (1).gif.meta
Normal file
56
Assets/Sprites/missile (1).gif.meta
Normal 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:
|
||||||
Loading…
x
Reference in New Issue
Block a user