示例#1
0
文件: Round.cs 项目: MartyIX/SoTh
        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);
                }
            }
        }
示例#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();
        }
示例#3
0
文件: Game.cs 项目: 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");
        }
示例#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);
        }
示例#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);
 }
示例#7
0
 public void RestartGame(GameDisplayType gameDisplayType)
 {
     gameDeskControl.RestartGame(gameDisplayType);
 }
示例#8
0
 public void GameChangedHandler(GameDisplayType gameDisplayType, GameChange gameChange)
 {
     gameDeskControl.GameChangedHandler(gameDisplayType, gameChange);
 }
示例#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");
            }
        }