private List <List <Maze.Room> > GetOldRoads(Maze.Door door) { List <List <Maze.Room> > roomListList = new List <List <Maze.Room> >(); foreach (List <Maze.Room> road in this.roads) { foreach (Maze.Room room in road) { if (this.TwoDoorAreEqual(room.TopDoor, door)) { roomListList.Add(road); break; } if (this.TwoDoorAreEqual(room.BottonDoor, door)) { roomListList.Add(road); break; } if (this.TwoDoorAreEqual(room.LeftDoor, door)) { roomListList.Add(road); break; } if (this.TwoDoorAreEqual(room.RightDoor, door)) { roomListList.Add(road); break; } } } return(roomListList); }
public Room() { this.topDoor = new Maze.Door(); this.bottonDoor = new Maze.Door(); this.leftDoor = new Maze.Door(); this.rightDoor = new Maze.Door(); this.topLeftDoor = new Maze.Door(); this.topRightDoor = new Maze.Door(); this.bottonLeftDoor = new Maze.Door(); this.bottonRightDoor = new Maze.Door(); }
private void Interlink() { while (!this.AllRoomLinked()) { List <Maze.Door> outlineDoors = this.GetOutlineDoors(this.roads[this.random.UniformInt(0, 1048575) % this.roads.Count]); Maze.Door door = outlineDoors[this.random.UniformInt(0, 1048575) % outlineDoors.Count]; List <List <Maze.Room> > oldRoads = this.GetOldRoads(door); List <Maze.Room> newRoad = this.GetNewRoad(oldRoads); this.RemoveOldRoads(oldRoads); this.roads.Add(newRoad); door.OpenTheDoor(); } }
private void AddOutlineDoor(Maze.Door door, List <Maze.Door> outlineDoors) { if (!door.GetLockState() || door.IsFixed) { return; } if (!outlineDoors.Contains(door)) { outlineDoors.Add(door); } else { outlineDoors.Remove(door); } }
private bool TwoDoorAreEqual(Maze.Door doorSource, Maze.Door doorTarget) { return(doorSource.GetLockState() && !doorSource.IsFixed && object.Equals((object)doorSource, (object)doorTarget)); }