Exemplo n.º 1
0
        public override IActorTask GetTask(IActor actor, ILogicStrategyData strategyData)
        {
            if (!strategyData.ExitNodes.Any())
            {
                Complete = true;
                return(null);
            }

            var actorNode = actor.Node;

            if (_map.Transitions.TryGetValue(actorNode, out var currentTransition))
            {
                _sector.UseTransition(currentTransition);
                Complete = true;
                return(null);
            }

            if (_moveTask == null || _moveTask.IsComplete || !_moveTask.CanExecute())
            {
                var nearbyExitNode = strategyData.ExitNodes
                                     .OrderBy(x => _map.DistanceBetween(actor.Node, x))
                                     .First();

                _moveTask = CreateMoveTask(actor, nearbyExitNode);

                if (_moveTask == null)
                {
                    Complete = true;
                    return(null);
                }

                return(_moveTask);
            }
            else
            {
                return(_moveTask);
            }
        }
Exemplo n.º 2
0
 public void MoveToOtherSector(ISector sector, SectorTransition sectorTransition)
 {
     BeginTransitionToOtherSector?.Invoke(this, EventArgs.Empty);
     sector.UseTransition(this, sectorTransition);
 }