void OnTriggerEnter2D(Collider2D other)
    {
        EntityHealthController healthController = other.gameObject.GetComponent <EntityHealthController>();

        if (healthController && healthController.GetType() != typeof(PlayerHealthController))
        {
            healthController.DamageCharacter(damage);
        }

        if (other.gameObject.tag != "Player")
        {
            Destroy(this.gameObject);
        }
    }
Example #2
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         if (!damageOnCooldown)
         {
             hc = other.gameObject.GetComponent <EntityHealthController>();
             hc.DamageCharacter(damageDealtPerTic);
             StartCoroutine(DamageCooldown());
             if (!hurtOnCooldown)
             {
                 hc.hurtSoundEffect.Play();
                 StartCoroutine(HurtSoundCooldown());
             }
         }
     }
 }
Example #3
0
 public void Start()
 {
     playerHealthController = player.GetComponent<EntityHealthController>();
 }
 void Awake()
 {
     playerHealthController = GameController.instance.player.GetComponent<EntityHealthController>();
     audioSource = GetComponent<AudioSource>();
 }