示例#1
0
 public void InitProperties()
 {
     m_CurrentSourceToolCoordinate      = new Point(-1, -1);
     m_CurrentDestinationToolCoordinate = new Point(-1, -1);
     m_LastToolEat            = null;
     m_CurrentPlayerTurn      = 0;
     m_EeatenIndexTool        = -1;
     m_ComputerTimer.Interval = 1200;
 }
示例#2
0
        private void initBoardTools(byte i_BoardSize)
        {
            int factorTop  = this.Height / i_BoardSize;
            int factorLeft = 50;

            m_ButtonToolGameTools = new ButtonTool[m_DamkaLogic.BoardSize, m_DamkaLogic.BoardSize];
            for (int i = 0; i < i_BoardSize; i++)
            {
                for (int j = 0; j < i_BoardSize; j++)
                {
                    m_ButtonToolGameTools[i, j]           = new ButtonTool(new Point(i, j));
                    m_ButtonToolGameTools[i, j].Width     = k_ButtonToolSize;
                    m_ButtonToolGameTools[i, j].Height    = k_ButtonToolSize;
                    m_ButtonToolGameTools[i, j].Top       = factorTop;
                    m_ButtonToolGameTools[i, j].Left      = factorLeft;
                    m_ButtonToolGameTools[i, j].AutoSize  = true;
                    m_ButtonToolGameTools[i, j].FlatStyle = FlatStyle.Flat;
                    m_ButtonToolGameTools[i, j].FlatAppearance.BorderSize  = 1;
                    m_ButtonToolGameTools[i, j].FlatAppearance.BorderColor = Color.Maroon;

                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0))
                    {
                        m_ButtonToolGameTools[i, j].BackColor = Color.FromArgb(249, 250, 197);
                        m_ButtonToolGameTools[i, j].Enabled   = false;
                    }
                    else
                    {
                        if (i <= (i_BoardSize / 2) - 2)
                        {
                            m_ButtonToolGameTools[i, j].BackgroundImage = Properties.Resources.BlackTool;
                        }
                        else if ((i <= i_BoardSize) && i >= ((i_BoardSize / 2) + 1))
                        {
                            m_ButtonToolGameTools[i, j].BackgroundImage = Properties.Resources.WhiteTool;
                        }

                        m_ButtonToolGameTools[i, j].BackgroundImageLayout = ImageLayout.Stretch;
                        m_ButtonToolGameTools[i, j].Click            += new EventHandler(tool_Click);
                        m_ButtonToolGameTools[i, j].OriginalBackColor = m_ButtonToolGameTools[i, j].BackColor = Color.FromArgb(123, 79, 16);
                    }

                    factorLeft += k_ButtonToolSize;
                    this.Controls.Add(m_ButtonToolGameTools[i, j]);
                }

                factorTop += k_ButtonToolSize;
                factorLeft = 50;
            }

            initBoardToolsIndex();
        }
示例#3
0
        private void getRegularMove(ButtonTool i_ButtonToolClicked)
        {
            int eatenToolIndex = -1;

            m_GameManager.DestinationToolCoordinate = i_ButtonToolClicked.Coordinate;
            if (m_DamkaLogic.IsValidPlayerMove(m_GameManager.PlayerTurn, m_GameManager.SourceToolCoordinate, m_GameManager.DestinationToolCoordinate, ref eatenToolIndex))
            {
                m_GameManager.EeatenIndexTool = eatenToolIndex;

                resetToolsAfterClick();
                m_DamkaLogic.Players[m_GameManager.PlayerTurn].Play(m_DamkaLogic.Board, m_GameManager.SourceToolCoordinate, m_GameManager.DestinationToolCoordinate);
            }
            else
            {
                m_GameManager.ErrorSound.Play();
                MessageBox.Show("Invalid Move");
            }

            resetToolsAfterClick();
            resetSourceAndDestinationAfterMove();
        }
示例#4
0
        private void continueEating(ButtonTool i_ToolClicked)
        {
            int eatenIndex = -1;

            if (i_ToolClicked != m_GameManager.LastToolEat)
            {
                if (!m_GameManager.LastToolEat.IsClicked)
                {
                    m_GameManager.ErrorSound.Play();
                    MessageBox.Show("Invalid Move");
                }
                else
                {
                    m_GameManager.DestinationToolCoordinate = i_ToolClicked.Coordinate;
                    i_ToolClicked.IsClicked = true;
                    if (m_DamkaLogic.IsValidPlayerMove(m_GameManager.PlayerTurn, m_GameManager.SourceToolCoordinate, m_GameManager.DestinationToolCoordinate, ref eatenIndex))
                    {
                        m_GameManager.EeatenIndexTool = eatenIndex;
                        m_DamkaLogic.Players[m_GameManager.PlayerTurn].Play(m_DamkaLogic.Board, m_GameManager.SourceToolCoordinate, m_GameManager.DestinationToolCoordinate);
                    }
                    else
                    {
                        m_GameManager.ErrorSound.Play();
                        MessageBox.Show("Invalid Move");
                    }

                    resetToolsAfterClick();
                    resetSourceAndDestinationAfterMove();
                }
            }
            else
            {
                i_ToolClicked.IsClicked            = true;
                m_GameManager.SourceToolCoordinate = m_GameManager.LastToolEat.Coordinate;
                m_GameManager.EeatenIndexTool      = -1;
            }
        }