Пример #1
0
    protected void Attack(HealthController_Abstract victim)
    {
        if (victim == null)
        {
            return;
        }

        if (!CanHarm(victim.name))
        {
            OnHitAnInvulnerable(victim);
            return;
        }
        if (CanAttackBeBlocked(victim))
        {
            OnAttackBlocked(victim);
            return;
        }

        if (instaKills || Kills(victim.name))
        {
            InstaKill(victim);
        }
        else
        {
            DealDamage(victim, (uint)damage);
        }
    }
Пример #2
0
 protected void OnHitAnInvulnerable(HealthController_Abstract invulnerable)
 {
     if (Delegate == null)
     {
         return;
     }
     Delegate.OnHitAnInvulnerable(this, invulnerable);
 }
Пример #3
0
 protected void OnDamageDealt(HealthController_Abstract victim, uint amount)
 {
     if (Delegate == null)
     {
         return;
     }
     Delegate.OnDamageDealt(this, victim, amount);
 }
Пример #4
0
 protected void OnInstaKilled(HealthController_Abstract victim)
 {
     if (Delegate == null)
     {
         return;
     }
     Delegate.OnInstaKilled(this, victim);
 }
Пример #5
0
 protected void OnAttackBlocked(HealthController_Abstract blocker)
 {
     if (Delegate == null)
     {
         return;
     }
     Delegate.OnAttackBlocked(this, blocker);
 }
Пример #6
0
 /*protected bool CanAttackBeDodged(HealthController_Abstract victim)
  * {
  *  if (Delegate == null)
  *      return false;
  *  return Delegate.CanAttackBeDodged(this, victim);
  * }*/
 protected bool CanAttackBeBlocked(HealthController_Abstract victim)
 {
     if (Delegate == null)
     {
         return(false);
     }
     return(Delegate.CanAttackBeBlocked(this, victim));
 }
Пример #7
0
    protected void InstaKill(HealthController_Abstract victim)
    {
        if (victim == null)
        {
            return;
        }

        victim.Kill(gameObject);      // TODO
        OnInstaKilled(victim);
    }
Пример #8
0
    protected void DealDamage(HealthController_Abstract victim, uint amount)
    {
        if (victim == null)
        {
            return;
        }

        victim.TakeDamage(amount, gameObject);      // TODO
        OnDamageDealt(victim, amount);
    }
    void OnCollisionEnter(Collision collision)
    {
        GameObject other             = collision.gameObject;
        HealthController_Abstract hc = TryGetHealthController(other);

        if (hc != null)
        {
            Attack(hc);
        }
    }
Пример #10
0
    void IDamageDealerDelegate.OnDamageDealt(DamageDealer_Base attacker, HealthController_Abstract victim, uint amount)
    {
        // TODO

        Enemy enemy = victim.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.Stun();
        }
    }
Пример #11
0
    bool IDamageDealerDelegate.CanAttackBeBlocked(DamageDealer_Base attacker, HealthController_Abstract victim)
    {
        Actor r = victim.GetComponent <Actor>();

        if (r == null)
        {
            return(false);
        }

        return(r.CanBlockAttack(woodenShieldBlocks, magicShieldBlocks, MoveDirection));     // TODO: remove the 2 "shieldCanBlock" params
    }
Пример #12
0
    protected static HealthController_Abstract TryGetHealthController(GameObject g)
    {
        HealthController_Abstract hc = g.GetComponent <HealthController_Abstract>();

        if (hc == null)
        {
            Transform otherParent = g.transform.parent;
            if (otherParent != null)
            {
                hc = otherParent.GetComponent <HealthController>();
            }
        }
        return(hc);
    }
Пример #13
0
    void OnAttackDeflected(DamageDealer_Base attacker, HealthController_Abstract deflector)
    {
        Actor r = deflector.GetComponent <Actor>();

        if (r == null)
        {
            return;
        }

        if (r.playSoundWhenBlockingAttack)
        {
            PlayDeflectionSound();
        }
    }
Пример #14
0
    IEnumerator AttackAllWithinReach_CR(float maxDistance)
    {
        yield return(new WaitForFixedUpdate());

        Vector3 center = transform.position;

        Collider[] colliders = Physics.OverlapSphere(center, maxDistance);
        foreach (Collider hit in colliders)
        {
            if (hit == null)
            {
                continue;
            }

            GameObject other             = hit.gameObject;
            HealthController_Abstract hc = TryGetHealthController(other);
            if (hc != null)
            {
                Attack(hc);
            }
        }
    }
Пример #15
0
 void IDamageDealerDelegate.OnAttackBlocked(DamageDealer_Base attacker, HealthController_Abstract blocker)
 {
     OnAttackDeflected(attacker, blocker);
 }
Пример #16
0
 void IDamageDealerDelegate.OnHitAnInvulnerable(DamageDealer_Base attacker, HealthController_Abstract invulnerable)
 {
     OnAttackDeflected(attacker, invulnerable);
 }
Пример #17
0
 void IDamageDealerDelegate.OnDamageDealt(DamageDealer_Base attacker, HealthController_Abstract victim, uint amount)
 {
 }
Пример #18
0
 void IDamageDealerDelegate.OnInstaKilled(DamageDealer_Base attacker, HealthController_Abstract victim)
 {
 }