Example #1
0
        public bool CanAttack(GameObject combatTarget)
        {
            if (combatTarget == null)
            {
                return(false);
            }
            Health targetToTest = combatTarget.GetComponent <Health>();

            return(targetToTest != null && targetToTest.IsAlive());
        }
Example #2
0
 // Checks if the target is null, and if not null, is it "alive". Returns true if neither condition is met
 public bool ValidTarget()
 {
     if (!target || target.IsAlive() == false)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #3
0
        private void Update()
        {
            _timeSinceLastAttack += Time.deltaTime;

            if (_target && GetIsInRange())
            {
                _mover.Cancel();

                if (_target.IsAlive())
                {
                    AttackBehaviour();
                }
                else
                {
                    Cancel();
                }
            }
        }
Example #4
0
 private void Update()
 {
     timeSinceLastAttack += Time.deltaTime;
     if (target == null)
     {
         return;
     }
     if (!target.IsAlive())
     {
         return;
     }
     if (!GetIsInRange())
     {
         mover.MoveTo(target.transform.position);
     }
     else
     {
         mover.StopMoving();
         AttackBehaviour();
     }
 }