Exemplo n.º 1
0
 public GameManager(Player.ePlayerType i_secondPlayerType, int i_BoardSize)
 {
     m_YellowPlayer = new Player(eDiskShape.Yellow, Player.ePlayerType.Human);
     m_RedPlayer    = new Player(eDiskShape.Red, i_secondPlayerType);
     m_BoardGame    = new Board(i_BoardSize);
     m_curentTurn   = m_YellowPlayer;
 }
Exemplo n.º 2
0
        private void InitFormAfterClick(Player.ePlayerType i_SecondPlayerType)
        {
            m_GameConfig.SecondPlayerType = i_SecondPlayerType;
            Form gameForm = new GameForm(m_GameConfig);

            gameForm.FormClosed += GameForm_FormClosed;
            Hide();
            gameForm.Show();
        }
        private static GameLogic.Player.ePlayerType[] getPlayerTypesFromSettingsForm(FormSettings i_FormSettings)
        {
            GameLogic.Player.ePlayerType[] playerTypes = new Player.ePlayerType[2];

            // Working under the assumption that the first player stored in the array is a human player -  due to design
            playerTypes[0] = GameLogic.Player.ePlayerType.Human;
            playerTypes[1] = i_FormSettings.IsSecondPlayerComputer() ? GameLogic.Player.ePlayerType.Computer : GameLogic.Player.ePlayerType.Human;

            return(playerTypes);
        }
 public void CreatePlayer(string i_Name, Player.ePlayerType i_PlayerType, bool i_IsPlayersTurn)
 {
     if (m_Player1 == null)
     {
         m_Player1       = new Player(i_Name, i_PlayerType, i_IsPlayersTurn);
         m_CurrentPlayer = m_Player1;
     }
     else
     {
         m_Player2 = new Player(i_Name, i_PlayerType, i_IsPlayersTurn);
     }
 }
Exemplo n.º 5
0
 public BoardForm(int i_BoardSize, Player.ePlayerType i_Player2Type)
 {
     r_GameLogic   = new GameLogic(new GameState(i_BoardSize, i_BoardSize, "Black", "White", Player.ePlayerType.Human, i_Player2Type));
     r_BoardSize   = i_BoardSize;
     r_BoardMatrix = new GraphicBoardCell[r_BoardSize, r_BoardSize];
     buildBoardCells();
     this.Width           = ((i_BoardSize + 1) * k_BoardCellWidth) - ((k_BoardCellWidth / 2) + k_ScreenWidthAdjustment);
     this.Height          = ((i_BoardSize + 1) * k_BoardCellHeight) - k_ScreenHeightAdjustment;
     this.Text            = getCurrentGameTitle();
     this.StartPosition   = FormStartPosition.CenterScreen;
     this.MaximizeBox     = false;
     this.FormBorderStyle = FormBorderStyle.FixedDialog;
     r_GameLogic.ChangeToNextPlayerWithLegalMoves();
     showPossibleMoves();
 }
Exemplo n.º 6
0
        private void createLogicDamka()
        {
            byte boardSize             = gameSetting.BoardSizeChosen;
            byte numberOfToolForPlayer = (byte)(((boardSize - 2) / 2) * (boardSize / 2));

            Player.ePlayerType player2Type = getPlayer2Type();
            Player[]           players     = new Player[2];

            players[0]   = new Player(gameSetting.Player1Name, Player.eDirection.DOWN_TO_UP, Player.ePlayerType.HUMAN, numberOfToolForPlayer, 'X');
            players[1]   = new Player(gameSetting.Player2Name, Player.eDirection.UP_TO_DOWN, player2Type, numberOfToolForPlayer, 'O');
            m_DamkaLogic = new Checkers(boardSize, players, numberOfToolForPlayer);
            m_DamkaLogic.StatusChanged += new EventHandler(GameStatus_Changed);
            m_DamkaLogic.ResetRound();
            addLogicDamkaToolsListenerOfBecameKing();
            players[0].AfterPlay             += new EventHandler(player_Played);
            players[1].AfterPlay             += new EventHandler(player_Played);
            m_DamkaLogic.DeleteToolFromBoard += new EventHandler(tool_RemovedFromBoard);
            m_DamkaLogic.UpdatePlayerToolsMoves(m_GameManager.PlayerTurn);
        }
Exemplo n.º 7
0
        internal static void Start()
        {
            {
                // Getting players' details from the user
                string[]             names        = new string[2];
                Player.ePlayerType[] playersTypes = new Player.ePlayerType[2];
                GetPlayersDetailsFromUser(names, playersTypes);

                // Getting board measurements from user
                int[] boardMeasurements = new int[2];
                GetBoardMeasurementsFromUser(boardMeasurements);

                // generating memory cards based on the size of the board
                List <int> memoryCards = new List <int>(boardMeasurements[0] * boardMeasurements[1]);
                GenerateMemoryCards(memoryCards, boardMeasurements[0] * boardMeasurements[1]);

                Game memoryGame = new Game(boardMeasurements, memoryCards, names, playersTypes);

                HandleMoves(memoryGame);
            }
        }
Exemplo n.º 8
0
 public GameState(int i_RowsInBoard, int i_ColumnsInBoard, string i_Player1Name, string i_Player2Name, Player.ePlayerType i_Player1Type, Player.ePlayerType i_Player2Type)
 {
     m_GameBoard            = new Board(i_RowsInBoard, i_ColumnsInBoard);
     m_PlayersArray         = new Player[k_NumOfPlayers];
     m_PlayersArray[0]      = new Player(i_Player1Name, i_Player1Type, Player.ePlayerNumber.Player1, Player.ePlayerColor.Black);
     m_PlayersArray[1]      = new Player(i_Player2Name, i_Player2Type, Player.ePlayerNumber.Player2, Player.ePlayerColor.White);
     m_IsGameOver           = false;
     m_CurrentPlayerIndex   = 0;
     m_NumberOfSkippedTurns = 0;
 }
Exemplo n.º 9
0
 private void buttonPlayAgainstFriend_Click(object sender, EventArgs e)
 {
     m_Player2Type = Player.ePlayerType.Human;
     this.Close();
 }
Exemplo n.º 10
0
 private void buttonPlayAgainstComputer_Click(object sender, EventArgs e)
 {
     m_Player2Type = Player.ePlayerType.Computer;
     this.Close();
 }
Exemplo n.º 11
0
 public Player(Player.ePlayerType i_PlayerType)
 {
     m_Type = i_PlayerType;
 }
Exemplo n.º 12
0
 public GameConfig(int i_BoardSize, Player.ePlayerType i_SecondPlayerType)
 {
     m_BoardSize        = i_BoardSize;
     m_SecondPlayerType = i_SecondPlayerType;
 }
Exemplo n.º 13
0
 public void AddPlayer(string i_Name, Player.ePlayerType i_PlayerType, bool i_IsPlayersTurn)
 {
     r_AllPlayers.CreatePlayer(i_Name, i_PlayerType, i_IsPlayersTurn);
 }