/// <summary> /// Gets the commands to be executed based on the specified state /// </summary> /// <param name="state"></param> /// <returns></returns> protected List <NaoCommand> GetCommands(NaoState state) { var commands = new List <NaoCommand>(); var index = StateCommands.IndexOf(state); if (index != -1) { for (int i = index; i < StateCommands.Count; i++) { commands.AddRange(StateCommands[i].Keys); } } return(commands); }
public void Initialize() { StateCommands.Add(new StateCommand(StateCommandType.Left, Key.Left, gm => gm.BlockNow.Left())); StateCommands.Add(new StateCommand(StateCommandType.Right, Key.Right, gm => gm.BlockNow.Right())); StateCommands.Add(new StateCommand(StateCommandType.Down, Key.Down, gm => gm.BlockNow.Down())); PressCommands.Add(new PressCommand(PressCommandType.Hold, Key.Z, gm => gm.Hold())); PressCommands.Add(new PressCommand(PressCommandType.HardDrop, Key.C, gm => gm.HardDrop())); PressCommands.Add(new PressCommand(PressCommandType.RotateCw, Key.Up, gm => gm.BlockNow.RotateCw())); PressCommands.Add(new PressCommand(PressCommandType.RotateCcw, Key.X, gm => gm.BlockNow.RotateCcw())); PressCommands.Add(new PressCommand(PressCommandType.Reset, Key.Escape, gm => gm.Reset())); }
GameState GetNext(StateCommands command) { //construct transition based on machine current state and the command ScriptPhaseTransition newTransition = new ScriptPhaseTransition(CurrentState, command); //store the location to got to here GameState newState; if (!allTransitions.TryGetValue(newTransition, out newState)) { throw new UnityException("Invalid Game State transition " + CurrentState + " -> " + command); } //return the new state return(newState); }
//!---CONSTRUCTORS---! public StateEvents(string name, StateCommands cmd) { this.name = name; this.cmd = cmd; }
GameState GetNext(StateCommands command) { //construct transition based on machine current state and the command ScriptPhaseTransition newTransition = new ScriptPhaseTransition(CurrentState, command); //store the location to got to here GameState newState; if (!allTransitions.TryGetValue(newTransition, out newState)) throw new UnityException("Invalid Game State transition " + CurrentState + " -> " + command); //return the new state return newState; }
public ScriptPhaseTransition(GameState thisPhase, StateCommands thisCommand) { currentPhase = thisPhase; command = thisCommand; }
/// <summary> /// Starts the robot /// </summary> public void Start() { this.Start(StateCommands.GetItem(0).Key); }