示例#1
0
 private void Impossible_Click(object sender, EventArgs e)
 {
     FieldData.FullyOpened = false;
     FieldData.Closed      = true;
     FieldUtils.GenerateEmptyField(EnumData.EDifficulty.Impossible);
     MainGlControl.Show();
     RedrawField(false);
 }
示例#2
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     Icon      = Properties.Resources.MineswapperICO;
     _mainForm = this;
     MainGlControl.Hide();
     ResultRichTextBox.Hide();
     TexturesUtils.LoadTextures();
 }
示例#3
0
        private async void RedrawField(bool fromControl)
        {
            if (!MainGlControl.Created)
            {
                return;
            }

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            //GL.MatrixMode(MatrixMode.Modelview);
            //GL.LoadIdentity();
            if (!fromControl)
            {
                if (FieldData.FullyOpened)
                {
                    MainGlControl.Hide();
                    return;
                }
            }

            if (!fromControl)
            {
                await ShowGameResult(FieldUtils.CheckGameResult());
            }

            int x        = 2;
            int y        = 2;
            int cellSize = 30;

            for (int cellX = 0; cellX < FieldData.CellsCountWight; cellX++)
            {
                int tempY = y;
                for (int cellY = 0; cellY < FieldData.CellsCountHeight; cellY++)
                {
                    Color color     = Color.DarkGray;
                    int   textureId = 0;

                    if (FieldData.FieldArray[cellX, cellY].Marked)
                    {
                        textureId = (int)EnumData.ETexturesTypes.Mark;
                        color     = Color.Gold;
                    }

                    if (FieldData.FieldArray[cellX, cellY].Opened)
                    {
                        color = Color.White;
                        if (FieldData.FieldArray[cellX, cellY].Mined)
                        {
                            textureId = (int)EnumData.ETexturesTypes.Mine;
                            //color = FieldData.Completed ? Color.Green : Color.Red;
                            color = FieldData.FieldArray[cellX, cellY].Mined &&
                                    FieldData.FieldArray[cellX, cellY].Marked
                                ? Color.Green
                                : Color.Red;
                        }
                        if (FieldData.FieldArray[cellX, cellY].MinesNear > 0)
                        {
                            textureId = FieldData.FieldArray[cellX, cellY].MinesNear;
                        }
                    }

                    DrawField(new PointF(x, y), new Size(cellSize, cellSize), textureId, color);
                    y = y + cellSize + 2;
                }
                x = x + cellSize + 2;
                y = tempY;
            }
            MainGlControl.SwapBuffers();
        }