예제 #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "LargeAsteroid")
     {
         gameHandlerScript.PlayBangLarge();
         Destroy(this.gameObject);
         gameHandlerScript.ScoreValue         += 20;
         gameHandlerScript.pointToLifeCounter += 20;
         asteroidSpawnerScript.SpawnMediumAsteroids(other.gameObject.transform.position);
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "MediumAsteroid")
     {
         gameHandlerScript.PlayBangMedium();
         Destroy(this.gameObject);
         gameHandlerScript.ScoreValue         += 50;
         gameHandlerScript.pointToLifeCounter += 50;
         asteroidSpawnerScript.SpawnSmallAsteroids(other.gameObject.transform.position);
         Destroy(other.gameObject);
     }
     else if (other.gameObject.tag == "SmallAsteroid")
     {
         gameHandlerScript.PlayBangSmall();
         Destroy(other.gameObject);
         Destroy(this.gameObject);
         gameHandlerScript.ScoreValue         += 100;
         gameHandlerScript.pointToLifeCounter += 100;
     }
     else if (other.gameObject.tag == "SmallShip")
     {
         gameHandlerScript.PlaySaucerSmall();
         Destroy(other.gameObject);
         Destroy(this.gameObject);
         gameHandlerScript.ScoreValue         += 1000;
         gameHandlerScript.pointToLifeCounter += 1000;
         gameHandlerScript.smallShipOnScreen   = false;
     }
     else if (other.gameObject.tag == "LargeShip")
     {
         gameHandlerScript.PlaySaucerBig();
         Destroy(other.gameObject);
         Destroy(this.gameObject);
         gameHandlerScript.ScoreValue         += 200;
         gameHandlerScript.pointToLifeCounter += 200;
         gameHandlerScript.largeShipOnScreen   = false;
         largeShipScript.hasShipFired          = false;
     }
 }
예제 #2
0
    /* Kill Player if Hit And Respawn Player */

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (playerDead != true)
        {
            if (collision.gameObject.tag == "MediumAsteroid")
            {
                gameHandlerScript.PlayBangMedium();
                Destroy(collision.gameObject);
                asteroidSpawnerScript.SpawnSmallAsteroids(collision.gameObject.transform.position);
            }
            else if (collision.gameObject.tag == "LargeAsteroid")
            {
                gameHandlerScript.PlayBangLarge();
                Destroy(collision.gameObject);
                asteroidSpawnerScript.SpawnMediumAsteroids(collision.gameObject.transform.position);
            }
            else if (collision.gameObject.tag == "SmallAsteroid")
            {
                gameHandlerScript.PlayBangSmall();
                Destroy(collision.gameObject);
            }
            else if (collision.gameObject.tag == "SmallShip")
            {
                gameHandlerScript.PlaySaucerSmall();
                Destroy(collision.gameObject);
                gameHandlerScript.smallShipOnScreen = false;
            }
            else if (collision.gameObject.tag == "LargeShip")
            {
                gameHandlerScript.PlaySaucerBig();
                Destroy(collision.gameObject);
                gameHandlerScript.largeShipOnScreen = false;
            }
            else if (collision.gameObject.tag == "ShipBullets")
            {
                gameHandlerScript.PlayBangLarge();
                Destroy(collision.gameObject);
            }

            gameHandlerScript.CurrentLives -= 1;
            playerDead = true;
            Player.SetActive(false);
        }
    }