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