コード例 #1
0
        /// <summary>
        /// Save Maze - Creates a compression of the maze and
        /// saves the file on the disk with a given file path
        /// </summary>
        /// <param name="mazeName">Maze name</param>
        /// <param name="path">File Name</param>
        /// <returns>True if successful saving the maze</returns>
        public bool saveMaze(string mazeName, string filePath)
        {
            //MessageBox.Show("save: " + mazeName);
            WinMaze winMaze     = m_currentWinMaze;
            Maze3d  currentMaze = winMaze.getMaze();

            add3dMaze(mazeName, currentMaze);
            if (isSolutionExists)
            {
                m_solutionsDictionary[mazeName] = mCurrentSolution;
            }

            if (currentMaze == null)
            {
                return(false);
            }
            using (FileStream fileOutStream = new FileStream(filePath, FileMode.Create))
            {
                using (Stream outStream = new MyCompressorStream(fileOutStream))
                {
                    outStream.Write(currentMaze.toByteArray(), 0, currentMaze.toByteArray().Length);
                    outStream.Flush();
                }
            }
            return(true);
        }
コード例 #2
0
 /// <summary>
 /// Move up in the maze command
 /// </summary>
 /// <param name="maze">WinMaze current maze</param>
 public void moveUp(WinMaze maze)
 {
     m_instructions.Clear();
     if ((maze.PosZ + 1) < maze.getMaze().MyHeight)
     {
         int isBrockAbove = maze.getMaze().getMazeByFloor(maze.PosZ + 1).getCell(maze.PosX, maze.PosY).BlockOrEmpty;
         if (isBrockAbove == 0)
         {
             maze.PosZ += 1;
             m_winMazesDictionary[maze.getName()] = maze;
             m_currentWinMaze = maze;
             m_instructions.Add("display");
             m_instructions.Add("maze");
             ModelChanged();
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Move forward in the maze command
 /// </summary>
 /// <param name="maze">WinMaze current maze</param>
 public void moveForward(WinMaze maze)
 {
     m_instructions.Clear();
     int[] currentCellWalls = maze.getMaze().getMazeByFloor(maze.PosZ).getCell(maze.PosX, maze.PosY).getWallsAroundCell();
     if (maze.PosY + 1 < maze.getMaze().MyRows)
     {
         if (currentCellWalls[3] == 0)
         {
             maze.PosY += 1;
             m_winMazesDictionary[maze.getName()] = maze;
             m_currentWinMaze = maze;
             m_instructions.Add("display");
             m_instructions.Add("maze");
             ModelChanged();
         }
     }
 }
コード例 #4
0
 /// <summary>
 /// Move back in the maze command
 /// </summary>
 /// <param name="maze">WinMaze current maze</param>
 public void moveBack(WinMaze maze)
 {
     m_instructions.Clear();
     int[] currentCellWalls = maze.getMaze().getMazeByFloor(maze.PosZ).getCell(maze.PosX, maze.PosY).getWallsAroundCell();
     if (maze.PosY - 1 >= 0)
     {
         int[] currentCellWallsBack = maze.getMaze().getMazeByFloor(maze.PosZ).getCell(maze.PosX, maze.PosY - 1).getWallsAroundCell();
         if ((currentCellWalls[2] == 0) || (currentCellWallsBack[3] == 0))
         {
             maze.PosY -= 1;
             m_winMazesDictionary[maze.getName()] = maze;
             m_currentWinMaze = maze;
             m_instructions.Add("display");
             m_instructions.Add("maze");
             ModelChanged();
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Move down in the maze command
 /// </summary>
 /// <param name="maze">WinMaze current maze</param>
 public void moveDown(WinMaze maze)
 {
     m_instructions.Clear();
     if (maze.PosZ - 1 >= 0)
     {
         int isBrockBelow = maze.getMaze().getMazeByFloor(maze.PosZ - 1).getCell(maze.PosX, maze.PosY).BlockOrEmpty;
         if (isBrockBelow == 0)
         {
             maze.PosZ -= 1;
             m_winMazesDictionary[maze.getName()] = maze;
             m_currentWinMaze = maze;
             m_instructions.Add("display");
             m_instructions.Add("maze");
             ModelChanged();
         }
     }
 }