Esempio n. 1
0
        /// <summary>
        /// constructor of maze canvas
        /// </summary>
        /// <param name="maze">Maze maze 3d</param>
        public MazeCanvas(Maze3d maze)
        {
            InitializeComponent();
            m_maze  = maze;
            Start_x = m_maze.getStartPosition().X;
            Start_y = m_maze.getStartPosition().Y;
            //m_row = 0;
            //m_column = 0;
            m_row      = Start_x;
            m_column   = Start_y;
            x          = m_maze.MX * 2 - 1;
            y          = m_maze.MY * 2 - 1;
            z          = m_maze.MZ;
            goal_layer = z - 1;
            cur_layer  = 0;

            CreateTheMaze();
            // CreatePlayer();
            RestaerPlayer();

            //for zoom in/out
            m_ZoomX = 1;
            m_ZoomY = 1;

            //this.MouseWheel += new MouseWheelEventHandler(prevMouseWheel);
            this.PreviewMouseWheel += PrevMouseWheel;
            checkWindow             = true;

            //
            dragged      = false;
            ScrollerView = new ScrollViewer();//
        }
Esempio n. 2
0
        /// <summary>
        /// sets maze to play on
        /// </summary>
        /// <param name="maze">maze to play on</param>
        public void setMazeToPlayOn(Maze3d maze)
        {
            try
            {
                m_mazeToPlayOn = maze;
                m_x            = maze.getStartPosition().Axis[0];
                m_y            = maze.getStartPosition().Axis[1];

                m_layer = 0;
                checkMovmentUpDown();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 3
0
        /// <summary>
        /// get initial state (the state of the maze)
        /// </summary>
        /// <returns>The initial state</returns>
        public Astate getInitialState()
        {
            Position start = maze.getStartPosition();
            Astate   ans   = new MazeState(null, start);

            return(ans);
        }
Esempio n. 4
0
 /// <summary>
 /// displays the maze on the screen
 /// </summary>
 /// <param name="maze">maze to display</param>
 public void outputMaze(Maze3d maze)
 {
     try {
         m_mazeToPlayOn = maze;
         m_sol          = null;
         solutionOn     = false;
         m_x            = maze.getStartPosition().Axis[0];
         m_y            = maze.getStartPosition().Axis[1];
         cnvs_main.Children.Clear();
         MazeDisplayer mazeDisplayer = new MazeDisplayer(maze, m_x, m_y, 0, solutionOn, m_sol, 400, 400);
         cnvs_main.Children.Add(mazeDisplayer);
         // Canvas.SetLeft(mazeDisplayer, 0);
         // Canvas.SetTop(mazeDisplayer, 0);
         //Grid.SetRow(mazeDisplayer, 20);
         //Grid.SetColumn(mazeDisplayer, 20);
     }
     catch (Exception)
     {
     }
 }
Esempio n. 5
0
        private static void testMyCompressorStream()
        {
            Console.WriteLine("*******  testMyCompressorStream  *******\n");
            int[]          size3D          = { 3, 6, 7 }; // (z,y,x)
            IMazeGenerator mazeGenerator3d = new MyMaze3dGenerator();
            Maze3d         maze            = (Maze3d)mazeGenerator3d.generate(size3D);

            // save the maze to a file – compressed
            using (FileStream fileOutStream = new FileStream(@"D:\1.maze.txt", FileMode.Create))
            {
                using (Stream outStream = new MyCompressorStream(fileOutStream))
                {
                    outStream.Write(maze.toByteArray(), 0, maze.toByteArray().Length);
                    outStream.Flush();
                }
            }
            byte[] mazeBytes;
            using (FileStream fileInStream = new FileStream(@"D:\1.maze.txt", FileMode.Open))
            {
                using (Stream inStream = new MyCompressorStream(fileInStream))
                {
                    mazeBytes = new byte[maze.toByteArray().Length];
                    inStream.Read(mazeBytes, 0, mazeBytes.Length);
                }
            }
            Maze3d loadedMaze = new Maze3d(mazeBytes);

            Console.WriteLine("The original maze : ");
            maze.print();
            maze.getStartPosition().print();
            maze.getGoalPosition().print();

            Console.WriteLine("The decompress maze : ");
            loadedMaze.print();
            loadedMaze.getStartPosition().print();
            loadedMaze.getGoalPosition().print();
            Console.WriteLine(loadedMaze.Equals(maze));
        }