Beispiel #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            Vida vida = collision.gameObject.GetComponent <Vida>();

            if (vida.invincivle || vida.inCharging)
            {
                //donothing
            }
            else if (vida.guardian)
            {
                vida.LoseGuard();
            }
            else
            {
                vida.EatDamage();
            }
        }

        GameObject.Destroy(gameObject);
    }
    void OnCollisionEnter2D(Collision2D collision)
    {
        //如果还没击中,且碰到了玩家
        if (collision.gameObject.tag == "Player")
        {
            Vida vida = collision.gameObject.GetComponent <Vida>();

            if (vida.invincivle || vida.inCharging)
            {
                //donothing
            }
            else if (vida.guardian)
            {
                vida.LoseGuard();
            }
            else
            {
                vida.EatDamage();
            }
        }


        Die();
    }