Ejemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     _game_manager        = GameObject.Find("game_manager").GetComponent <game_handler>();
     _shield              = transform.FindChild("Shield");
     _powerups["triple"]  = false;
     _powerups["speed"]   = false;
     _powerups["shield"]  = false;
     _powerups2["triple"] = false;
     _powerups2["speed"]  = false;
     _powerups2["shield"] = false;
     _game_manager.change_lives(_lives, single_player);
     _laser = GetComponent <AudioSource>();
 }
Ejemplo n.º 2
0
 public void destroy_player()
 {
     if ((bool)_powerups["shield"] || (bool)_powerups2["shield"])
     {
         _powerups["shield"]  = false;
         _powerups2["shield"] = false;
         _shield.gameObject.SetActive(false);
         return;
     }
     _lives--;
     if (_lives == 2)
     {
         int failure = Random.Range(0, engines.Length);
         engines[failure].SetActive(true);
     }
     if (_lives == 1)
     {
         foreach (GameObject engine in engines)
         {
             engine.SetActive(true);
         }
     }
     _game_manager.change_lives(_lives, single_player);
     if (_lives == 0)
     {
         if (!_game_manager.coop)
         {
             _game_manager.menu.SetActive(true);
             _game_manager.gameover = true;
         }
         else if (transform.parent.childCount == 1)
         {
             _game_manager.menu.SetActive(true);
             _game_manager.gameover = true;
         }
         Instantiate(Resources.Load("player_destroy", typeof(GameObject)), transform.position, Quaternion.identity);
         Destroy(this.gameObject);
     }
 }