Beispiel #1
0
        /// <summary>
        /// Сделать ход для крестика или для нолика
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void DoStep(int x, int y)
        {
            buttonGetComputerStep.Enabled = true;
            try
            {
                m_IsPanelBlock = true;
                m_Field[x, y]  = m_WhoStep;

                m_PaintClass.DrawObject(m_WhoStep, x, y);
                PaintBitmap();
                m_PaintClass.ShowLastStep(this, 1);

                m_IsPanelBlock = false;

                ObjectType loser = new CheckFieldClass().FindLoser(m_Field, m_RowsCnt, m_ColumnsCnt, m_PaintClass);
                PaintBitmap();

                m_WhoStep = m_WhoStep == ObjectType.Cross ? ObjectType.Nil : ObjectType.Cross;

                if (loser != ObjectType.Empty)
                {
                    SetEnd(loser);
                }
                else if (m_WhoStep == ObjectType.Cross)
                {
                    pictureBoxCross.Visible = true;
                    pictureBoxNil.Visible   = false;
                    m_TimeNil += m_AddSec;
                }
                else
                {
                    pictureBoxCross.Visible = false;
                    pictureBoxNil.Visible   = true;
                    m_TimeCross            += m_AddSec;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SetEnd(ObjectType.Empty);
            }
        }