Ejemplo n.º 1
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Alien Laser"))
        {
            laserDetector.RemoveLaser(other.gameObject);
            lives--;
            switch (lives)
            {
            case 2:
                secondShip.SetActive(false);
                healthText.GetComponent <Text>().text = "2";
                break;

            case 1:
                firstShip.SetActive(false);
                healthText.GetComponent <Text>().text = "1";
                break;

            case 0:
                healthText.GetComponent <Text>().text = "0";
                levelController.GameWon();
                break;
            }
        }
    }
Ejemplo n.º 2
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (CompareTag("Player Laser") && other.gameObject.CompareTag("Enemy Bullet"))
     {
         Destroy(other.gameObject);
     }
     else if (CompareTag("Alien Laser") && other.gameObject.CompareTag("Enemy Bullet"))
     {
         Destroy(other.gameObject);
         laserDetector.RemoveLaser(gameObject);
         Destroy(gameObject);
     }
 }