コード例 #1
0
        // TODO load from file mines.txt lol??? Im too tired and drunk so idc
        // also this program is just for reddit so who care
        public static MineTemplate[] LoadTemplates()
        {
            MineTemplate[] mines = new MineTemplate[4];

            mines[0] = new MineTemplate {
                horizontalLock = 2,
                verticalLock   = 2,
                mines          = new int[, ] {
                    { -2, 0, 0 }, { -2, -3, -4 }
                },
                minesCount = 3,
                sizeX      = 2,
                sizeY      = 3
            };

            mines[1] = new MineTemplate {
                horizontalLock = 0,
                verticalLock   = 0,
                mines          = new int[, ] {
                    { -4, -3, -2 }, { 0, 0, -2 }
                },
                minesCount = 3,
                sizeX      = 2,
                sizeY      = 3
            };

            mines[2] = new MineTemplate {
                horizontalLock = 0,
                verticalLock   = 2,
                mines          = new int[, ] {
                    { 0, -4 }, { 0, -3 }, { -2, -2 }
                },
                minesCount = 3,
                sizeX      = 3,
                sizeY      = 2
            };

            mines[3] = new MineTemplate {
                horizontalLock = 2,
                verticalLock   = 0,
                mines          = new int[, ] {
                    { -2, -2 }, { -3, 0 }, { -4, 0 }
                },
                minesCount = 3,
                sizeX      = 3,
                sizeY      = 2
            };

            return(mines);
        }
コード例 #2
0
ファイル: MineField.cs プロジェクト: grhea/Minesweepernt
        public void GenerateMines(int startX, int startY)
        {
            MineTemplate mineTemp = GetRandomMineTemplate(startX, startY);

            for (int i = 0; i < mineTemp.sizeX; i++)
            {
                for (int j = 0; j < mineTemp.sizeY; j++)
                {
                    mines[mineTemp.startX + i, mineTemp.startY + j] = mineTemp.mines[i, j];
                    if (mineTemp.mines[i, j] < -2)
                    {
                        fakeMines[mineTemp.mines[i, j] + 4, 0] = mineTemp.startX + i;
                        fakeMines[mineTemp.mines[i, j] + 4, 1] = mineTemp.startY + j;
                    }
                }
            }

            mines[startX, startY] = -1;
            playing = true;
            Random rnd       = new Random();
            int    minesTemp = minesCount - mineTemp.minesCount;

            while (minesTemp > 0)
            {
                int x = rnd.Next(0, sizeX);
                int y = rnd.Next(0, sizeY);

                if (mines[x, y] == 0)
                {
                    mines[x, y] = -2;
                    minesTemp--;
                }
            }

            Reveal(startX, startY);
        }
コード例 #3
0
ファイル: MineField.cs プロジェクト: grhea/Minesweepernt
 public MineField()
 {
     mineTemplates = MineTemplate.LoadTemplates();
 }