예제 #1
0
        //게임 필드 그리기 갱신
        private void mineFieldRenderBox_Paint(object sender, PaintEventArgs e)
        {
            if (gameField == null || gameField.GetGameState() == ConstantsPack.gameState.gameState_Init)
            {
                return;
            }

            int getWidth = gameField.GetFieldWidth(), getHeight = gameField.GetFieldHeight();
            int x = 0, y = 0;

            for (y = 0; y < getHeight; ++y)
            {
                for (x = 0; x < getWidth; ++x)
                {
                    string    imageKey = "";
                    Rectangle drawArea = new Rectangle(0, 0, 0, 0);
                    FieldCell curCell  = gameField.GetFieldCell(x, y);

                    if (curCell.closeValue != (sbyte)ConstantsPack.closeCellValue.cellValue_opened)
                    {
                        if (curCell.closeValue == (sbyte)ConstantsPack.closeCellValue.cellValue_closed)
                        {
                            imageKey = "cell_init";
                        }
                        else if (curCell.closeValue == (sbyte)ConstantsPack.closeCellValue.cellValue_flaged)
                        {
                            imageKey = "cell_flag";
                        }
                        else
                        {
                            imageKey = "cell_question_mark";
                        }
                    }
                    else
                    {
                        if (curCell.openValue == (sbyte)ConstantsPack.openCellValue.cellValue_mine)
                        {
                            imageKey = "mine";
                        }
                        else if (curCell.openValue >= (sbyte)ConstantsPack.openCellValue.cellValue_blank)
                        {
                            imageKey = "cell_" + curCell.openValue.ToString();
                        }
                        else if (curCell.openValue == (sbyte)ConstantsPack.openCellValue.cellValue_minePressed)
                        {
                            imageKey = "mine_lose";
                        }
                        else if (curCell.openValue == (sbyte)ConstantsPack.openCellValue.cellValue_flagFailed)
                        {
                            imageKey = "mine_wrong";
                        }
                    }

                    ImageInfo drawInfo   = imageContainer.GetImageInfo(imageKey);
                    Bitmap    drawBitmap = imageContainer.GetImageData(imageKey);

                    drawArea.X     = x * drawInfo.width; drawArea.Y = y * drawInfo.height;
                    drawArea.Width = drawInfo.width; drawArea.Height = drawInfo.height;

                    e.Graphics.DrawImageUnscaledAndClipped(drawBitmap, drawArea);
                }
            }

            if (gameField.GetGameState() == ConstantsPack.gameState.gameState_GameOver)
            {
                gameStartButton.BackgroundImage = imageContainer.GetImageData("smile_lose");
            }
            else if (gameField.GetGameState() == ConstantsPack.gameState.gameState_Clear)
            {
                gameStartButton.BackgroundImage = imageContainer.GetImageData("smile_win");
            }
        }