private void OnGamePause(PauseGameMessage msg, DateTime timestamp)
        {
            if (!this.IsGameOwner())
            {
                return;
            }

            this._gameHost.IsPaused = msg.IsPaused;

            this.BroadcastToCurrentGame(EventBuilder.Build(msg).Serialize());
        }
Esempio n. 2
0
        void BackToMainMenuCommandExecute()
        {
            void BackAction()
            {
                PauseGameMessage.Send(MessengerInstance); // stops the ai thread
                ShowMainMenuMessage.Send(MessengerInstance);
            }

            if (PrimaryNeedsSaving)
            {
                const string message = "Would you like to save the current game before exiting?";

                ShowSavePopupMessage.Send(MessengerInstance, (message, BackAction, true));
            }
            else
            {
                BackAction();
            }
        }
Esempio n. 3
0
        private void InitMessageHandlers()
        {
            // Receive any move and update the primary game's state.
            CommitMoveMessage.Register(MessengerInstance, this, action => UpdateGame(action, PrimaryGame));


            // These message handlers stay irrespective of the ActiveMode
            UndoMessage.Register(MessengerInstance, this, () => Undo(ModeSpecificGame()));
            RedoMessage.Register(MessengerInstance, this, () => Redo(ModeSpecificGame()));
            SwitchGameViewModeMessage.Register(MessengerInstance, this, mode => ActiveMode = mode);
            PauseGameMessage.Register(MessengerInstance, this, () => _aiLoopCanRun         = false);

            // someone requested that the current state of the game be saved
            RequestSaveToGameScreenMessage.Register(
                MessengerInstance,
                this,
                () => {
                SaveGameMessage.Send(MessengerInstance, (GameId, PrimaryGame.Memento));
                PrimaryNeedsSaving = false;
            });