Ejemplo n.º 1
0
 public Dungeon(int seed, Game game)
     : base(game)
 {
     rand = new Random(seed);
     rooms = new RoomGraph();
     tiles = new bool[WIDTH, HEIGHT];
 }
Ejemplo n.º 2
0
        public void GenFromBSP(BSP bsp)
        {
            RoomGraph next;

            while (!bsp.Leaf)
            {
                next = new RoomGraph();
                if (bsp.Horizontal)
                {
                    if (neighbourg.ContainsKey(NeighbourgPos.Right))
                    {
                        next.addNeighbourg(neighbourg[NeighbourgPos.Right], NeighbourgPos.Right);
                        neighbourg[NeighbourgPos.Right].changeNeighbourg(next, NeighbourgPos.Left);
                        this.changeNeighbourg(next, NeighbourgPos.Right);
                    }
                    else
                    {
                        this.addNeighbourg(next, NeighbourgPos.Right);
                    }
                    next.addNeighbourg(this, NeighbourgPos.Left);
                }
                else
                {
                    if (neighbourg.ContainsKey(NeighbourgPos.Down))
                    {
                        next.addNeighbourg(neighbourg[NeighbourgPos.Down], NeighbourgPos.Down);
                        neighbourg[NeighbourgPos.Down].changeNeighbourg(next, NeighbourgPos.Up);
                        this.changeNeighbourg(next, NeighbourgPos.Down);
                    }
                    else
                    {
                        this.addNeighbourg(next, NeighbourgPos.Down);
                    }
                    next.addNeighbourg(this, NeighbourgPos.Up);
                }
                next.GenFromBSP(bsp.Right);
                bsp = bsp.Left;
            }
            pos = bsp;

            room = new DungeonRoom(new Vector3(bsp.Width, 1, bsp.Height), new Vector3(bsp.X, 0, bsp.Y));
            room.LoadRoom();
        }
Ejemplo n.º 3
0
 void changeNeighbourg(RoomGraph value, NeighbourgPos pos)
 {
     neighbourg.Remove(pos);
     neighbourg.Add(pos, value);
 }
Ejemplo n.º 4
0
 void addNeighbourg(RoomGraph value, NeighbourgPos pos)
 {
     neighbourg.Add(pos, value);
 }