예제 #1
0
    public void DealDamage(int damage)
    {
        zombie_Animation.Hurt();
        zombiehealth -= damage;
        if (zombiehealth <= 0)
        {
            zombie_Alive = false;
            zombie_Animation.Dead();

            StartCoroutine(DeactivateZombie());
        }
    }
예제 #2
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag(TagManager.PLAYER_HEALTH_TAG) ||
            collision.CompareTag(TagManager.PLAYER_TAG) ||
            collision.CompareTag(TagManager.FENCE_TAG))
        {
            canAttack = true;
        }

        if (collision.CompareTag(TagManager.BULLET_TAG) || collision.CompareTag(TagManager.ROCKET_MISSILE_TAG))
        {
            anim.Hurt();

            health -= collision.GetComponent <BulletController>().damage;

            if (collision.CompareTag(TagManager.ROCKET_MISSILE_TAG))
            {
                collision.GetComponent <BulletController>().ExplosionFX();
            }

            if (health <= 0)
            {
                alive = false;
                anim.Dead();

                StartCoroutine(DeactivateZombie());
            }

            collision.gameObject.SetActive(false);
        }

        if (collision.CompareTag(TagManager.FIRE_BULLET_TAG))
        {
            anim.Hurt();
            health -= fireDamage;
            if (health <= 0)
            {
                alive = false;
                anim.Dead();
                StartCoroutine(DeactivateZombie());
            }
        }
    }