private ElevatorGeoForm ChooseElevatorForm(float wealthLevel) { var firstForm = new KeyValuePair <ElevatorGeoForm, float>(ElevatorGeoForm.Squared, ProceduralManager.instance.minThresholdValue); var secondForm = new KeyValuePair <ElevatorGeoForm, float>(ElevatorGeoForm.Rounded, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstForm, secondForm, wealthLevel)); }
private ElevatorOpenness ChooseElevatorOpenness(float wealthLevel) { var firstOpenness = new KeyValuePair <ElevatorOpenness, float>(ElevatorOpenness.Closed, ProceduralManager.instance.minThresholdValue); var secondOpenness = new KeyValuePair <ElevatorOpenness, float>(ElevatorOpenness.Opened, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstOpenness, secondOpenness, wealthLevel)); }
private RoadType ChooseRoadType(float wealthLevel) { var firstRoadType = new KeyValuePair <RoadType, float>(RoadType.Cross, ProceduralManager.instance.minThresholdValue); var secondRoadType = new KeyValuePair <RoadType, float>(RoadType.Straight, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstRoadType, secondRoadType, wealthLevel)); }
private int GetNbElevator(float wealthLevel) { var firstNumber = new KeyValuePair <int, float>(1, ProceduralManager.instance.minThresholdValue); var secondNumber = new KeyValuePair <int, float>(2, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstNumber, secondNumber, wealthLevel)); }
public bool ChooseIfHub(float wealthLevel) { var firstYesorNo = new KeyValuePair <bool, float>(true, ProceduralManager.instance.minThresholdValue); var secondYesorNo = new KeyValuePair <bool, float>(false, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstYesorNo, secondYesorNo, wealthLevel)); }
private GameObject LoadInsideShop(WealthLevelShop wealthLevelShop, SizeShop sizeShop, float wealthValue) { GameObject[] shops; if (wealthLevelShop == WealthLevelShop.Poor) { shops = (sizeShop == SizeShop.Small) ? poorSmall : poorBig; } else if (wealthLevelShop == WealthLevelShop.Normal) { shops = (sizeShop == SizeShop.Small) ? normalSmall : normalBig; } else { shops = (sizeShop == SizeShop.Small) ? richSmall : richBig; } var shopDict = new Dictionary <GameObject, float>(); foreach (var obj in shops) { shopDict.Add(obj, obj.GetComponent <ProceduralEntity>().wealthValue); } return(Instantiate(ProceduralCalculations.GetRandomTFromPool(shopDict, wealthValue))); }
public WealthStair ChooseWealthStair(float wealthLevel) { var firstWealthStair = new KeyValuePair <WealthStair, float>(WealthStair.Poor, ProceduralManager.instance.minThresholdValue); var secondWealthStair = new KeyValuePair <WealthStair, float>(WealthStair.Rich, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstWealthStair, secondWealthStair, wealthLevel)); }
private int ChooseBorder(ElevatorGeoForm form, ElevatorOpenness openness, float wealthLevel) { var border = new Dictionary <int, float>(); int beginIndex = 0; if (openness == ElevatorOpenness.Opened) { beginIndex = 1; } if (form == ElevatorGeoForm.Squared) { for (int i = beginIndex; i < 4; i++) { border.Add(i, SquaredBorder[i].GetComponent <ProceduralEntity>().wealthValue); } } else { for (int i = beginIndex; i < 4; i++) { border.Add(i, RoundedBorder[i].GetComponent <ProceduralEntity>().wealthValue); } } return(ProceduralCalculations.GetRandomTFromPool(border, wealthLevel)); }
public WidthStair ChooseWidthStair(float wealthLevel) { var firstWidth = new KeyValuePair <WidthStair, float>(WidthStair.Simple, ProceduralManager.instance.minThresholdValue); var secondWidth = new KeyValuePair <WidthStair, float>(WidthStair.Double, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstWidth, secondWidth, wealthLevel)); }
private ObstructedLocation GetLocationElevator(float wealthLevel) { var locations = new Dictionary <ObstructedLocation, float>(); locations.Add(ObstructedLocation.Middle, MiddleValueProb); locations.Add(ObstructedLocation.Short, ShortValueProb); locations.Add(ObstructedLocation.Long, LongValueProb); return(ProceduralCalculations.GetRandomTFromPool(locations, wealthLevel)); }
private GameObject GetDoor(float wealthLevel) { var doorDictionary = new Dictionary <GameObject, float>(); foreach (var door in doors) { doorDictionary.Add(door, door.GetComponent <ProceduralEntity>().wealthValue); } return(ProceduralCalculations.GetRandomTFromPool(doorDictionary, wealthLevel)); }
private GameObject GetWall(GameObject[] walls, float wealthLevel) { var wallDictionary = new Dictionary <GameObject, float>(); foreach (var wallGO in walls) { wallDictionary.Add(wallGO, wallGO.GetComponent <ProceduralEntity>().wealthValue); } return(ProceduralCalculations.GetRandomTFromPool(wallDictionary, wealthLevel)); }
public DirectionHub ChooseDirectionHub(bool isHub, float wealthLevel) { if (!isHub) { return(DirectionHub.Null); } var firstDirection = new KeyValuePair <DirectionHub, float>(DirectionHub.Inside, ProceduralManager.instance.minThresholdValue); var secondDirection = new KeyValuePair <DirectionHub, float>(DirectionHub.Outside, ProceduralManager.instance.maxTresholdValue); return(ProceduralCalculations.GetRandomFrom2Value(firstDirection, secondDirection, wealthLevel)); }
private StoreyPlace ChooseStoreyPlace(List <ObstructedLocation> obstructedLocations, float wealthLevel) { var placesAvailable = (from placeAvailable in places where placeAvailable.place.GetComponent <ProceduralEntity>().obstructedLocation.Intersect(obstructedLocations).Count() == 0 select placeAvailable).ToList(); var placesToPick = new Dictionary <StoreyPlace, float>(); foreach (var placeAvailable in placesAvailable) { placesToPick.Add(placeAvailable, placeAvailable.place.GetComponent <ProceduralEntity>().wealthValue); } return(ProceduralCalculations.GetRandomTFromPool(placesToPick, wealthLevel)); }
//public DirectionHub ChooseDirectionHub() public ObstructedPattern ChooseObstructedPattern(List <ObstructedLocation> obstructedLocations, ObstructedStair obstructedStair, float wealthLevel) { var obstructedPatterns = new Dictionary <ObstructedPattern, float>(); var obstructedPatternsAvailable = (from oPAvailable in obstructedStair.ObstructedPatterns where oPAvailable.obstructedLocations.Intersect(obstructedLocations).Count() == 0 select oPAvailable).ToList(); foreach (var oPAvailable in obstructedPatternsAvailable) { obstructedPatterns.Add(oPAvailable, oPAvailable.wealthValue); } return(ProceduralCalculations.GetRandomTFromPool(obstructedPatterns, wealthLevel)); }
public void LoadMall(List <ObstructedLocation> obstructedLocation, float wealthLevel) { var mallDict = new Dictionary <GameObject, float>(); foreach (var obj in contentMall) { if (!(obstructedLocation.Contains(ObstructedLocation.Middle) && obj.GetComponent <ProceduralEntity>().obstructedLocation.Contains(ObstructedLocation.Middle))) { mallDict.Add(obj, obj.GetComponent <ProceduralEntity>().wealthValue); } } GameObject temp = Instantiate(ProceduralCalculations.GetRandomTFromPool(mallDict, wealthLevel), ProceduralManager.ParentMap); temp.transform.position = Vector3.zero; }
private GameObject ChooseRoad(List <GameObject> roads, List <ObstructedLocation> obstructedLocations, float wealthLevel) { var roadsAvailable = (from roadAvailable in roads where roadAvailable.GetComponent <ProceduralEntity>().obstructedLocation .Intersect(obstructedLocations).Count() == 0 select roadAvailable).ToList(); var road = new Dictionary <GameObject, float>(); foreach (var roadAvailable in roadsAvailable) { road.Add(roadAvailable, roadAvailable.GetComponent <ProceduralEntity>().wealthValue); } return(ProceduralCalculations.GetRandomTFromPool(road, wealthLevel)); //----------- }
public LengthStair ChooseLengthStair(float wealthLevel, bool isLongIntegrated) { var lengths = new Dictionary <LengthStair, float>(); if (isLongIntegrated) { lengths.Add(LengthStair.Long, 1f); lengths.Add(LengthStair.Medium, .5f); lengths.Add(LengthStair.Short, 0f); return(ProceduralCalculations.GetRandomTFromPool(lengths, wealthLevel)); } else { var firstLength = new KeyValuePair <LengthStair, float>(LengthStair.Medium, 1f); var secondLength = new KeyValuePair <LengthStair, float>(LengthStair.Short, 0f); return(ProceduralCalculations.GetRandomFrom2Value(firstLength, secondLength, wealthLevel)); } }
private void LoadApartment(float wealthValue, Vector3 position, SizeApartment sizeApartment) { GameObject[] rooms; switch (sizeApartment) { case SizeApartment.Small: rooms = smallContent; break; case SizeApartment.Medium: rooms = mediumContent; break; case SizeApartment.Big: rooms = bigContent; break; default: rooms = tinyContent; break; } var roomDict = new Dictionary <GameObject, float>(); foreach (var room in rooms) { roomDict.Add(room, room.GetComponent <ProceduralEntity>().wealthValue); } GameObject temp = Instantiate(ProceduralCalculations.GetRandomTFromPool(roomDict, wealthValue), ProceduralManager.ParentMap); temp.transform.position = position; RotateRoom(temp.transform, position); }
public void LoadShops(List <ObstructedLocation> obstructedLocations, float wealthLevel) { doorShopManager.Reset(); int longSide = 10; int shortSide = 7; WealthLevelShop choosenWealthLevelShop = (wealthLevel < tresholdPoorNormal)? WealthLevelShop.Poor : ((wealthLevel < tresholdNormalRich)? WealthLevelShop.Normal : WealthLevelShop.Rich); GameObject[] choosenShops = (choosenWealthLevelShop == WealthLevelShop.Poor)? poorShops : ((choosenWealthLevelShop == WealthLevelShop.Normal)? normalShops : richShops); GameObject shopToPut; // 10 units for long // 7 units for short bool isShopObstructed; int sideValue; int middleObsIdx; GameObject shopParent; for (int h = 0; h < 2; h++) { bool isLong = (h == 0); sideValue = (isLong) ? longSide : shortSide; isShopObstructed = (isLong) ? obstructedLocations.Contains(ObstructedLocation.Long) : obstructedLocations.Contains(ObstructedLocation.Short); middleObsIdx = (isLong) ? 4 : 2; for (int i = 0; i < 2; i++) { int j = 0; int add = 0; SizeShop choosenSizeShop; GameObject shop; while (j < sideValue) { choosenSizeShop = SizeShop.Null; if (j == middleObsIdx + 1 && isShopObstructed) { add = 1; shopToPut = noShops[0]; } else if ((j == middleObsIdx && isShopObstructed) || (j == sideValue - 1)) { add = 1; shopToPut = choosenShops[0]; choosenSizeShop = SizeShop.Small; } else { if (ProceduralCalculations.GetRandomValue() < wealthLevel) { add = 2; shopToPut = choosenShops[1]; choosenSizeShop = SizeShop.Big; } else { add = 1; shopToPut = choosenShops[0]; choosenSizeShop = SizeShop.Small; } } int x = (isLong)? -100 + j * 20 : 100; int z = (isLong)? 70 : 70 - j * 20; int yRotation = (isLong)? 0 : 90; if (i == 1) { x *= -1; z *= -1; yRotation = (isLong)? 180 : 270; } j += add; shopParent = new GameObject(); shopParent.transform.parent = ProceduralManager.ParentMap; shopParent.name = "Shop"; shopParent.transform.position = new Vector3(x, 0, z); shopToPut = Instantiate(shopToPut, shopParent.transform); shopToPut.transform.position = new Vector3(x, 0, z); shopToPut.transform.Rotate(0, yRotation, 0); if (choosenSizeShop != SizeShop.Null) { shop = LoadInsideShop(choosenWealthLevelShop, choosenSizeShop, wealthLevel); shop.transform.parent = shopParent.transform; shop.transform.position = new Vector3(x, 0, z); shop.transform.Rotate(0, yRotation, 0); shop.SetActive(false); ShopEntity shopEntity = new ShopEntity(); shopEntity.ParentObjects = shop; shopEntity.Animator = shopToPut.GetComponent <Animator>(); shopEntity.Position = GetCenterDoor(shopToPut.transform.GetChild(0).position, shopToPut.transform.GetChild(1).position); shopEntity.IsOpen = false; doorShopManager.Add(shopEntity); } } } } doorShopManager.EnableDoorShop(); }