Exemple #1
0
 private void tryMakePlayerMove(GameWindowButton i_CurrentButton)
 {
     m_WindowButtonDestination = i_CurrentButton;
     onPieceMove();
     swapButtonColor(m_CurrentWindowButton);
     m_CurrentWindowButton     = null;
     m_WindowButtonDestination = null;
 }
Exemple #2
0
 private void swapButtonColor(GameWindowButton i_CurrentWindowButton)
 {
     if (i_CurrentWindowButton.BackColor == Color.White)
     {
         i_CurrentWindowButton.BackColor = Color.LightSkyBlue;
     }
     else if (i_CurrentWindowButton.BackColor == Color.LightSkyBlue)
     {
         i_CurrentWindowButton.BackColor = Color.White;
     }
 }
Exemple #3
0
 private void tryMakePlayerSelection(GameWindowButton i_CurrentButton)
 {
     try
     {
         OnWindowButtonSelected(i_CurrentButton);
         m_CurrentWindowButton = i_CurrentButton;
         swapButtonColor(i_CurrentButton);
     }
     catch (ArgumentException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemple #4
0
        private void gameWindowButton_ButtonClicked(object i_Sender, EventArgs i_E)
        {
            GameWindowButton currentButton = i_Sender as GameWindowButton;

            if (m_CurrentWindowButton == null)
            {
                resetComputerActions();
                tryMakePlayerSelection(currentButton);
            }
            else if (m_CurrentWindowButton == currentButton)
            {
                undoPlayerSelection();
            }
            else
            {
                tryMakePlayerMove(currentButton);
            }
        }
Exemple #5
0
        private void createButtonMatrix()
        {
            for (int row = 0; row < m_GameWindowSize; row++)
            {
                for (int col = 0; col < m_GameWindowSize; col++)
                {
                    GameWindowButton currentSquare = new GameWindowButton(new Point(col, row));
                    if ((row % 2 == 0 && col % 2 == 0) || (row % 2 == 1 && col % 2 == 1))
                    {
                        currentSquare.Enabled   = false;
                        currentSquare.BackColor = Color.Gray;
                    }

                    currentSquare.Top    = (row * Constants.k_ButtonHeight) + Constants.k_ButtonStartY;
                    currentSquare.Left   = (col * Constants.k_ButtonWidth) + Constants.k_ButtonStartX;
                    currentSquare.Click += gameWindowButton_ButtonClicked;
                    Controls.Add(currentSquare);
                }
            }
        }
Exemple #6
0
 protected virtual void OnWindowButtonSelected(GameWindowButton i_CurrentWindowButton)
 {
     WindowButtonSelect?.Invoke(i_CurrentWindowButton.ButtonLocation);
 }
Exemple #7
0
 private void undoPlayerSelection()
 {
     swapButtonColor(m_CurrentWindowButton);
     m_CurrentWindowButton = null;
 }