public override CognitionState Update() { if (ProbabilisticTriggering.TestOnAverageOnceEvery(0.1f)) { if (Map.ArePositionsOnTheSameTile(Unit.LogicPosition, _path[0])) { return(DisposeCurrent() .AndChangeStateTo(StatesFactory.CreateWatching(null, 3))); } if (Vision.UnitsSpottedByTeam.Count > 0) { var target = Vision.GetHighestPriorityTarget(); return(DisposeCurrent().AndChangeStateTo(StatesFactory.CreateChasing(target))); } } MovementHelper.ManageMovingAlongThePath(_path); Unit.Control.LookAt(_path[0]); return(this); }
public override CognitionState Update() { _timeSpent += Time.deltaTime; if (_isLimited && _timeSpent > _timeLimit) { return(DisposeCurrent().AndReturnToThePreviousState()); } if (Map.IsPositionDangorous(Unit.LogicPosition)) { ProbabilisticTriggering.PerformOnAverageOnceEvery(0.1f, ChangeDirection); } ProbabilisticTriggering.PerformOnAverageOnceEvery(2, ChangeDirection); if (Vision.UnitsSpottedByTeam.Count > 0) { var target = Vision.GetHighestPriorityTarget(); return(RememberCurrent().AndChangeStateTo(StatesFactory.CreateChasing(target))); } return(this); }