private static void AddLivingQuarterSideFurnishing(LivingQuarters room, string[,,] grid) { var population = room.inhabitants.Count; var size = Mathf.Sqrt(DesignedBuilding.monsterRoomSizes[room.inhabitants[0].generalType]); int bedType = GetBedType(room); if (bedType == 1) { population /= 2; } bool fancy = (bedType >= 6); Dictionary <string, GameObject> furniture; Dictionary <string, float> furnitureProbs; if (fancy) { furniture = prefabs["castle"]["livingQuarterSideFurnitureFancy"]; furnitureProbs = prefabProbability["castle"]["livingQuarterSideFurnitureFancy"]; } else { furniture = prefabs["castle"]["livingQuarterSideFurniture"]; furnitureProbs = prefabProbability["castle"]["livingQuarterSideFurniture"]; } var potentialSpots = LevelGenRoomUtils.GetPotentialSideDressingSpots(room, grid); foreach (var spot in potentialSpots) { var roll = Random.Range(0, 100); if (roll < 100 * population / (float)potentialSpots.Count) { var xFudge = Random.Range(-0.05f, 0.05f); var yFudge = Random.Range(-0.05f, 0.05f); var rotationFudge = Random.Range(-2.5f, 2.5f); var wallRotation = LevelGenGridUtils.GetWallRotation((int)spot.x, (int)spot.y, room.floor, grid); var xAdjust = LevelGenGridUtils.GetXSideDressingAdjustment((int)spot.x, (int)spot.y, room.floor, grid); var yAdjust = LevelGenGridUtils.GetYSideDressingAdjustment((int)spot.x, (int)spot.y, room.floor, grid); var obj = LevelGenInstantiationUtils.InstantiateBlockObject(furniture, furnitureProbs, xAdjust + xFudge + spot.x, yAdjust + yFudge + spot.y); room.dressingLocations.Add(spot); obj.transform.localScale = new Vector3(size, size, size); obj.transform.Rotate(0, rotationFudge + wallRotation, 0); } } }
private static void AddBeds(LivingQuarters room) { var population = room.inhabitants.Count; var size = Mathf.Sqrt(DesignedBuilding.monsterRoomSizes[room.inhabitants[0].generalType]); int bedType = GetBedType(room); if (bedType == 1) { population /= 2; } var beds = prefabs["castle"]["beds" + bedType]; var bedProbs = prefabProbability["castle"]["beds" + bedType]; int bedsX = (int)Mathf.Sqrt(population); if (bedsX == 0) { bedsX = 1; } int bedsY = population / bedsX; int bedRotation = Random.Range(0, 4); for (int x = 0; x < bedsX; x++) { for (int y = 0; y < bedsY; y++) { var xFudge = Random.Range(-0.05f, 0.05f); var yFudge = Random.Range(-0.05f, 0.05f); var obj = LevelGenInstantiationUtils.InstantiateBlockObject(beds, bedProbs, xFudge + room.x - 0.5f + ((float)(room.xSize) * (x + 1) / (bedsX + 1)), yFudge + room.y - 0.5f + ((float)(room.ySize) * (y + 1) / (bedsY + 1))); obj.transform.localScale = new Vector3(size, size, size); var rotationFudge = Random.Range(-2.5f, 2.5f); obj.transform.Rotate(0, (90 * bedRotation) + rotationFudge, 0); int nightstandRoll = Random.Range(0, 2); if (nightstandRoll == 0) { AddNightstand(xFudge + room.x - 0.5f + ((float)(room.xSize) * (x + 1) / (bedsX + 1)), yFudge + room.y - 0.5f + ((float)(room.ySize) * (y + 1) / (bedsY + 1)), 90 * bedRotation, size); } } } }
public static void AddDressing(LivingQuarters room, string[,,] grid) { AddBeds(room); AddLivingQuarterSideFurnishing(room, grid); }