public TournamentForm()
        {
            InitializeComponent();

            //Play the preparation music
            soundPlayer.Stream = Properties.Resources.Preparation;
            soundPlayer.Play();

            //Initialize button events, etc.
            surrenderButton.MouseHover += CommonEvents.menuButton_MouseHover;
            surrenderButton.MouseLeave += CommonEvents.menuButton_MouseLeave;
            surrenderButton.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);

            //Set the player's profile
            playerPictureBox.Image = Player.profilePicture;
            playerNameLabel.Text   = Player.userName;

            //Let the player choose the piece they wish to be, and assign it, this is for the whole tournament
            PiecePrompt piecePrompt = new PiecePrompt();

            piecePrompt.ShowDialog();
            playerPiece = piecePrompt.selectedPiece;

            //Tournament Settings
            matchIndex      = 0;
            matchDifficulty = new Difficulty[NUMBER_OF_T_MATCHES];

            //Set up the difficulty of each match
            //1 advanced match, a specified percentage of normal matches, and rest are easy.
            //Tournament starts easy and gets harder.
            matchDifficulty[NUMBER_OF_T_MATCHES - 1] = Difficulty.Advanced;
            int normalMatches = (int)Math.Ceiling(NUMBER_OF_T_MATCHES * PERCENT_OF_MATCHES_NORMAL);
            int easyMatches   = NUMBER_OF_T_MATCHES - (normalMatches + 1);

            for (int i = 0; i < easyMatches; i++)
            {
                matchDifficulty[i] = Difficulty.Easy;
            }

            for (int i = easyMatches; i < normalMatches + 1; i++)
            {
                matchDifficulty[i] = Difficulty.Normal;
            }

            StartGame();
        }
Exemple #2
0
        private void StartGame()
        {
            //Play the preparation music
            soundPlayer.Stream = Properties.Resources.Preparation;
            soundPlayer.Play();

            //Prompt the player for the difficulty of the match
            DifficultyPrompt diffPrompt = new DifficultyPrompt();

            diffPrompt.ShowDialog();

            //Create a new "game"
            currentGame = new Game((Difficulty)diffPrompt.selectedDifficulty);

            //Let the player choose the piece they wish to be, and assign it
            PiecePrompt piecePrompt = new PiecePrompt();

            piecePrompt.ShowDialog();
            currentGame.PlayerPiece = piecePrompt.selectedPiece;

            //Create a new AI player, and assign it the piece opposite of the player
            currentGame.aiPlayer         = new AI();
            currentGame.aiPlayer.AIPiece = Game.GetOppositePiece(currentGame.PlayerPiece);
            currentGame.AIPiece          = currentGame.aiPlayer.AIPiece;

            //Determine who goes first
            DiceRollPrompt diceRoll = new DiceRollPrompt();

            diceRoll.ShowDialog();
            currentGame.CurrentPlayer = diceRoll.firstToGo;

            //Start the game
            currentGame.GameStarted = true;
            currentGame.GameState   = Game.State.Playing;

            //Start the game timers
            gameTimer.Start();
            countdownTimer.Start();

            //Play battle music
            soundPlayer.Stop();
            soundPlayer.Stream = Properties.Resources.BattleMusic;
            soundPlayer.PlayLooping();
        }