/// <summary> /// Gets the next state if a given command/transition is run /// </summary> /// <param name="command">The command (or transition) to run</param> /// <returns></returns> MenuStates GetNext(MenuCommands command) { //Construct the new transition based on the machines current state, and the supplied transition/command MenuTransitions newTransition = new MenuTransitions(CurrentState, command); //Location to store the new state for the machine to go into MenuStates newState; //Make sure that the transition is valid, using the dictionary lookup if (!allTransitions.TryGetValue(newTransition, out newState)) { throw new UnityException("Invalid transition " + CurrentState + " -> " + command); } //If at this point we have not broken anything, return the new state return(newState); }
/// <summary> /// Gets the next state if a given command/transition is run /// </summary> /// <param name="command">The command (or transition) to run</param> /// <returns></returns> MenuStates GetNext(MenuCommands command) { //Construct the new transition based on the machines current state, and the supplied transition/command MenuTransitions newTransition = new MenuTransitions (CurrentState, command); //Location to store the new state for the machine to go into MenuStates newState; //Make sure that the transition is valid, using the dictionary lookup if (!allTransitions.TryGetValue(newTransition, out newState)) throw new UnityException("Invalid transition " + CurrentState + " -> " + command); //If at this point we have not broken anything, return the new state return newState; }
public override bool Equals(object obj) { MenuTransitions other = obj as MenuTransitions; return(other != null && this.currentState == other.currentState && this.command == other.command); }
/// <summary> /// Gets the next state if a given command/transition is run /// </summary> /// <param name="command">The command (or transition) to run</param> /// <returns></returns> MenuStates GetNext(MenuCommands command) { MenuTransitions newTransition = new MenuTransitions(CurrentState, command); MenuStates newState; if (!allTransitions.TryGetValue(newTransition, out newState)) { throw new UnityException("Invalid Transition" + CurrentState + "-->" + command); } return newState; }