Exemple #1
0
        /// <summary>
        /// Run the game, Main Menu window shows in the start, or after running a game!
        /// </summary>
        /// <param name="isFirstRun">Indicator if the game is running for the first time</param>
        public void Run()
        {
            System.Media.SoundPlayer music = new System.Media.SoundPlayer(); // Creating an instance for the music!

            Displayer.WindowStyle();

            do
            { // While "Esc" is not pressed, the main menu will be showen after every game!
                Displayer.ClearWindow();

                #region Related to first run options

                if (!isFirstRun)
                {
                    Displayer.Logo(); // Tic Tac Toe Logo
                }
                else
                {
                    Displayer.LogoAnimation(); // Logo with Animation only at first run!
                }

                #endregion

                #region Menu Music
                music.SoundLocation = "1.wav";
                music.PlayLooping();
                #endregion

                Displayer.DisplayGameOptions(true); // Sends true for not showing error msg at the beginning
                UserInput.SetGameMode(this);        // Sends the game to set it's mode!

                if (GameMode == GameMode.PlayerVsPlayer)
                {
                    #region Music (Typing Players)
                    music.SoundLocation = "2.wav";
                    music.PlayLooping();
                    #endregion
                    PlayerVsPlayer(); // Go to the chosen mode!
                }
                else if (GameMode == GameMode.PlayerVsComputer)
                {
                    #region Music (Typing Players)
                    music.SoundLocation = "2.wav";
                    music.PlayLooping();
                    #endregion
                    PlayerVsComputer(); // Go to the chosen mode!
                }

                isFirstRun = false;                  // If it's first run: now we completed the first run of the game!
            } while (GameMode != GameMode.ExitMode); // If pressed Esc
            Displayer.CloseGame();
        }