public bool CanAttack(GameObject combatTarget) { if (combatTarget == null) { return(false); } Health targetToTest = combatTarget.GetComponent <Health>(); return(targetToTest != null && targetToTest.IsAlive()); }
// 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); } }
private void Update() { _timeSinceLastAttack += Time.deltaTime; if (_target && GetIsInRange()) { _mover.Cancel(); if (_target.IsAlive()) { AttackBehaviour(); } else { Cancel(); } } }
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(); } }