private void createNewGameWithSameSetting()
        {
            string firstUserName  = m_GameLogic.PlayerOne.Name;
            string secondUserName = m_GameLogic.PlayerTwo.Name;

            Game.eGameType gameType = m_GameLogic.Type;
            int            row      = m_GameLogic.Board.Row;
            int            col      = m_GameLogic.Board.Col;

            createGameSetting(firstUserName, secondUserName, gameType, row, col);
        }
        public GameUI()
        {
            m_WelcomeForm = new FormLogin();
            m_WelcomeForm.ShowDialog();

            string firstUserName  = m_WelcomeForm.FirstPlayerName;
            string secondUserName = m_WelcomeForm.SecondPlayerName;
            int    row            = m_WelcomeForm.RowSize;
            int    col            = m_WelcomeForm.ColSize;
            bool   isUserTwoHuman = m_WelcomeForm.IsHumanGame;

            Game.eGameType gameType = isUserTwoHuman ? Game.eGameType.AgainstAnotherUser : Game.eGameType.AgainstTheComputer;
            createGameSetting(firstUserName, secondUserName, gameType, row, col);
        }
示例#3
0
        public Game(string i_FirstUserName, string i_SecondUserName, Game.eGameType i_GameType, int i_Lenght, int i_Width)
        {
            bool isSecondUserHuman = i_GameType == eGameType.AgainstTheComputer ? false : true;

            r_GameType           = i_GameType;
            m_GameTurn           = eGameTurn.FirstUser;
            m_Board              = new Board(i_Lenght, i_Width);
            m_UserPlayer1        = new User(i_FirstUserName, true, 0);
            m_UserPlayer2        = new User(i_SecondUserName, isSecondUserHuman, m_Board.MaxPairCards / 2);
            m_Board.AfterExpose += new ExposeCardEventHandler(updateIndexCardByInteval);
            if (m_UserPlayer2.IsHuman == false)
            {
                m_Board.AfterExpose += new ExposeCardEventHandler(updateComputerAI);
            }
        }
 private void createGameSetting(string i_FirstUserName, string i_SecondUserName, Game.eGameType i_GameType, int i_Row, int i_Col)
 {
     m_GameLogic                    = new Game(i_FirstUserName, i_SecondUserName, i_GameType, i_Row, i_Col);
     m_GameForm                     = new FormGame(i_Row, i_Col, i_FirstUserName, i_SecondUserName);
     m_GameForm.Clicked             = new ButtonEventHandler(runTurnes);
     m_GameForm.AfterGameOver       = new GameOverEventHandler(gameOverShowWinnerAndMessageBox);
     m_GameLogic.Board.AfterHide   += new HideCardEventHandler(m_GameForm.resetButton);
     m_GameLogic.Board.AfterExpose += new ExposeCardEventHandler(m_GameForm.exposedButton);
 }