mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-24 09:31:07 +00:00
on peut prendre une bombe et la lancer mais elle ne tue pas l'ennemi la caisse de vie peut être prise mais ne soigne pas
42 lines
972 B
C#
42 lines
972 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class LayBombs : MonoBehaviour
|
|
{
|
|
[HideInInspector]
|
|
public bool bombLaid = false; // si une bombe a été lancé
|
|
public int bombCount = 0; // nombre bomb que le joueur possede
|
|
|
|
public GameObject bomb; // Prefab of the bomb.
|
|
|
|
|
|
private GUITexture bombHUD; // affiche si le joueur possede une bombe
|
|
|
|
|
|
void Awake ()
|
|
{
|
|
// Setting up the reference.
|
|
bombHUD = GameObject.Find("ui_bombHUD").GetComponent<GUITexture>();
|
|
}
|
|
|
|
|
|
void Update ()
|
|
{
|
|
// si le bouton est pressé et qu'aucune bombe n'a été lancé et qu'on a des bombes
|
|
if(Input.GetButtonDown("Fire2") && !bombLaid && bombCount > 0)
|
|
{
|
|
// Decremente le nb de bombe
|
|
bombCount--;
|
|
|
|
// lance une bombe
|
|
bombLaid = true;
|
|
|
|
// Instancie la bombe
|
|
Instantiate(bomb, transform.position, transform.rotation);
|
|
}
|
|
|
|
// active le display de bombe si le joueur possede des bombes(true) sinon false
|
|
bombHUD.enabled = bombCount > 0;
|
|
}
|
|
}
|