Ejemplo n.º 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ground" || collision.gameObject.tag == "Wall")
        {
        }
        else
        {
            Destroy(collision.gameObject);
        }
        if (collision.gameObject.tag == "Meteo")
        {
            playerLife--;
            //sliderのvalueに、体力を代入する
            hp.value = playerLife;

            if (playerLife <= 0)
            {
                if (isDead)
                {
                    return;
                }
                isDead = true;
                Destroy(this.gameObject);
                Debug.Log(playerLife);
            }
        }
        if (collision.gameObject.tag == "YellowStar")
        {
            score.AddAScore(40);
        }
        if (collision.gameObject.tag == "GreenStar")
        {
            score.AddAScore(30);
        }
        if (collision.gameObject.tag == "BlueStar")
        {
            score.AddAScore(20);
        }
        if (collision.gameObject.tag == "PinkStar")
        {
            score.AddAScore(10);
        }
    }