Ejemplo n.º 1
0
 public Room(bool isStair)
 {
     _isStair = isStair;
     me       = false;
     top      = null;
     down     = null;
     left     = null;
     right    = null;
 }
Ejemplo n.º 2
0
        public void AddHallways()
        {
            Random rdm = new Random();

            for (int y = 0; y < rooms.Length; y++)
            {
                bool down = y != rooms.Length - 1;
                for (int x = 0; x < rooms[y].Length; x++)
                {
                    bool right = x != rooms[y].Length - 1;

                    if (right)
                    {
                        var hw = new Hallway(rooms[y][x], rooms[y][x + 1]);
                        rooms[y][x].right    = hw;
                        rooms[y][x + 1].left = hw;
                    }
                    if (down)
                    {
                        var hw = new Hallway(rooms[y][x], rooms[y + 1][x]);
                        rooms[y][x].down    = hw;
                        rooms[y + 1][x].top = hw;
                    }
                }
            }
            int rdmy = rdm.Next(rooms.Length);
            int rdmx = rdm.Next(rooms[0].Length);

            new Grenade().MinimumSpanningTree(rooms[rdmy][rdmx], minHallways, minRooms);

            for (int y = 0; y < rooms.Length; y++)
            {
                for (int x = 0; x < rooms[y].Length; x++)
                {
                    var currentroom = rooms[y][x];
                    var random      = rdm.Next(1, 3);

                    if (currentroom.right != null && !minHallways.Contains(currentroom.right))
                    {
                        if (random == 1)
                        {
                            currentroom.right.isCollapsed = true;
                        }
                    }
                    if (currentroom.down != null && !minHallways.Contains(currentroom.down))
                    {
                        if (random == 2)
                        {
                            currentroom.down.isCollapsed = true;
                        }
                    }
                }
            }
        }