Exemplo n.º 1
0
        public void RandomFill(int Percent)
        {
            m_maze = new MazeGenerator();

            List <Rectangle> m_exitRooms = new List <Rectangle>();
            List <Point>     m_exits     = new List <Point>();

            if (m_maze.m_rooms.Count > 1)
            {
                do
                {
                    m_exitRooms.Add(m_maze.m_rooms[Game1.RNG.Next(0, m_maze.m_rooms.Count)]);
                    m_exitRooms.Add(m_maze.m_rooms[Game1.RNG.Next(0, m_maze.m_rooms.Count)]);

                    if (m_exitRooms[0] != m_exitRooms[1])
                    {
                        break;
                    }
                    m_exitRooms.Clear();
                } while (true);

                m_exits.Add(new Point(m_exitRooms[0].X + Game1.RNG.Next(1, m_exitRooms[0].Width - 1), m_exitRooms[0].Y + Game1.RNG.Next(1, m_exitRooms[0].Height - 1)));
                m_exits.Add(new Point(m_exitRooms[1].X + Game1.RNG.Next(1, m_exitRooms[1].Width - 1), m_exitRooms[1].Y + Game1.RNG.Next(1, m_exitRooms[1].Height - 1)));
            }
            else if (m_maze.m_rooms.Count == 1)
            {
                m_exitRooms.Add(m_maze.m_rooms[0]);
                do
                {
                    m_exits.Add(new Point(m_exitRooms[0].X + Game1.RNG.Next(1, m_exitRooms[0].Width - 1), m_exitRooms[0].Y + Game1.RNG.Next(1, m_exitRooms[0].Height - 1)));
                    m_exits.Add(new Point(m_exitRooms[0].X + Game1.RNG.Next(1, m_exitRooms[0].Width - 1), m_exitRooms[0].Y + Game1.RNG.Next(1, m_exitRooms[0].Height - 1)));
                    if (m_exits[0] != m_exits[1])
                    {
                        break;
                    }
                } while (true);
            }
            else
            {
                m_exits.Add(new Point(0, 0));
                m_exits.Add(new Point(0, 1));
            }

            //m_exits.Clear();
            //m_exits.Add(new Point(0, 0));
            //m_exits.Add(new Point(0, 1));


            levelCreate.Map[m_exits[0].X, m_exits[0].Y] = 2;
            levelCreate.Map[m_exits[1].X, m_exits[1].Y] = 3;

            MapChanged = true;
        }
Exemplo n.º 2
0
 public Level(MazeInfo inf)
 {
     m_mazeGen = new MazeGenerator();
     m_inf     = inf;
     RegenMaze(inf);
 }
Exemplo n.º 3
0
 public Level(int seed)
 {
     m_mazeGen = new MazeGenerator(seed);
     m_inf     = new MazeInfo(new Point(128, 96), 40, 30, 7, 15, 10);
     RegenMaze(m_inf);
 }