Exemplo n.º 1
0
        private void getTopAndLeftInitButtonValue(out int o_Top, out int o_Left, GameBoard.eGameboardSizes i_GameBoardSize)
        {
            switch (i_GameBoardSize)
            {
            case GameBoard.eGameboardSizes.Small:
                o_Left = 35;
                o_Top  = 40;
                break;

            case GameBoard.eGameboardSizes.Medium:
                o_Left = 45;
                o_Top  = 50;
                break;

            case GameBoard.eGameboardSizes.Large:
                o_Left = 60;
                o_Top  = 60;
                break;

            default:
                o_Left = 60;
                o_Top  = 60;
                break;
            }
        }
Exemplo n.º 2
0
        private void initBoardSize(GameBoard.eGameboardSizes i_GameBoardSize)
        {
            int sizeInPixels;

            switch (i_GameBoardSize)
            {
            case GameBoard.eGameboardSizes.Small:
                sizeInPixels = k_SmallGameBoardFormSize;
                break;

            case GameBoard.eGameboardSizes.Medium:
                sizeInPixels = k_MediumGameBoardFormSize;
                break;

            case GameBoard.eGameboardSizes.Large:
                sizeInPixels = k_LargeGameBoardFormSize;
                break;

            default:
                sizeInPixels = k_LargeGameBoardFormSize;
                break;
            }

            this.Size = new System.Drawing.Size(sizeInPixels, sizeInPixels);
        }
Exemplo n.º 3
0
        private void initGameBoardButtons(GameBoard.eGameboardSizes i_GameBoardSize)
        {
            int     currentLocationTop, currentLocationLeft, leftLocationSaver;
            Vector2 location;

            GameBoardButtons = new ButtonWithLocation[(int)i_GameBoardSize, (int)i_GameBoardSize];
            getTopAndLeftInitButtonValue(out currentLocationTop, out currentLocationLeft, i_GameBoardSize);
            leftLocationSaver = currentLocationLeft;
            for (int i = 0; i < (int)i_GameBoardSize; i++)
            {
                for (int j = 0; j < (int)i_GameBoardSize; j++)
                {
                    location = new Vector2(j, i);
                    GameBoardButtons[i, j] = new ButtonWithLocation(i, j);
                    this.Controls.Add(GameBoardButtons[i, j]);
                    GameBoardButtons[i, j].AutoSize = true;
                    GameBoardButtons[i, j].Size     = new Size(35, 35);
                    GameBoardButtons[i, j].Location = new Point(currentLocationLeft, currentLocationTop);
                    currentLocationLeft            += 35;
                    if (((i % 2 == 0) && (j % 2 == 0)) || ((i % 2 == 1) && (j % 2 == 1)))
                    {
                        GameBoardButtons[i, j].Enabled   = false;
                        GameBoardButtons[i, j].BackColor = Color.Gray;
                    }
                    else
                    {
                        GameBoardButtons[i, j].BackColor = Color.BurlyWood;
                        GameBoardButtons[i, j].ForeColor = Color.BurlyWood;
                    }

                    if (i < ((int)i_GameBoardSize / 2) - 1 && GameBoardButtons[i, j].Enabled == true)
                    {
                        GameBoardButtons[i, j].BackgroundImage       = Image.FromFile(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\white_man.png");
                        GameBoardButtons[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                        GameBoardButtons[i, j].Text      = "O";
                        GameBoardButtons[i, j].TextAlign = ContentAlignment.MiddleCenter;
                        GameBoardButtons[i, j].Click    += new EventHandler(GameBoardButtons_FirstClick);
                    }
                    else if (i > ((int)i_GameBoardSize / 2) && GameBoardButtons[i, j].Enabled == true)
                    {
                        GameBoardButtons[i, j].BackgroundImage       = Image.FromFile(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\black_man.png");
                        GameBoardButtons[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                        GameBoardButtons[i, j].Text      = "X";
                        GameBoardButtons[i, j].TextAlign = ContentAlignment.MiddleCenter;
                        GameBoardButtons[i, j].Click    += new EventHandler(GameBoardButtons_FirstClick);
                    }
                    else
                    {
                        GameBoardButtons[i, j].Click += new EventHandler(GameBoardButtons_ClickOnEmptyCell);
                    }
                }

                currentLocationLeft = leftLocationSaver;
                currentLocationTop += 35;
            }
        }
Exemplo n.º 4
0
 public FormGame(string io_PlayerOneName, string io_PlayerTwoName, GameBoard.eGameboardSizes io_GameBoardSize, GameBoard io_GameBoard, bool i_Is2PlayersMode)
 {
     m_Is2PlayersMode   = i_Is2PlayersMode;
     PlayerOneName.Text = string.Format("{0} :", io_PlayerOneName);
     PlayerTwoName.Text = string.Format("{0} :", io_PlayerTwoName);
     r_GameBoardSize    = io_GameBoardSize;
     this.Text          = string.Format("{0}X{0} Checkers", (int)io_GameBoardSize);
     this.StartPosition = FormStartPosition.CenterScreen;
     initBoardSize(io_GameBoardSize);
     m_GameBoard = io_GameBoard;
     m_GameBoard.CleanBoard();
     m_GameBoard.Initial();
     this.FormBorderStyle = FormBorderStyle.FixedSingle;
     m_GameBoard.ReportEatenEventHandler      += reportEaten;
     m_GameBoard.ReportBecameKingEventHandler += reportBecomeKing;
     m_GameBoard.ReportMovedEventHandler      += reportMoved;
     GameLogic.ReportScoreChengeEventHandler  += scoreChanged;
 }
Exemplo n.º 5
0
 private void m_RadioButtonTen_Click(object sender, EventArgs e)
 {
     RadioButtonSix.Checked = !true;
     m_BoardSize            = GameBoard.eGameboardSizes.Large;
 }
Exemplo n.º 6
0
 private void m_RadioButtonEight_Click(object sender, EventArgs e)
 {
     RadioButtonSix.Checked = !true;
     m_BoardSize            = GameBoard.eGameboardSizes.Medium;
 }
Exemplo n.º 7
0
 private void m_RadioButtonSix_Click(object sender, EventArgs e)
 {
     m_BoardSize = GameBoard.eGameboardSizes.Small;
 }