void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Bullet")
        {
            if (this.gameObject.name == "Left")
            {
                //if bullet touched left side of the enemy, apply force to it.
                _enemy_Movement.AddForce("Left");
                _enemy_Health.GetDamage(_player_Bullet.BulletDamage);
            }
            if (this.gameObject.name == "Right")
            {
                _enemy_Movement.AddForce("Right");
                _enemy_Health.GetDamage(_player_Bullet.BulletDamage);
            }
            if (this.gameObject.name == "Up")
            {
                _enemy_Movement.AddForce("Up");
                _enemy_Health.GetDamage(_player_Bullet.BulletDamage);
            }
            if (this.gameObject.name == "Down")
            {
                _enemy_Movement.AddForce("Down");
                _enemy_Health.GetDamage(_player_Bullet.BulletDamage);
            }

            // if get touched by a bullet
            //Debug.Log("Bullet");
        }
    }
示例#2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Hat"))
     {
         health.GetDamage(30, false, (float)0.1);
     }
 }
 public void RemoveAllEnemy()
 {
     for (int i = 0; i < enemys.Count; i++)
     {
         if (enemys[i] != null)
         {
             Enemy_Health health = enemys[i].GetComponent <Enemy_Health>();
             health.GetDamage(1000, true, 0);
         }
     }
     enemys.Clear();
 }