Exemplo n.º 1
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == "EnemyVision")
     {
         return;
     }
     if (coll.gameObject.tag == "Player")
     {
         player = coll.gameObject.GetComponent <PlayerController>();
         player.TakeDamage(damage);
         Destroy(this.gameObject);
     }
     else if (coll.gameObject.tag == "Enemy")
     {
         AI = coll.gameObject.GetComponent <BasicAI>();
         AI.TakeDamage(damage);
         Destroy(this.gameObject);
     }
     else if (coll.gameObject.tag == "Bullet" || coll.gameObject.tag == "PlayerBullet" || coll.gameObject.tag == "CanShootOver")
     {
         return;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 2
0
 private void DealDamage(int _damage)
 {
     if (ai != null)
     {
         ai.TakeDamage(_damage);
     }
     else if (player != null)
     {
         player.TakeDamage(_damage);
     }
 }
Exemplo n.º 3
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == "Enemy" && attacker != "enemy")
     {
         BasicAI ai = coll.gameObject.GetComponent <BasicAI>();
         ai.TakeDamage(damage);
     }
     if (coll.gameObject.tag == "Player" && attacker == "enemy")
     {
         player.PlayerController Player = coll.gameObject.GetComponent <player.PlayerController>();
         Player.TakeDamage(damage);
         Debug.Log(damage);
     }
 }