Пример #1
0
        public override CognitionState Update()
        {
            if (Map.IsPositionDangorous(Unit.LogicPosition))
            {
                return(RememberCurrent().AndChangeStateTo(StatesFactory.CreateStrafing(_target)));
            }

            if (_target.IsVisible)
            {
                if (ProbabilisticTriggering.TestOnAverageOnceEvery(0.1f))
                {
                    _path = Map.PathFinder.FindPath(Unit.LogicPosition,
                                                    _target.Position);
                }

                TargetingHelper.ManageAimingAtTheTarget(_target);

                var distanceToTarget = (_target.Position - Unit.LogicPosition).magnitude;
                if (distanceToTarget > 4)
                {
                    MovementHelper.ManageMovingAlongThePath(_path);
                }

                return(this);
            }

            return(DisposeCurrent().AndChangeStateTo(StatesFactory.CreateSearching(_target)));
        }
Пример #2
0
 public override CognitionState Update()
 {
     if (!Map.IsPositionDangorous(Unit.LogicPosition))
     {
         return(DisposeCurrent().AndReturnToThePreviousState());
     }
     ProbabilisticTriggering.PerformOnAverageOnceEvery(0.3f,
                                                       () => _path = Map.PathFinder.FindSafespot(Unit.LogicPosition));
     MovementHelper.ManageMovingAlongThePath(_path);
     if (_target.IsVisible)
     {
         TargetingHelper.ManageAimingAtTheTarget(_target);
     }
     return(this);
 }
Пример #3
0
        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);
        }