예제 #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 (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);
        }