Ejemplo n.º 1
0
 protected virtual bool AttackTarget(bool _repeatAttack)
 {
     if (distanceToTarget <= range)
     {
         CurrentState = LivingEntityState.Attacking;
         attackTime = 1;
         //animation trigger goes here
         target.TakeDamage(attackDamage);
         Debug.Log(gameObject.name + " Attacked " + target.gameObject.name + "!!");
         if (!_repeatAttack)
         {
             chasing = false;
         }
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 2
0
 protected virtual void Update()
 {
     switch (CurrentState)
     {
             // ====
         case LivingEntityState.Idle:
             if (target && chasing)
             {
                 if (!AttackTarget(true))
                 {
                     Move(target);
                 }
             }
             else
             {
                 chasing = false;
             }
             break;
             // ====
         case LivingEntityState.Moving:
             break;
             // ====
         case LivingEntityState.Attacking:
             agent.destination = transform.position;
             if (attackTime > 0)
             {
                 attackTime -= Time.deltaTime;
             }
             else
             {
                 CurrentState = LivingEntityState.Idle;
             }
             break;
             // ====
     }
 }