public void CloseGameWindowAndCleanup(GameEnd endType, bool forceQuit = false) { if (GameType != Gametype.TOURNAMENT_GAME || endType == GameEnd.SERVER_DISCONNECTED || endType == GameEnd.TOURNAMENT_FINISHED) { RequestStop(); } gameRunning = false; StateMgr.Clear(); if (Application.Current == null) { return; } if (forceQuit) { NormalGameEnded(); } else if (GameType == Gametype.TOURNAMENT_GAME && endType != GameEnd.SERVER_DISCONNECTED && endType != GameEnd.TOURNAMENT_FINISHED) { TournamentGameEnded(); } else if (endType != GameEnd.TOURNAMENT_FINISHED) { NormalGameEnded(); } if (particleArea != null) { particleArea.ClearAll(); } particleArea = null; }