/// <summary> /// /// Define whether characters can do attack behaviour. /// /// </summary> /// <param name="combatTarget">Attack attackTarget</param> /// <returns> /// True: characters can attack; /// False: characters can't attack. /// </returns> public bool CanAttack(GameObject combatTarget) { if (!combatTarget) { return(false); } Health targetToTest = combatTarget.GetComponent <Health>(); // Health component can tell us whether this character is dead. return(targetToTest && !targetToTest.IsDead()); }
public bool CanAttack(GameObject combatTarget) { if (combatTarget == null) { return(false); } if (GetComponent <Mover>().CanMoveTo(combatTarget.transform.position) && !GetIsInRange(combatTarget.transform)) { return(false); } Health targetToTest = combatTarget.GetComponent <Health>(); return(targetToTest != null && !targetToTest.IsDead()); }
public bool CanAttack(GameObject target) { if (target == null) { return(false); } if (!_mover.CanMoveTo(target.transform.position) && !IsInRange(target.transform)) { return(false); } Health targetToTest = target.GetComponent <Health>(); return(targetToTest != null && !targetToTest.IsDead()); }
private void Update() { _timeSinceLastAttack += Time.deltaTime; if (_target == null) { return; } if (_target.IsDead()) { return; } if (_target != null && !GetIsInRange(_target.transform)) { GetComponent <Mover>().MoveTo(_target.transform.position, 1f); } else { GetComponent <Mover>().Cancel(); AttackBehavior(); } }
private void Update() { _timeSinceLastAttack += Time.deltaTime; if (_target == null) { return; } if (_target.IsDead()) { return; } if (!IsInRange(_target.transform)) { _mover.MoveTo(_target.transform.position, 1f); } else { _mover.Cancel(); AttackBehaviour(); } }