Ejemplo n.º 1
0
        private void 随机拆墙ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Random r   = new Random(DateTime.Now.Millisecond);
            int    num = r.Next(scale * scale);

            for (int i = 0; i < num; i++)
            {
                int  x    = r.Next(scale);
                int  y    = r.Next(scale);
                Cell cell = p.Cells[x, y];
                int  dir  = r.Next(4);
                switch (dir)
                {
                case 0:
                    cell.ChangeStatusofAWall(Direction.up, WallStatus.open);
                    break;

                case 1:
                    cell.ChangeStatusofAWall(Direction.down, WallStatus.open);
                    break;

                case 2:
                    cell.ChangeStatusofAWall(Direction.left, WallStatus.open);
                    break;

                case 3:
                    cell.ChangeStatusofAWall(Direction.right, WallStatus.open);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改当前鼠标最近的格子的状态。(哪边墙,开还是关)
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="status"></param>
        public void ChangeACellNearTo(int X, int Y, WallStatus status)
        {
            Cell cell = CheckMouse(X, Y);

            if (cell == null)
            {
                return;
            }
            Direction dir = cell.checkDir(X, Y);

            cell.ChangeStatusofAWall(dir, status);
        }