private static void GenerateNewFinishedGameMessage(object sender, GameFinishedEventArgs e) { var gameMaster = sender as GameMaster; gameMaster.LogGameResults(e.Winners); _finishedGameMessage = "Last game winners: " + (e.Winners == TeamColor.Red ? "Red " : "Blue"); }
private void ActiveGame_GameFinished(object sender, GameFinishedEventArgs e) { if (e.IsWin) { GamerProfile.Statistics["total.totalwin", true].ValueInt++; GamerProfile.Statistics["total.totalplayed.level" + ActiveGame.DifficultLevel + ".win", true].ValueInt++; } else { GamerProfile.Statistics["total.totallose", true].ValueInt++; GamerProfile.Statistics["total.totalplayed.level" + ActiveGame.DifficultLevel + ".lose", true].ValueInt++; switch (e.FinishType) { case GameFinishType.GameFinish_LoseResign: GamerProfile.Statistics["total.totallose.resign", true].ValueInt++; break; case GameFinishType.GameFinish_LoseTimeOver: GamerProfile.Statistics["total.totallose.losetime", true].ValueInt++; break; case GameFinishType.GameFinish_LOseLifeOver: GamerProfile.Statistics["total.totallose.lifeleft", true].ValueInt++; break; } } double tplayedsec = (DateTime.Now - ActiveGame.GameStartedAt).TotalSeconds; if (!GamerProfile.FirstPlayed) { GamerProfile.Statistics["first.guesscount", true].Value = ActiveGame.TotalGuessCount; GamerProfile.Statistics["first.pluscount", true].Value = ActiveGame.TotalPlus; GamerProfile.Statistics["first.minuscount", true].Value = ActiveGame.TotalMinus; GamerProfile.Statistics["first.playedsec", true].ValueDouble = tplayedsec; GamerProfile.FirstPlayed = true; } GamerProfile.Statistics["last.guesscount", true].Value = ActiveGame.TotalGuessCount; GamerProfile.Statistics["last.pluscount", true].Value = ActiveGame.TotalPlus; GamerProfile.Statistics["last.minuscount", true].Value = ActiveGame.TotalMinus; GamerProfile.Statistics["last.playedsec", true].ValueDouble = tplayedsec; GamerProfile.Statistics["playedtime.totalplayedsec", true].ValueDouble += tplayedsec; if (tplayedsec > GamerProfile.Statistics["playedtime.longplayedsec", true].ValueDouble) { GamerProfile.Statistics["playedtime.longplayedsec", true].ValueDouble = tplayedsec; GamerProfile.Statistics["playedtime.longplayedtime", true].Value = DateTime.Now; } if (GamerProfile.Statistics["playedtime.shortplayedsec", true].ValueDouble <= 0) { GamerProfile.Statistics["playedtime.shortplayedsec", true].ValueDouble = tplayedsec; GamerProfile.Statistics["playedtime.shortplayedtime", true].Value = DateTime.Now; } else { if (tplayedsec < GamerProfile.Statistics["playedtime.shortplayedsec", true].ValueDouble) { GamerProfile.Statistics["playedtime.shortplayedsec", true].ValueDouble = tplayedsec; GamerProfile.Statistics["playedtime.shortplayedtime", true].Value = DateTime.Now; } } }
private void onGameFinished(Player i_PlayerOne, int i_PlayerOneCurrentGameScore, Player i_PlayerTwo, int i_PlayerTwoCurrentGameScore) { if (m_GameFinishedDelegate != null) { GameFinishedEventArgs gameFinishedArgs = new GameFinishedEventArgs(i_PlayerOne, i_PlayerOneCurrentGameScore, i_PlayerTwo, i_PlayerTwoCurrentGameScore); m_GameFinishedDelegate.Invoke(this, gameFinishedArgs); } }
private void RaiseGameFinished(GameFinishedEventArgs e) { EventHandler <GameFinishedEventArgs> handler = GameFinished; if (handler != null) { handler(this, e); } }
public void OnGameFinished(object source, GameFinishedEventArgs gameFinishedEventArgs) { var options = new JsonSerializerOptions { WriteIndented = true }; string jsonString = JsonSerializer.Serialize(gameFinishedEventArgs, options); File.WriteAllText("local_json_file.json", jsonString); }
private static void Runner_GameFinished(object sender, GameFinishedEventArgs e) { Console.Clear(); Console.WriteLine("Game finished"); foreach (GameCommand command in e.Commands) { Console.WriteLine($" { command.PlayerName } ; { command.BotId } ; { command.ActionType } { stringArrToString(command.StepParams) } "); } }
public void OnGameFinished(object sender, GameFinishedEventArgs args) { //_dispatcher.Invoke( // new Action(() => // { if (GameFinished != null) { GameFinished(sender, args); } // }), System.Windows.Threading.DispatcherPriority.Normal); }
private async void OnGameFinished(object sender, GameFinishedEventArgs e) { var logger = (sender as GameSimulator).Logger; var logs = logger.GetLogs(); var gameData = await _resultsApiClient.GetScoreAsync(e.GameId); gameData.Logs = logs; gameData.WinnerId = e.WinnerTankId; gameData.Status = GameStatus.Finished; await _resultsApiClient.UpdateAsync(gameData); }
/// <summary> /// Runs after someone died, show highschore , winner and gametime /// </summary> /// <param name="sender">sender</param> /// <param name="e">e</param> private void GL_GameFinished(object sender, EventArgs e) { Application.Current.Dispatcher?.Invoke(() => { GameFinishedEventArgs gamefinished = e as GameFinishedEventArgs; HighScoreWindow highScoreWindow = new HighScoreWindow(); MessageBox.Show( "A nyertes neve " + gamefinished.WinnerName + " pontjai: " + gamefinished.WinnerPoints + " pts" + "\nA vesztes neve: " + gamefinished.LoserName + " pontjai: " + gamefinished.LoserPoints + " pts" + "\nA játékidő: " + gamefinished.Gametime.ToString() + " mp volt"); highScoreWindow.ShowDialog(); this.gL.SoundSystem.PlayGameStartSound(); this.Close(); }); }
//public override bool OnCursorClick(Vector2 pos) //{ // if (base.OnCursorClick(pos)) // { // return true; // } // else { // if (GhostlyActionHandlers.CurrentLevel != null) { // if (pos.X > _engine.Device.Viewport.Width / 2) // { // GhostlyActionHandlers.CurrentLevel.ProcessPrimaryAction(true); // } else { // GhostlyActionHandlers.CurrentLevel.ProcessSecondaryAction(true); // } // } // return false; // } //} private void _screen_GameFinished(object sender, GameFinishedEventArgs e) { GhostlyGame.Instance.OnGameFinished(e.Score, e.Level, e.Reason); if (e.Reason == GameFinishedEventArgs.EndReason.GameFailed) { Components.Remove(_gameplayPanel); Components.Add(_gameOverPanel); } else if (e.Reason == GameFinishedEventArgs.EndReason.GoalAccomplished) { Components.Remove(_gameplayPanel); Components.Add(_levelDonePanel); _scoreLabel.Text = "Score: " + e.Score; } }
public void OnGameFinished(object sender, GameFinishedEventArgs e) { Console.WriteLine("Game finished! Would you like to play again?"); Console.WriteLine("Press [Y] key to play again or any other key to exit."); WritePrompt(); var keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Y) { e.Restart(); RefreshConsole(e.Board); return; } Environment.Exit(0); }
public void OnGameFinished(object source, GameFinishedEventArgs gameFinishedEventArgs) { StringBuilder sb = new StringBuilder(); Team winner = gameFinishedEventArgs.Winner; Team loser = gameFinishedEventArgs.Loser; Boolean draw = gameFinishedEventArgs.Draw; string result = "Winner: \n" + "TeamId: " + winner.TeamId + "\nTeam score: " + winner.getTeamScore() + "\nLoser: \n" + "TeamId: " + loser.TeamId + "\nTeam score: " + loser.getTeamScore() + "\nDraw: " + draw; Console.WriteLine(result); Console.WriteLine("\nAdditional:\nWinner: \n" + winner.ToString() + "\nLoser: \n" + loser.ToString()); }
private void GameManagerOnGameFinished(object sender, GameFinishedEventArgs gameFinishedEventArgs) { SyncContext.Send((_) => { IsPlaying = false; IsGameOver = true; WhiteCount = gameFinishedEventArgs.WhiteCount; BlackCount = gameFinishedEventArgs.BlackCount; var draftString = "The game is draft"; var noDraftString = gameFinishedEventArgs.WhiteWins == null ? null : string.Format("{0} Wins!!!", gameFinishedEventArgs.WhiteWins.Value ? "Whites" : "Blacks"); WinString = gameFinishedEventArgs.WhiteWins == null ? draftString : noDraftString; CurrentState = WinString; BlackTimer.Stop(); WhiteTimer.Stop(); }, null); }
public void MoveNext() { if (IsEndGame || IsPlaying || !GameStarted) { return; } IsPlaying = true; var nextMove = CurrentPlayerAtTurn.GetNextMove(Board); if (nextMove == null) //if can't move { IsPlaying = false; return; } if (nextMove.IsPassMove && HasPlayerPassed) //finish case { IsEndGame = true; var whites = Board.WhitePoints.Count; var blacks = Board.BlackPoints.Count; var gameFinishedEventArgs = new GameFinishedEventArgs { WhiteCount = whites, BlackCount = blacks }; if (whites - blacks != 0) { gameFinishedEventArgs.WhiteWins = whites - blacks > 0; } RaiseGameFinished(gameFinishedEventArgs); GameStarted = false; IsPlaying = false; return; } HasPlayerPassed = nextMove.IsPassMove; MakeMove(nextMove); IsPlaying = false; }
private void Runner_GameFinished(object sender, GameFinishedEventArgs e) { GameFinished?.Invoke(this, e); }
//event for window closing by the button - event private void EndingWindow_GameResultsWindowClosing(object sender, GameFinishedEventArgs e) { willBeClosedAsHost = true; OnGameResultsWindowClosing(e.PlayedGames, e.PlayedAndWonGames); this.Close(); }
private void GameManager_OnNumberGuessedEvent(object?sender, GameFinishedEventArgs e) { GuessedTextBlock.Text = $"You have guessed it! It was {e.WinningNumber}"; GuessedTextBlock.Visibility = Visibility.Visible; e.StartNewGame = StartNewGameCheckBox.IsChecked ?? false; }
private void GameMaster_GameFinished(object sender, GameFinishedEventArgs e) { Winners = e.Winners; GameFinished = true; }
private void Game_GameFinished(object sender, GameFinishedEventArgs e) { ClearTable(); ClearPlayerPanels(); RefreshStat(e.LastRoundWinner); }