void MainWindow_EndGameEvent(object oSender, EventArgs Args) { GamePlayThread.Abort(); if (!_endGameInformationSend) { _endGameInformationSend = true; if (_scoreModule != null) { foreach (IArenaCallback client in avatarDictionary.Keys) // GamePlay is ending; { try { client.gamePlayEnd(_scoreCounter.GetTotalScoreForRobot(avatarDictionary[client])); } catch (Exception e) { EventLog.WriteErrorToLog(strErrorLogPath, e); } } CreateHistoryLogFile(_numberOfPlayedGames); _globalHistory.Clear(); // clear all history for that game } else { foreach (IArenaCallback client in avatarDictionary.Keys) {// GamePlay is ending; try { client.gamePlayEnd(0); } catch (Exception e) { EventLog.WriteErrorToLog(strErrorLogPath, e); } } } } _currentRound = 0; _currentMap = _initialMap.Copy(); _isGameStarted = false; _currentMovesQueue.Clear(); _globalHistory.Clear(); _scoreCounter.Clear(); _currentMap = (oSender as MainWindow).CurrentMap; foreach (RobotAvatar robotA in avatarDictionary.Values) { removeRobotFromMap(robotA.Color); } foreach (var client in avatarDictionary) { client.Value.CurrentMapForRobot = CreateStartingPack(client.Key, client.Value); } EventLog.WriteMessageToLog(strLogPath, "End of the game"); }