Ejemplo n.º 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);
            }
        }
    }
Ejemplo n.º 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();
 }