Exemple #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)));
        }
Exemple #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);
        }
Exemple #3
0
        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);
        }