Example #1
0
    private void ProcessHit(DamageDealer damageDealer)
    {
        health -= damageDealer.GetDamage();
        damageDealer.OnHit();

        if (health <= 0)
        {
            Die();
        }
    }
Example #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        DamageDealer damageDealer = collision.gameObject.GetComponent <DamageDealer>();

        if (null != damageDealer)
        {
            damageDealer.OnHit();
        }
        ProcessHit(damageDealer);
    }
Example #3
0
    private void ProcessHit(DamageDealer dmg)
    {
        setHP(
            (healthPoints - dmg.getDmg() > 0) ? healthPoints - dmg.getDmg() : 0
            );

        dmg.OnHit();
        playOnHitFeedback();

        if (healthPoints <= 0)
        {
            Die();
        }
    }
Example #4
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     Debug.Log($"Touched : {other.gameObject.name}");
     damageDealer.OnHit(other.gameObject);
 }