/// <summary> /// this is when the game is over. /// </summary> /// <param name="message"></param> /// <returns></returns> async Task IHandleAsync <GameOverEventModel> .HandleAsync(GameOverEventModel message) //done. { //i propose just having the extra button for new game that appears when the game is over. CommandContainer.ClearLists(); //try this too. ReplaceGame(); //i think here it should replace the game. not so for rounds. //replacegame is where the problem is at. for clients, that seems to happen as well. if (BasicData.MultiPlayer == true && BasicData.Client == true) { return; //because only host can choose new game unless its single player game. } await _save.DeleteGameAsync(); if (MainVM == null) { throw new BasicBlankException("The main view model was not even available. Rethink"); } //get it fresh now. //this is one case where i have to replace the game. //also think about what else has to be replaced. //if there are other things that needs to be replaced that does not depend on the game processes, do here. //host has to decide if he even wants new game. if (_test.AlwaysNewGame) { //has to close so it can refresh agin. await CloseSpecificChildAsync(NewGameScreen !); NewGameScreen = null; //has to do again. that is the best way to handle so i can click new game. } await ShowNewGameAsync(); }
async Task IHandleAsync <GameOverEventModel> .HandleAsync(GameOverEventModel message) { CommandContainer.ClearLists(); //try this too. if (MainVM == null) { throw new BasicBlankException("The main view model was not even available. Rethink"); } await _saves.DeleteSinglePlayerGameAsync(); //just in case its forgotten, it will be deleted. await CloseSpecificChildAsync(MainVM); MainVM = null; if (NewGameVM != null) { return; } await GameOverScreenAsync(); if (AutoStartNewGame == false) { await OpenStartingScreensAsync(); } else { await ShowNewGameAsync(); //try this way (?) } }
private async Task StartNewGameAsync() { CommandContainer.ClearLists(); //try this too. hopefully this simple. ClearSubscriptions(); MainVM = GetMainViewModel(); await LoadScreenAsync(MainVM); FinishInit(); }
/// <summary> /// this is when somebody chooses new game. /// </summary> /// <param name="message"></param> /// <returns></returns> async Task IHandleAsync <NewGameEventModel> .HandleAsync(NewGameEventModel message) { await PrepNewGameAsync(); if (_test.AlwaysNewGame) { CommandContainer.ClearLists(); //try this too. await _save.DeleteGameAsync(); //i think. ReplaceGame(); //try this too. //other things are needed here too. } if (NewGameScreen == null) { throw new BasicBlankException("New game was not even active. Therefore, I should not have received message for requesting new game"); } await CloseMainAsync("Should have shown main game when showing new game."); //i think i should load it again anyways (?) and set the old to nothing. so a fresh one will be created. //maybe we don't need the update code but we still need the load processes. //since we have code for closing, hopefully i am not forced to figure out how to delete controls (?) await _save.DeleteGameAsync(); //i think. await CloseSpecificChildAsync(NewGameScreen); NewGameScreen = null;//forgot to set to null. await NewGameOrRoundRequestedAsync(); if (_mainGame == null) { throw new BasicBlankException("Failed to replace game when requesting new game. Rethink"); } //can't load here because it thinks you have the old file (wrong). //await LoadGameScreenAsync(); //i think in this case, should load here. IRequestNewGameRound gameRound = MainContainer.Resolve <IRequestNewGameRound>(); await gameRound.RequestNewGameAsync(); }