/// <summary> /// Generates a random instance of Village Data from the specified generator data. /// </summary> /// <param name="generatorData"></param> /// <returns></returns> private VillageData GenerateVillageData(VillageGeneratorData generatorData, float maxRadius) { var newVillageData = new VillageData { HeadCount = villageGeneratorData.headCount.RandomSample(), hutSpawnRange = generatorData.percentageHutSpawnRadius * (maxRadius / 100), elderHutSpawnRange = generatorData.percentageElderHutSpawnRadius * (maxRadius / 100), maxRadius = maxRadius, villagersPerHut = generatorData.villagersPerHut, villagerPrefab = generatorData.villagerPrefab, elderHutPrefab = generatorData.elderHutPrefab, hutPrefab = generatorData.hutPrefab }; return(newVillageData); }
private List <Vector3> CreateVillageCenters(VillageGeneratorData villageGeneratorData, int villageCount) { List <Vector3> villagePositions = new List <Vector3>(); // TODO: Generalise spawnpoint bounds float lowerSpawnBoundX = 0 - chunkSize / 2; // When the time comes to add vertical scaling, this will have to change based on a separate vertical bound float lowerSpawnBoundY = 0; float lowerSpawnBoundZ = 0 - chunkSize / 2; // TODO: Generalise spawnpoint bounds float upperSpawnBoundX = 0 + chunkSize / 2; // When the time comes to add vertical scaling, this will have to change based on a separate vertical bound float upperSpawnBoundY = 0; float upperSpawnBoundZ = 0 + chunkSize / 2; Vector3 lowerBounds = new Vector3(lowerSpawnBoundX, lowerSpawnBoundY, lowerSpawnBoundZ); Vector3 upperBounds = new Vector3(upperSpawnBoundX, upperSpawnBoundY, upperSpawnBoundZ); // Loop over each village, generate a center for it for (int idx = 0; idx < villageCount; idx++) { float newVillageRadius = villageGeneratorData.spawnRadius.RandomSample(); Vector3 spawnPosition = UtilityFunctions.GetRandomVector3(lowerBounds, upperBounds); // Create Temp Area with the above parameters var tempArea = new TempRegion(RegionType.circle, newVillageRadius, spawnPosition); // Check for any collisions if (IsCircularRegionFree(tempArea)) { string newVillageName = $"{villageGeneratorData.villageName}.{idx}"; // Initialize new Village Center GameObject newVillageObject = new GameObject(name: newVillageName); var newVillageNode = newVillageObject.AddComponent <VillageNode>(); // Find new head count int newVillagerCount = villageGeneratorData.headCount.RandomSample(); newVillageNode.SetUp(newVillageName); newVillageNode.SetUpRegion(newVillageRadius, spawnPosition); var newVillageData = new VillageData { HeadCount = newVillagerCount, // huts will be grown as per necessity in the VillageNode script hutSpawnRange = villageGeneratorData.percentageHutSpawnRadius * (newVillageRadius / 100), villagersPerHut = villageGeneratorData.villagersPerHut, villagerPrefab = villageGeneratorData.villagerPrefab, elderHutPrefab = villageGeneratorData.elderHutPrefab, hutPrefab = villageGeneratorData.hutPrefab }; newVillageNode.SetUpVillage(newVillageData); newVillageNode.BeginGenerationProcess(); villagePositions.Add(newVillageNode.CenterPosition); Regions.Add(newVillageNode); AddLink(newVillageNode); } } return(villagePositions); }