Ejemplo n.º 1
0
 public Level(Maze maze, Room startingRoom, Room finishingRoom, Func<Level> next)
 {
     this.maze = maze;
     this.startingRoom = startingRoom;
     this.finishingRoom = finishingRoom;
     this.next = next;
 }
Ejemplo n.º 2
0
        public IHttpActionResult CreateMaze(MazeParam partialMaze)
        {
            try
            {
                int x = 0;
                int y = 0;

                MazeLib.Maze maze = this.mazeModel.Generate
                                        (partialMaze.Name, partialMaze.Rows, partialMaze.Cols);

                partialMaze.GoalPos = maze.GoalPos.ToString();
                Converters.PositionConverter.ConvertPos(ref x, ref y, partialMaze.GoalPos);
                partialMaze.GoalPosRow = x;
                partialMaze.GoalPosCol = y;

                partialMaze.InitialPos = maze.InitialPos.ToString();
                Converters.PositionConverter.ConvertPos(ref x, ref y, partialMaze.InitialPos);
                partialMaze.InitialPosRow = x;
                partialMaze.InitialPosCol = y;
                JObject jmaze = JObject.Parse(maze.ToJSON());
                partialMaze.AsString = jmaze.GetValue("Maze").ToString();


                return(Ok(JObject.Parse(partialMaze.ToJson())));
            }
            catch (ArgumentException)
            {
                // Content bla bla BadRequest blabla
                return(NotFound());
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Maze maze1 = new Maze(5, 5, null, 0, 0);

            maze1.GenerateTWMaze_GrowingTree();
            maze1.dumpMaze();

            // better integration for it, like generate maze1.blockVersion array
            // + display
            Byte[,] blockmaze = maze1.LineToBlock();

            for (UInt16 y = 0; y < blockmaze.GetLength(1); y++)
            {
                string xline = string.Empty;

                for (UInt16 x = 0; x < blockmaze.GetLength(0); x++)
                {
                    xline += ' ' + blockmaze[x, y].ToString();
                }

                Debug.Print(string.Format("BM[{0}]={1}", y, xline));
            }

            Byte[,] bigm = maze1.scaleMaze(3);

            for (UInt16 y = 0; y < bigm.GetLength(1); y++)
            {
                string xline = string.Empty;

                for (UInt16 x = 0; x < bigm.GetLength(0); x++)
                {
                    xline += ' ' + bigm[x, y].ToString();
                }

                Debug.Print(string.Format("BigM[{0}]={1}", y, xline));
            }
        }
Ejemplo n.º 4
0
 public MazeAdapter(MazeLib.Maze maze)
 {
     this.maze = maze;
 }
Ejemplo n.º 5
0
        private bool isValidCarvePoint(Maze maze, Point2D origin, Point2D option)
        {
            // Can't carve the outer wall of the maze or things out of bounds.
            if (option.x < 1)
            {
                return(false);
            }
            if (option.y < 1)
            {
                return(false);
            }
            // Has already been carved.
            if (!maze.hasWallAt(option))
            {
                return(false);
            }

            List <Point2D> pointsToCheck = new List <Point2D>()
            {
                // Check surrounding points
                option.Up(),
                           option.Down(),
                           option.Left(),
                           option.Right(),
                // Also want the corner points
                           option.TopLeft(),
                           option.TopRight(),
                           option.BottomLeft(),
                           option.BottomRight()
            };

            foreach (Point2D point in pointsToCheck)
            {
                // Don't disqualify if we are looking at the origin
                if (point.Equals(origin))
                {
                    continue;
                }
                // Or something connected to the origin!
                if (point.Equals(origin.Up()))
                {
                    continue;
                }
                if (point.Equals(origin.Down()))
                {
                    continue;
                }
                if (point.Equals(origin.Left()))
                {
                    continue;
                }
                if (point.Equals(origin.Right()))
                {
                    continue;
                }
                // All other points should be walls?
                if (!maze.hasWallAt(point))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 6
0
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();

            this.Window.AllowUserResizing = true;

            IsMouseVisible = true;

            methodArray = (PickMethod[])Enum.GetValues(typeof(PickMethod));

            picking = PickMethod.Newest;
            mazeW = 20;
            mazeH = 18;
            backgroundsW = 500;
            backgroundsH = 400;
            holesCount = 0;
            holesMaxRadius = 0;

            layoutIndex = 0;

            mlayout = new Layout(mazeW, mazeH);

            aMazIng = new Maze(mazeW, mazeH, mlayout, 0, 0, PickMethod.Cyclic);
            aMazIng.GenerateTWMaze_GrowingTree(picking);

            //aMazIng.dumpMaze();

            base.Initialize();
        }