예제 #1
0
 void LandMineCollision(string player)
 {
     Debug.Log("Land Mine explodes !!!");
     if (player == "Player1")
     {
         Tank02.ScorePoints(LandMineOpponentPoints);
         Tank01.SetDamage(LandMineDamage);
         Destroy(this.gameObject);
         this.UpdateScoreboard(player);
     }
     else if (player == "Player2")
     {
         Tank01.ScorePoints(LandMineOpponentPoints);
         Tank02.SetDamage(LandMineDamage);
         Destroy(this.gameObject);
         this.UpdateScoreboard(player);
     }
 }
예제 #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // Check if 'other' is a tagged an item
        Debug.Log("Other tag: " + other.tag);
        Debug.Log("Bullet trigger: " + this.trigger);
        if (other.tag == this.trigger)
        {
            return;
        }
        switch (other.tag.ToUpper())
        {
        case "BARRIER":

            if (GameLevel == 1)
            {
                Instantiate(brick2, other.transform.position, other.transform.rotation);
            }
            else if (GameLevel == 2)
            {
                Instantiate(rock2, other.transform.position, other.transform.rotation);
            }
            else
            {
                Instantiate(metal2, other.transform.position, other.transform.rotation);
            }


            Destroy(other.gameObject);
            Destroy(this.gameObject);
            break;

        case "BARRIER2":

            if (GameLevel == 1)
            {
                Instantiate(brick3, other.transform.position, other.transform.rotation);
            }
            else if (GameLevel == 2)
            {
                Instantiate(rock3, other.transform.position, other.transform.rotation);
            }
            else
            {
                Instantiate(metal3, other.transform.position, other.transform.rotation);
            }


            Destroy(other.gameObject);
            Destroy(this.gameObject);
            break;

        case "BARRIER3":
            Destroy(other.gameObject);
            Destroy(this.gameObject);
            break;

        case "PLAYER1":
            Tank02.ScorePoints();
            Tank01.SetDamage();
            gCont.setScoreboard(Tank02.Flag);
            Destroy(this.gameObject);
            break;

        case "PLAYER2":
            Tank01.ScorePoints();
            Tank02.SetDamage();
            gCont.setScoreboard(Tank01.Flag);
            Destroy(this.gameObject);
            break;
        }
    }