public void Init() { Engine = new GameEngine(); menuInput = new UserInputController(); gameInput = new UserInputController(); fsa.AddLink(States.Menu, States.Game, "new", OnNewGame); fsa.AddLink(States.Init, States.Menu, "init_complete", OnExitToMenu); var exitCommand = new UserCommand("exit", "Immediately closes the application", "OnExit", this, null); menuInput.AddCommand(exitCommand); gameInput.AddCommand(exitCommand); menuInput.AddCommand(new UserCommand("new", "Starts new game", () => fsa.Switch("new"))); gameInput.AddCommand(new UserCommand("list", "Shows this list", OnPrintListOfCommands)); gameInput.AddCommand(new UserCommand("look", "Look at location for more details", "OnOverview", Engine, new ArgumentSet(typeof(string)))); gameInput.AddCommand(new UserCommand("turn", "Next turn", "OnTurn", Engine, null)); fsa.Switch("init_complete"); }
void OnExitToMenu(States oldState, States newState) { currentInput = menuInput; OnPrintListOfCommands(); }
void OnNewGame(States oldState, States newState) { currentInput = gameInput; Engine.CreateNewGame(); Console.WriteLine("Welcome to the GameOfHomes! Type 'list' for a list of commands"); }