Exemplo n.º 1
0
        private static bool ResolveAutopilotBeginTravel(AutopilotBeginAction action, EncounterState state)
        {
            var           playerPosition = state.Player.GetComponent <PositionComponent>().EncounterPosition;
            EncounterZone zone           = state.GetZoneById(action.ZoneId);

            var foundPath      = Pathfinder.AStarWithNewGrid(playerPosition, zone.Center, state, 9000);
            int autopilotTries = 0;

            while (foundPath == null && autopilotTries < 5)
            {
                foundPath = Pathfinder.AStarWithNewGrid(playerPosition, zone.RandomEmptyPosition(state.EncounterRand, state), state, 9000);
                autopilotTries++;
            }
            if (foundPath != null && autopilotTries > 0)
            {
                state.LogMessage(String.Format("Autopilot could not find path to center of [b]{0}[/b]; autopiloting to randomly chosen position in [b]{0}[/b].", zone.ZoneName));
                state.Player.GetComponent <PlayerComponent>().LayInAutopilotPathForTravel(new EncounterPath(foundPath));
                return(true);
            }
            else if (foundPath != null)
            {
                state.LogMessage(String.Format("Autopiloting to [b]{0}[/b]", zone.ZoneName));
                state.Player.GetComponent <PlayerComponent>().LayInAutopilotPathForTravel(new EncounterPath(foundPath));
                return(true);
            }
            else
            {
                state.LogMessage(String.Format("Autopilot failed to plot course to to [b]{0}[/b]", zone.ZoneName), failed: true);
                return(false);
            }
        }
Exemplo n.º 2
0
        private static bool ResolveAutopilotBeginExplore(AutopilotBeginAction action, EncounterState state)
        {
            var playerComponent = state.Player.GetComponent <PlayerComponent>();

            playerComponent.BeginAutoexploring(action.ZoneId);
            return(true);
        }
Exemplo n.º 3
0
 private static bool ResolveAutopilotBegin(AutopilotBeginAction action, EncounterState state)
 {
     if (action.Mode == AutopilotMode.TRAVEL)
     {
         return(ResolveAutopilotBeginTravel(action, state));
     }
     else if (action.Mode == AutopilotMode.EXPLORE)
     {
         return(ResolveAutopilotBeginExplore(action, state));
     }
     else
     {
         throw new NotImplementedException(string.Format("Rulebook doesn't know how to handle autopilot mode {0}", action.Mode));
     }
 }