void StartTargetAttack(BaseUnitBehaviour target) { _model.StopCurrentAnimation(); Action <BaseUnitBehaviour> onTargetFound = _onTargetFound; _onTargetFound = null; StopAllCoroutines(); State = EUnitAttackState.WatchTarget; onTargetFound(target); }
private IEnumerator AttackTarget() { _lastAttackTime = Time.time; _lastTargetUnit = _targetUnit; if (_model.WFSAttackDelay != null) { yield return(_model.WFSAttackDelay); } if (!_performPlay) { _model.PlayAttackAnimation(DistanceToTarget); _performPlay = true; } if (!_performAttack) { EventsAggregator.Fight.Broadcast <BaseUnitBehaviour, BaseUnitBehaviour>(EFightEvent.PerformAttack, this, _targetUnit); _unitAttack.ToNextAttackUnit(this); _performAttack = true; } if (_unitAttack.State == EUnitAttackState.AttackTarget) { if (!_performWait) { _performWait = true; yield return(_cachedWaitForSeconds); } _model.StopCurrentAnimation(); StopTargetAttack(false); _targetUnit = null; _unitAttack.Reset(true); _corTargetAttack = null; } _performPlay = _performAttack = _performWait = false; }