Esempio n. 1
0
    void Take_Life()
    {
        //find player and lives script
        GameObject lifeManager = GameObject.Find("LifeManager");
        KeepLives  lifeScript  = lifeManager.GetComponent <KeepLives>();

        //if lives left then remove a life
        if (lifeScript.LifeVal != 0)
        {
            lifeScript.RemoveLife();
            // then respawn
            GameObject player      = GameObject.Find("Player");
            SpawnShip  spawnScript = player.GetComponent <SpawnShip> ();
            // reset to not first spawn
            spawnScript.firstSpawn = false;
            spawnScript.Spawn();
        }
        //if no more lives then enable the restart canvas
        else if (lifeScript.LifeVal == 0)
        {
            Enable_Canvas();
            // reset the wave count and disable the script
            GameObject waveManager = GameObject.Find("WaveManager");
            KeepWave   script      = waveManager.GetComponent <KeepWave>();
            script.ResetWave();
            script.enabled = false;
            // remove boss bar if exists
            GameObject boss = GameObject.FindWithTag("Boss");
            if (boss != null)
            {
                BossCollide bossScript = boss.GetComponent <BossCollide>();
                bossScript.ToggleHealthBar();
            }
        }
    }
Esempio n. 2
0
    void SetPlayerSpawn(Vector2 location)
    {
        GameObject player = GameObject.Find("Player");
        SpawnShip  script = player.GetComponent <SpawnShip> ();

        script.ShipSpawnLocation = location;
    }
 void OnCollisionEnter2D(Collision2D other)
 {
     //check for shot collision
     if (other.gameObject.tag == "Shot" || other.gameObject.tag == "LongShot")
     {
         AddToWaveKillCount();
         AddToScore();
         ExplosionSound();
         // destroy enemy
         Destroy(gameObject);
         LeaveExplosion();
         // get cords before destroying for powerup
         powerCord = gameObject.transform.position;
         //based on what enemy decide what power up
         PowerUp();
     }        // Kamakazi
     else if (other.gameObject.tag == "Ship")
     {
         GameObject Player      = GameObject.Find("Player");
         SpawnShip  spawnScript = Player.GetComponent <SpawnShip>();
         if (spawnScript.isImmune == false)
         {
             ExplosionSound();
             // destroy enemy
             Destroy(gameObject);
             LeaveExplosion();
         }
     }
 }
Esempio n. 4
0
    void SpawnShip()
    {
        // spawn ship
        GameObject player      = GameObject.Find("Player");
        SpawnShip  spawnScript = player.GetComponent <SpawnShip>();

        spawnScript.firstSpawn = true;
        spawnScript.Spawn();
    }
Esempio n. 5
0
    public void ShipCollision()
    {
        // get player and spawn script to check immunity
        GameObject player      = GameObject.Find("Player");
        SpawnShip  spawnScript = player.GetComponent <SpawnShip>();

        if (spawnScript.isImmune == false)
        {
            ExplosionSound();
            Destroy(gameObject);
            Toggle_Death();
            LeaveExplosion();
            Take_Life();
        }
    }