Esempio n. 1
0
 public Dungeon(int seed, Game game)
     : base(game)
 {
     rand = new Random(seed);
     rooms = new RoomGraph();
     tiles = new bool[WIDTH, HEIGHT];
 }
Esempio 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();
        }
Esempio n. 3
0
 void changeNeighbourg(RoomGraph value, NeighbourgPos pos)
 {
     neighbourg.Remove(pos);
     neighbourg.Add(pos, value);
 }
Esempio n. 4
0
 void addNeighbourg(RoomGraph value, NeighbourgPos pos)
 {
     neighbourg.Add(pos, value);
 }