//Randomly places a new dungeon room next to one that already exists private static void PlaceRandomRoom(Dungeon Dungeon) { //Get a random size for the new room Vector2 RoomSize = GetNewRoomSize(Dungeon.RoomSizes); //Create a shuffled copy of the list of rooms that already exist in the dungeon List <DungeonRoom> RoomsCopy = ListFunctions.Copy(Dungeon.Rooms); ListFunctions.Shuffle(RoomsCopy); //Search through the rooms, checking if we can place the new room adjacent to any of these existing rooms foreach (DungeonRoom OtherRoom in RoomsCopy) { //Make a list of the 4 placement directions we want to check for placing the new room List <Direction> Directions = new List <Direction>(); for (int i = 0; i < 4; i++) { Directions.Add((Direction)i); } ListFunctions.Shuffle(Directions); //Use each direction to check if we can place the new room next to the current OtherRoom in that direction Direction Placement = Direction.North; bool Found = false; foreach (Direction Check in Directions) { //Store the direction and exit out once a valid placement location has been found if (CanPlaceRoom(Dungeon, RoomSize, OtherRoom, Check)) { Placement = Check; Found = true; break; } } //Add the new room to the dungeon if a valid placement location was found if (Found) { Vector2 NewRoomPos = OtherRoom.GetAdjacentLocation((int)RoomSize.x, (int)RoomSize.y, Placement); DungeonRoom NewRoom = new DungeonRoom((int)RoomSize.x, (int)RoomSize.y, NewRoomPos); NewRoom.Init(); Dungeon.Rooms.Add(NewRoom); ConnectRooms(Dungeon, OtherRoom, NewRoom, Placement); return; return; } } }
protected List <Node> Nodes = new List <Node>(); //The child nodes for this selector public SelectorNode(List <Node> Nodes) { this.Nodes = ListFunctions.Copy(Nodes); }
protected List <Node> Nodes = new List <Node>(); //Children nodes belonging to this sequence public SequenceNode(List <Node> Nodes) { this.Nodes = ListFunctions.Copy(Nodes); }