Exemplo n.º 1
0
        public void RestartGame(GameDisplayType gameDisplayType)
        {
            bool executeRestart = true;
            removeShadeEffect();

            if (gameMode == GameMode.TwoPlayers && gameDisplayType == GameDisplayType.FirstPlayer && networkModule != null)
            {
                if (game.GameStatus == GameStatus.Finished)
                {
                    MessageBoxShow("You've already finished the game with opponent.");
                    executeRestart = false;
                }
                else
                {
                    networkModule.SendRestartMessage();
                }
            }

            if (executeRestart)
            {
                if (gameDisplayType == GameDisplayType.FirstPlayer)
                {
                    TerminateFirstPlayer(); // do not terminate opponent gamedesk
                    loadCurrentRound(game);
                }
                else if (gameDisplayType == GameDisplayType.SecondPlayer)
                {
                    TerminateSecondPlayer(true); // do not terminate opponent gamedesk
                    loadCurrentRound(gameOpponent);
                }
            }
        }
Exemplo n.º 2
0
        //
        // Constructors
        //
        public GameRepository(GameMode gameMode, GameDisplayType gameDisplayType, INetworkService networkService)
        {
            if (appPath == null) throw new InvalidStateException("Application path is not set in GameRepository module.");

            this.gameMode = gameMode;
            this.gameDisplayType = gameDisplayType;
            this.networkService = networkService;

            this.Initialize();
        }
Exemplo n.º 3
0
Arquivo: Game.cs Projeto: MartyIX/SoTh
        public Game(IQuest quest, GameMode gameMode, GameDisplayType gameDisplayType, INetworkService networkService, IUserInquirer userInquirer)
        {
            this.quest = quest;
            this.gameDisplayType = gameDisplayType;
            this.gameMode = gameMode;
            this.networkService = networkService;
            this.userInquirer = userInquirer;

            if (this.quest == null) throw new NotValidQuestException("Quest is not valid");
        }
Exemplo n.º 4
0
        static ManualResetEvent SpawnThread(GameDisplayType gameDisplayType)
        {
            ThreadData threadData = new ThreadData()
            {
                ManualResetEvent = new ManualResetEvent(false), GameDisplayType = gameDisplayType
            };
            Thread thread = new Thread(new ParameterizedThreadStart(SpawnGame));

            thread.IsBackground = false;
            thread.Start(threadData);
            return(threadData.ManualResetEvent);
        }
Exemplo n.º 5
0
 public SecondaryGame(GameDisplayType gameDisplayType)
 {
     graphics = new CustomGraphicsDeviceManager(this, gameDisplayType);
 }
 public CustomGraphicsDeviceManager(Game game, GameDisplayType gameDisplayType)
     : base(game)
 {
     GameDisplayType = gameDisplayType;
     this.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(CustomGraphicsDeviceManager_PreparingDeviceSettings);
 }
Exemplo n.º 7
0
 public void RestartGame(GameDisplayType gameDisplayType)
 {
     gameDeskControl.RestartGame(gameDisplayType);
 }
Exemplo n.º 8
0
 public void GameChangedHandler(GameDisplayType gameDisplayType, GameChange gameChange)
 {
     gameDeskControl.GameChangedHandler(gameDisplayType, gameChange);
 }
Exemplo n.º 9
0
        /// <summary>
        /// May be called from first or second player!!
        /// </summary>
        /// <param name="gameChange"></param>
        public void GameChangedHandler(GameDisplayType gameDisplayType, GameChange gameChange)
        {
            if (gameMode == GameMode.SinglePlayer)
            {
                if (game.GameStatus == Lib.GameStatus.Running)
                {
                    if (gameChange == GameChange.Won)
                    {
                        if (quest.RoundsNo > 1)
                        {
                            if (!quest.IsLast())
                            {
                                ShowQuestion(inquirySinglePlayerPlayNextRoundOfLeague, new string[] { "Yes", "No" });
                            }
                            else
                            {
                                MessageBoxShow("Congratulations! You've won the round and completed the league!");
                            }
                        }
                        else
                        {
                            MessageBoxShow("Congratulations! You've won the round!");
                        }

                        FirstPlayerIsFinishing();

                        // Sending results
                        try
                        {
                            AppendMessage(storeSinglePlayerRoundResult(this.getTime()));
                        }
                        catch
                        {
                            AppendMessage("Unexpected error: Cannot store results to the server.");
                        }

                    }
                    else if (gameChange == GameChange.StopCountingTime)
                    {
                        this.PauseTime();
                    }
                    else if (gameChange == GameChange.Lost)
                    {
                        FirstPlayerIsFinishing();
                        this.ShowQuestion(inquirySinglePlayerRestart, new string[] { "Yes", "No" }); // answer is processed in UserInquirer.cs
                    }
                }
            }
            else if (gameMode == GameMode.TwoPlayers)
            {
                if (gameDisplayType == GameDisplayType.FirstPlayer)
                {
                    if (game.GameStatus == Lib.GameStatus.Running)
                    {
                        if (gameChange == GameChange.Won)
                        {
                            MessageBoxShow("You have won the duel!");
                        }
                        else if (gameChange == GameChange.Lost)
                        {
                            MessageBoxShow("Your opponent have won the duel!");
                        }

                        FirstPlayerIsFinishing();
                    }
                }
                else
                {
                    if (gameOpponent.GameStatus == GameStatus.Running)
                    {
                        if (gameChange == GameChange.Restart)
                        {
                            this.RestartGame(GameDisplayType.SecondPlayer); // restart opponent game desk
                        }
                    }
                }
            }
            else
            {
                throw new NotImplementedException("not implemented");
            }
        }