예제 #1
0
    protected void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.GetComponent <Collider2D>().CompareTag("Projectiles"))
        {
            healthPoint -= collision.gameObject.GetComponent <ProjectileScript>().AttackPower;

            StartCoroutine(anim.DamageAnimation());

            if (healthPoint <= 0)
            {
                Destroy(gameObject);
            }
        }
    }
예제 #2
0
 public void ReceivedDamage(float DamageTaken)                           //Function to damage the enemy
 {
     HP -= DamageTaken;
     if (HP <= 0)
     {
         //call death animation
         enemyAnimation.DeathAnimation();
         gameObject.GetComponent <BoxCollider>().enabled = false;
         //disactivates enemies
         Destroy(Vision);
         Idle            = false;
         Patrol          = false;
         DetectedPlayer  = false;
         HuntingPlayer   = false;
         dead            = true;
         Agent.isStopped = true;
     }
     //call damage animation
     DetectedPlayer = true;
     enemyAnimation.DamageAnimation();
 }