Esempio n. 1
0
        public void ShouldRaiseEndGameEventAfterGameTimeElapsed()
        {
            AutoResetEvent     endedEvent = new AutoResetEvent(false);
            GameEndedEventArgs args       = null;

            this.game.GameEnded += (o, e) =>
            {
                ThreadPool.QueueUserWorkItem((state) =>
                {
                    args = e;
                    endedEvent.Set();
                });
            };
            game.Start();

            game.IncrementScore(userId, 1);
            game.IncrementScore(friendUserId, 2);
            game.IncrementScore(userId, 3);

            endedEvent.WaitOne(1500);

            Assert.NotNull(args);
            Assert.Equal(userId, args.WinnerUserId);
            Assert.Equal(game.Id, args.Game.Id);
        }
Esempio n. 2
0
 private void GameSession_OnGameEnded(object sender, GameEndedEventArgs e)
 {
     if (e.GameResult == GameResult.Draw)
     {
         SendData("draw");
     }
 }
Esempio n. 3
0
 private void TileManager_OnSideChange(object sender, EventArgs e)
 {
     previousMovements = _movements.Count;
     _movements        = CalculatePossibleMovements(CurrentSide);
     if (_movements.Count == 0)
     {
         if (previousMovements == 0)
         {
             GameEndedEventArgs gameEndedEventArgs;
             if (CountTiles(false) > CountTiles(true))//player win
             {
                 gameEndedEventArgs = new GameEndedEventArgs(-1, score);
             }
             else if (CountTiles(false) == CountTiles(true))
             {
                 gameEndedEventArgs = new GameEndedEventArgs(0, score);
             }
             else
             {
                 gameEndedEventArgs = new GameEndedEventArgs(1, score);
             }
             OnGameEnded(this, gameEndedEventArgs);
         }
         else
         {
             CurrentSide = !CurrentSide;
         }
     }
 }
Esempio n. 4
0
        private void ProcessGameEnded(object sender, GameEndedEventArgs gameEndedEventArgs)
        {
            var winnerMessage = gameEndedEventArgs.Winner == null ? "Draw" : $"{gameEndedEventArgs.Winner.Name} won";

            LogMessage(LogLevel.Debug, $"Game ended, {winnerMessage}");
            var lastMove = gameEndedEventArgs.History.Last();

            App.RunOnUiThread(() => _cellControls[lastMove.X, lastMove.Y].LoadPicture(_currentSign));

            if (gameEndedEventArgs.WinningSet != null)
            {
                App.RunOnUiThread(() =>
                {
                    foreach (var cell in gameEndedEventArgs.WinningSet)
                    {
                        _cellControls[cell.X, cell.Y].LoadWonPicture(_currentSign);
                    }
                });
            }

            App.RunOnUiThread(() =>
            {
                WinnerLabel.Content = winnerMessage;
                FieldGrid.IsEnabled = false;
                if (MessageBox.Show(this, "Restart now?", "TicTacToe", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    Load();
                }
            });
        }
Esempio n. 5
0
        /// <summary>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnGameEnded(object sender, GameEndedEventArgs e)
        {
            Screen.IsPaused = true;

            var screen = new MultiplayerScreen(OnlineManager.CurrentGame, true);

            Screen.Exit(() => new ResultScreen(Screen, GetScoreboardUsers(), screen));
        }
Esempio n. 6
0
 private static void GameEndedEventHandler(object sender, GameEndedEventArgs e)
 {
     if (Main.netMode == 1)
     {
         UI.Error(Lang.inter[66], Lang.inter[67]);
         Main.saveOnExit = UI.main.autoSave;
         UI.main.ExitGame();
     }
 }
 private void _gameLogic_GameFinished(object sender, GameEndedEventArgs e)
 {
     Winner         = e.Winner;
     IsGameFinished = true;
     Task.Delay(3000).ContinueWith((x) =>
     {
         IsGameFinished = false;
         _gameLogic.StartGame();
     });
 }
Esempio n. 8
0
        public GameEndedEventArgs RunSilently()
        {
            GameEndedEventArgs result = null;

            GameStateChanged = (sender, args) => ReportStepProcessed();
            GameEnded        = (sender, args) => result = args;
            Start();
            WaitCompleted();
            return(result);
        }
Esempio n. 9
0
        public async Task GameEnded(int redId, int blueId, GameEndedEventArgs args)
        {
            using Packet packet = new Packet((int)ServerPackets.TroopMoved);
            packet.Write(args.Score.Red);
            packet.Write(args.Score.Blue);

            await server.SendPacket(redId, packet);

            await server.SendPacket(blueId, packet);
        }
Esempio n. 10
0
        private void Game_GameEnded(object sender, GameEndedEventArgs e)
        {
            UpdateUI();
            MessageBox.Show(
                e.Winner == null ? "Draw!" : $"Player { e.Winner.Name } wins!",
                "GAME ENDED",
                MessageBoxButton.OK,
                MessageBoxImage.Information
                );

            Close();
        }
Esempio n. 11
0
 void moveGenerator_GameEnded(object sender, GameEndedEventArgs e)
 {
     if (e.Winner == Defaults.WHITE)
     {
         MessageBox.Show("The White player wins the game.", "Game over");
     }
     else
     {
         MessageBox.Show("The Black player wins the game.", "Game over");
     }
     this.GameRunning = false;
 }
 /// <summary>
 /// Handle the end of the game session.
 /// </summary>
 void networkSession_GameEnded(object sender, GameEndedEventArgs e)
 {
     if ((world != null) && !world.GameWon && !world.GameExited)
     {
         world.GameExited = true;
     }
     if (!IsExiting && ((world == null) || world.GameExited))
     {
         world = null;
         ExitScreen();
         networkSession = null;
     }
 }
        //private void AcceptedCard(object sender, ACRCardAcceptedCardScanEventArg e)
        //{
        //    if (!Disabled)
        //    {
        //        if (e.EventsACR122UManager.Card == null && !GameRunning)
        //        {
        //            #region depreciated
        //            //byte Data;
        //            //Logger.WriteLog("Accepted Card with ATR: " + e.ATRString);
        //            //try
        //            //{
        //            //    CardManger.ConnectToCard();
        //            //    CardManger.LoadAthenticationKeys(ACR122U_KeyMemories.Key1, AuthenticationKeys);
        //            //}
        //            //catch
        //            //{
        //            //    Logger.WriteLog("Unable to connect to card as card has been removed from reader. System is now aborting operations.", LoggerWarringLevel.Warring);
        //            //    return;
        //            //}
        //            //try
        //            //{
        //            //    CardManger.Athentication(8, ACR122U_Keys.KeyB, ACR122U_KeyMemories.Key1);
        //            //    Logger.WriteLog("Card success fully athenticated.");
        //            //}
        //            //catch
        //            //{
        //            //    Logger.WriteLog("Card Athentication failed.", LoggerWarringLevel.Warring);
        //            //    CardManger.SetLEDandBuzzerControl(NFC_CardReader.ACR122U.ACR122U_LEDControl.AllOn, 20, 20, 5, NFC_CardReader.ACR122U.ACR122U_BuzzerControl.BuzzerOnT1And2Cycle, out Data);
        //            //    return;
        //            //}

        //            //switch (MainConfig.StarterMode)
        //            //{
        //            //    case GameStartMode.SingleGameStarter:
        //            //        StartGameAsSingleGameStarter();
        //            //        break;
        //            //    case GameStartMode.AttendantChargeDeskOnly:
        //            //        StartGameAsAttendantChargeDeskOnly();
        //            //        break;
        //            //    case GameStartMode.MultiSocketStarterMaster:
        //            //        StartGameAsMultiSocketStarterMaster();
        //            //        break;
        //            //    case GameStartMode.MultiSocketStarterSlave:
        //            //        StartGameAsMultiSocketStarterSlave();
        //            //        break;
        //            //}
        //            #endregion
        //        }
        //    }
        //    else
        //        Logger.WriteLog("Accepted Card with ATR: " + e.ATRString + ". However the machine has been disabled.");
        //}

        //private void RejectedCard(object sender, ACRCardRejectedCardScanEventArg e)
        //{
        //    if (!Disabled)
        //    {
        //        Logger.WriteLog("Rejected Card with ATR: " + e.ATRString, LoggerWarringLevel.Warring);
        //        byte Data;
        //        try
        //        {
        //            e.EventsACR122UManager.ConnectToCard();
        //            e.EventsACR122UManager.SetLEDandBuzzerControl(NFC_CardReader.ACR122U.ACR122U_LEDControl.AllOn, 20, 20, 5, NFC_CardReader.ACR122U.ACR122U_BuzzerControl.BuzzerOnT1And2Cycle, out Data);
        //            e.EventsACR122UManager.DisconnectToCard();
        //            Logger.WriteLog("Razing buzzer razed");
        //        }
        //        catch
        //        {
        //            Logger.WriteLog("Attempted buzzer read, but card has been pulled. This may have resulted in a miss read. Buzzer aborted");
        //        }
        //    }
        //    else
        //        Logger.WriteLog("Rejected Card with ATR: " + e.ATRString + ". However the machine has been disabled.", LoggerWarringLevel.Warring);
        //}

        //private void CardRemoved(object sender, ACRCardRemovedEventArg e)
        //{
        //    Logger.WriteLog("Card Removed from Reader.");
        //    e.EventsACR122UManager.DisconnectToCard();
        //}

        //private void CardDectected(object sender, ACRCardDetectedEventArg e)
        //{
        //    if (e.EventsACR122UManager.Card == null)
        //    {
        //        Logger.WriteLog("Card Detected on Reader");
        //    }
        //}

        //private void CardStateChanged(object sender, ACRCardStateChangeEventArg e)
        //{
        //    Logger.WriteLog("Card readers state has changed. New State Enum Flags: " + e.EventState);
        //}
        #endregion
        #endregion

        #region GameEvents
        private void GameInstancerGameHasEnded(object sender, GameEndedEventArgs e)
        {
            if (!exit)
            {
                Logger.WriteLog($"GameInstancer - Game has Ended. Time Ended {e.time} Reason: {e.Reason}");
                if (MainConfig.StarterMode == GameStartMode.SingleGameStarter)
                {
                    GameMenu.StartMenu();
                    Logger.WriteLog($"GameMenu - Game Menu has Started in response.");
                }
                else if (MainConfig.StarterMode == GameStartMode.MultiSocketStarterSlave)
                {
                    SlaveClient.NotifyServerOfGamesEnd();
                    Logger.WriteLog($"GameMenu - Master Server has been notified.");
                }
            }
        }
        private void GameEngine_GameEnded(object sender, GameEndedEventArgs e)
        {
            if (!this.Dispatcher.CheckAccess())
            {
                this.Dispatcher.BeginInvoke(
                    (Action <object, GameEndedEventArgs>) this.GameEngine_GameEnded,
                    DispatcherPriority.Normal,
                    sender,
                    e);
                return;
            }

            _gameEngine.Stop();
            _gameEngine.CallPaint();

            var winningLogicName = e.WinningLogic == null ? "None" : e.WinningLogic.GetType().Name;

            this.ShowInfoMessage(
                string.Format("Winning team: {0} ({1}).", e.WinningTeam, winningLogicName),
                "Game Ended");
        }
Esempio n. 15
0
        private async void OnGameEnded(object sender, GameEndedEventArgs e)
        {
            e.Game.GameEnded -= this.OnGameEnded;

            await this.notificationService.SendSignalRMessageAsync(
                e.Game.PlayerUserIds,
                Constants.SignalR.NotificationHubName,
                HubMethodNames.GameEnded,
                new GameEndedMessage(e.Game.Id, e.WinnerUserId));

            var users = await this.userRepository.SearchUsersAsync(e.Game.PlayerUserIds);

            var pushInfos  = users.Where(u => u.PushInfo != null).Select(u => new { u.Language, u.PushInfo });
            var winnerUser = users.FirstOrDefault(u => u.Id == e.WinnerUserId);

            string url = $"{Constants.Urls.ApplicationUrl}/game/end/{e.Game.Id}";

            var messagesPerLanguage = pushInfos.GroupBy(g => g.Language);

            foreach (var lang in messagesPerLanguage)
            {
                var gameOverTitle = await this.translationService.GetTranslationAsync(lang.Key, "Game.GameOver");

                var gameOverMessage = winnerUser != null ? await translationService.GetTranslationAsync(lang.Key, "Game.WinnerMessage", winnerUser.Name) :
                                      await translationService.GetTranslationAsync(lang.Key, "Game.NoWinnerMessage");

                var languagePushInfos = lang.Select(l => l.PushInfo).ToList();
                this.notificationService.SendWebPushMessage(languagePushInfos,
                                                            new WebPushNotificationMessage(gameOverMessage, gameOverTitle, url));
            }

            var activity = Activity.Domain.Activity.CreateGameActivity(e.Game.ToEntity(users.Select(u => u.ToUserInfo())), winnerUser?.ToUserInfo());

            var savedActivity = await this.activityRepository.AddActivityAsync(activity.ToEntity());

            await activityRepository.AddToActivityAddedTopicAsync(savedActivity.Id);
        }
        private void ProcessGameEnded(object sender, GameEndedEventArgs gameEndedEventArgs)
        {
            var winnerMessage = gameEndedEventArgs.Winner == null ? "Draw" : $"{gameEndedEventArgs.Winner.Name} won";
            var lastMove      = gameEndedEventArgs.History.Last();

            App.RunOnUiThread(async() => await _cellControls[lastMove.X, lastMove.Y].LoadPictureAsync(_currentSign));

            if (gameEndedEventArgs.WinningSet != null)
            {
                App.RunOnUiThread(() =>
                {
                    foreach (var cell in gameEndedEventArgs.WinningSet)
                    {
                        _cellControls[cell.X, cell.Y].LoadWonPicture(_currentSign);
                    }
                });
            }

            App.RunOnUiThread(() =>
            {
                WinnerLabel.Text    = winnerMessage;
                FieldGrid.IsEnabled = false;
            });
        }
Esempio n. 17
0
 void session_GameEnded(object sender, GameEndedEventArgs e)
 {
     message = "Game Over";
 }
Esempio n. 18
0
        protected virtual void OnGameEndedEvent(GameEndedEventArgs e)
        {
            EventHandler handler = GameEndedEvent;

            handler?.Invoke(this, e);
        }
Esempio n. 19
0
        protected override void OnInitialized()
        {
            #region Event Handlers
            _gameEventHandler = (o, e) =>
            {
                GameEventArgs message = e as GameEventArgs;
                ShowInfo(message.EventHeader, message.EventBody, message.InfoType);
            };

            _gameEndHandler = (o, e) =>
            {
                GameEndedEventArgs winner = e as GameEndedEventArgs;
                //ShowInfo("Game", $"Game has ended. Winner is/are {winner.Winner}", InfoType.Info);
                NavigationManager.NavigateTo($"/winner/{winner.Winner}/{winner.Guid}");
                //NavigationManager.NavigateTo("/");
            };

            _gamePropertyChangedEventHandler = async(o, e) =>
            {
                async Task ShowModalAsync(string modalTitle, string modalText, string modalButton)
                {
                    ModalParameters parameters = new ModalParameters();

                    parameters.Add("ModalText", modalText);
                    parameters.Add("ModalButton", modalButton);
                    await Modal.Show <CustomModal>(modalTitle, parameters).Result;
                }

                _someoneVoting = false;

                if (_game.Status == GameState.Locked && _game.TimeFrame == 0)
                {
                    await ShowModalAsync("Game", "Game is about to start. Are you ready?", "Ready");

                    _player.State = PlayerState.Ready;
                }

                if (_game.Status == GameState.Locked && _game.TimeFrame > 0 && _game.TimeOfDay == TimeOfDay.Night)
                {
                    switch (_player.Role)
                    {
                    case PlayerRole.Citizen:
                        await ShowModalAsync("Citizen", "It night time and you are Citizen. Hold tight!", "Dismiss");

                        _player.State = PlayerState.Ready;
                        break;

                    case PlayerRole.Mafia:
                        await ShowModalAsync("Mafia", "It night time and you are Mafia. Select player to kill from the list", "Continue");

                        break;

                    case PlayerRole.Police:
                        await ShowModalAsync("Police", "It night time and you are Police. Guess who is Mafia from the list", "Continue");

                        break;

                    default:
                        ShowModalAsync("Chill", "Just chill. They kicked you out", "Dismiss");
                        _player.State = PlayerState.Ready;
                        break;
                    }
                }

                await InvokeAsync(() => StateHasChanged());
            };

            _playerPropertyChangedEventHandler = async(o, e) =>
            {
                bool isModalOpen = false;

                async Task ShowModalAsync(string modalTitle, string modalText, string modalButton)
                {
                    ModalParameters parameters = new ModalParameters();

                    parameters.Add("ModalText", modalText);
                    parameters.Add("ModalButton", modalButton);
                    await Modal.Show <CustomModal>(modalTitle, parameters).Result;
                }

                if (_game.IsGameVoting == true && isModalOpen == false && e.PropertyName == "AllowedToVote")
                {
                    if (_player.AllowedToVote == true && _player.HasVoted == false)
                    {
                        isModalOpen    = true;
                        _someoneVoting = false;
                        await ShowModalAsync("Vote", "It's your turn to vote. Select player to kick out from the list", "Continue");

                        isModalOpen = false;
                    }
                    else
                    {
                        _someoneVoting = true;
                    }
                }

                await InvokeAsync(() => StateHasChanged());
            };
            #endregion

            if (GamePool.Games.TryGetValue(Guid, out _game) &&
                _game.Players.TryGetValue(GetCurrentUserGuid(), out _player))
            {
                _players = _game.Players.Values;

                _game.GamePropertyChangedEvent   += _gamePropertyChangedEventHandler;
                _game.PlayerPropertyChangedEvent += _playerPropertyChangedEventHandler;
                _game.GameEvent      += _gameEventHandler;
                _game.GameEndedEvent += _gameEndHandler;
                //Log.Information("Player {player} subscribed to events at {time}.", GetCurrentUserGuid(), DateTime.Now);
            }
            else
            {
                _players = new List <Player>();
            }
        }
Esempio n. 20
0
 private void OnLiveSessionEnded(object sender, GameEndedEventArgs e)
 {
     OnEnded();
 }
Esempio n. 21
0
 void session_GameEnded(object sender, GameEndedEventArgs e)
 {
     sayMessage("Game Over");
 }
Esempio n. 22
0
 void SessionGameEndedHandler(object sender, GameEndedEventArgs e)
 {
     //throw new NotImplementedException();
 }
Esempio n. 23
0
 /// <summary>
 /// Handle the end of the game session.
 /// </summary>
 void networkSession_GameEnded(object sender, GameEndedEventArgs e)
 {
     if ((world != null) && !world.GameWon && !world.GameExited)
     {
         world.GameExited = true;
     }
     if (!IsExiting && ((world == null) || world.GameExited))
     {
         world = null;
         ExitScreen();
         networkSession = null;
     }
 }
Esempio n. 24
0
 //event subscribed from data placeholder
 private void DataPlaceholder_GameEnded(object sender, GameEndedEventArgs e)
 {
     SynchCont.Post(_ => OpenEngGameResultsWindow(e.GameEndedData), null);
 }
 /// <summary>
 /// Handles a game ending event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void GameEndedEventHandler(object sender, GameEndedEventArgs e)
 {
 }
Esempio n. 26
0
        private void GameEnded(object sender, GameEndedEventArgs e)
        {
            Console.WriteLine("done game!");

            if(Storage.InTutorial)
            {
                foreach (var gamer in Storage.NetworkSession.AllGamers)
                {
                    Game.Components.Remove(gamer.Tag as Player);

                    if (gamer.IsLocal)
                    {
                        gamer.Tag = new LocalPlayer(Game, gamer);
                    }
                    else
                    {
                        gamer.Tag = new RemotePlayer(Game, gamer);
                    }
                }

                Storage.SandParticles.Particles.Clear();
                Storage.AnimationController.Clear();

                Storage.Game.Effect.CurrentTechnique = Storage.Game.Effect.Techniques["None"];

                Storage.Scores[Team.Red] = Storage.Scores[Team.Blue] = 0;
                Storage.InTutorial = false;
                Storage.TutorialLevel = 0;

                Storage.Game.TransitionState(States.Lobby);
            }
            else
            {
                Storage.Game.TransitionState(States.Win);
            }
        }
Esempio n. 27
0
 void session_GameEnded(object sender, GameEndedEventArgs e)
 {
 }
Esempio n. 28
0
 private void GameEnded(object sender, GameEndedEventArgs args)
 {
 }
Esempio n. 29
0
 void SessionGameEndedHandler(object sender, GameEndedEventArgs e)
 {
     //throw new NotImplementedException();
 }
Esempio n. 30
0
 private void OnLiveSessionEnded(object sender, GameEndedEventArgs e)
 {
     OnEnded();
 }
Esempio n. 31
0
        private void m_AmericanCheckers_GameEnded(object sender, EventArgs e)
        {
            GameEndedEventArgs ge = e as GameEndedEventArgs;

            m_FormGame.CreateYesNoMessageBox(ge.Message, "Damka");
        }
Esempio n. 32
0
 //ゲームの終了処理をします。
 private void ExitGame(object sender, GameEndedEventArgs e)
 {
     CurrentPlayerLabel.Content = String.Empty;
     SetGameResultLabel(e.Winner);
 }
 void GameEndedEventHandler(object sender, GameEndedEventArgs e)
 {
     log.Add("Game ended");
     command = "[Press R to signal you're ready]";
 }
Esempio n. 34
0
 public static void Session_GameEnded(object sender, GameEndedEventArgs args)
 {
     Console.WriteLine("The game has ended.");
 }
Esempio n. 35
0
        private void TileManager_OnGameEnded(object sender, EventArgs e)
        {
            GameEndedEventArgs gameEndedEventArgs = (e as GameEndedEventArgs);

            switch (gameEndedEventArgs.Result)
            {
            case -1:
            {
                if (singleplayer)
                {
                    afterGameTexts[0].Text = "You win!";
                }
                else
                {
                    afterGameTexts[0].Text = "Black wins!";
                }
                break;
            }

            case 0:
            {
                afterGameTexts[0].Text = "Draw!";
                break;
            }

            case 1:
            {
                if (singleplayer)
                {
                    afterGameTexts[0].Text = "You lose!";
                }
                else
                {
                    afterGameTexts[0].Text = "White wins!";
                }
                break;
            }
            }
            if (scoreManager.Scores.Count != 0)
            {
                if (gameEndedEventArgs.Scores[0].Value > scoreManager.Scores.LastOrDefault().Value&& gameEndedEventArgs.Scores[1].Value > scoreManager.Scores.LastOrDefault().Value)
                {
                    afterGameTexts[1].Text           += $"New high scores: {gameEndedEventArgs.Scores[0].Value}, {gameEndedEventArgs.Scores[1].Value}";
                    gameEndedEventArgs.Scores[0].Name = DateTime.Now.ToString();
                    gameEndedEventArgs.Scores[1].Name = DateTime.Now.ToString();
                    scoreManager.Add(gameEndedEventArgs.Scores[0]);
                    scoreManager.Add(gameEndedEventArgs.Scores[1]);
                }
                else if (gameEndedEventArgs.Scores[0].Value > scoreManager.Scores.LastOrDefault().Value&& gameEndedEventArgs.Scores[0].Value != 0)
                {
                    afterGameTexts[1].Text           += $"New high score: {gameEndedEventArgs.Scores[0].Value}";
                    gameEndedEventArgs.Scores[0].Name = DateTime.Now.ToString();
                    scoreManager.Add(gameEndedEventArgs.Scores[0]);
                }
                else if (gameEndedEventArgs.Scores[1].Value > scoreManager.Scores.LastOrDefault().Value&& gameEndedEventArgs.Scores[1].Value != 0)
                {
                    afterGameTexts[1].Text           += $"New high score: {gameEndedEventArgs.Scores[1].Value}";
                    gameEndedEventArgs.Scores[1].Name = DateTime.Now.ToString();
                    scoreManager.Add(gameEndedEventArgs.Scores[1]);
                }
            }
            else
            {
                if (gameEndedEventArgs.Scores[0].Value != 0 && gameEndedEventArgs.Scores[1].Value != 0)
                {
                    afterGameTexts[1].Text           += $"New high scores: {gameEndedEventArgs.Scores[0].Value}, {gameEndedEventArgs.Scores[1].Value}";
                    gameEndedEventArgs.Scores[0].Name = DateTime.Now.ToString();
                    gameEndedEventArgs.Scores[1].Name = DateTime.Now.ToString();
                    scoreManager.Add(gameEndedEventArgs.Scores[0]);
                    scoreManager.Add(gameEndedEventArgs.Scores[1]);
                }
                else if (gameEndedEventArgs.Scores[0].Value != 0)
                {
                    afterGameTexts[1].Text           += $"New high score: {gameEndedEventArgs.Scores[0].Value}";
                    gameEndedEventArgs.Scores[0].Name = DateTime.Now.ToString();
                    scoreManager.Add(gameEndedEventArgs.Scores[0]);
                }
                else if (gameEndedEventArgs.Scores[1].Value != 0)
                {
                    afterGameTexts[1].Text           += $"New high score: {gameEndedEventArgs.Scores[1].Value}";
                    gameEndedEventArgs.Scores[1].Name = DateTime.Now.ToString();
                    scoreManager.Add(gameEndedEventArgs.Scores[1]);
                }
            }
            ScoreManager.Save(scoreManager);
            gameEnded = true;
        }
Esempio n. 36
0
 void session_GameEnded(object sender, GameEndedEventArgs p)
 {
     Console.Write("Game Ended");
 }
Esempio n. 37
0
 /// <summary>
 /// Handles a game ending event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void GameEndedEventHandler(object sender, GameEndedEventArgs e)
 {
 }
Esempio n. 38
0
 void session_GameEnded(object sender, GameEndedEventArgs e)
 {
     message = "Game Over";
 }
Esempio n. 39
0
 private void OnGameEnded(GameEndedEventArgs e) => GameEnded?.Invoke(this, e);
Esempio n. 40
0
        /// <summary>
        /// Called when a Game has ended
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void session_GameEnded(object sender, GameEndedEventArgs e)
        {
            string winner;
            Console.WriteLine("Game has ended...");
            if (ActiveGameObjects[playerIndex].Health > 0)
            {
                activePlayers[playerIndex].Money += 250;
                activePlayers[opponentIndex].Money += 100;
                winner = activePlayers[playerIndex].PlayerName;
            }
            else
            {
                activePlayers[playerIndex].Money += 100;
                activePlayers[opponentIndex].Money += 250;
                winner = activePlayers[opponentIndex].PlayerName;
            }
            if (session.IsHost)
            {
                activePlayers[playerIndex].UpdateInfoOnServer(SERVER_IP, SERVER_PORT_NUM);
                activePlayers[opponentIndex].UpdateInfoOnServer(SERVER_IP, SERVER_PORT_NUM);
            }

            backgroundMusic.Stop(AudioStopOptions.Immediate);
            scene.UIRenderer.Remove2DComponent(player1_hud);
            scene.UIRenderer.Remove2DComponent(player2_hud);
            HideMainMenu();
            scene.RootNode.RemoveChildren();
            session.Dispose();
            session = null;

            backgroundMusic = soundBank.GetCue("Boom Music");
            gameState = GameState.Main_Menu;
            gameMode = GameMode.Menu;
            DisplayMainMenu();

            /*added for winner label*/
            gwinner = new FadingMessage(winner + " is the Winner and recieves 250 in coins, ENJOY! ", 1000);
            gwinner.Bounds = new Rectangle(0, 0, 130, 30);
            gwinner.Name = "gwinner";
            gwinner.TextFont = hudFont;
            gwinner.TextColor = Color.ForestGreen;
            winners.Enabled = true;
            winners.Visible = true;
            gwinner.Enabled = true;
            gwinner.Visible = true;
            winners.AddChild(gwinner);
            gwinner.Transparency = 1.0f;
        }