public GameObject PlaceBuilding(EAssignment _assignment, Street _s, bool _isLeftSide) { EDemand density = EDemand.NONE; switch (_assignment) { case EAssignment.NONE: break; case EAssignment.LIVING: density = m_LivingDemand; break; case EAssignment.BUSINESS: density = m_BusinessDemand; break; case EAssignment.INDUSTRY: density = m_IndustryDemand; break; } GameObject prefab = GetRandomPrefab(_assignment, density); if (prefab == null) { return(null); } Building b = prefab.GetComponent <Building>(); if (_isLeftSide) { if (_s.FindAreaLeftSide(b.Size, _assignment, out Area a)) { return(SpawnPrefab(a, b, prefab)); } } else { if (_s.FindAreaRightSide(b.Size, _assignment, out Area a)) { return(SpawnPrefab(a, b, prefab)); } } return(null); }
public AConsumableBase(string itemId, string name, EDemand affector, int effectValue) : base(itemId, name, EItemType.Consumable) { _selectedDemand = affector; SetAction(IncrementAffectorByValue(effectValue)); }
public StressDecreaser(string itemId, string name, EDemand affector, int effectValue) : base(itemId, name, affector, effectValue) { }
private GameObject GetRandomPrefab(EAssignment _assignment, EDemand _density) { List <GameObject> validPrefabs = new List <GameObject>(); switch (_assignment) { case EAssignment.NONE: break; case EAssignment.LIVING: foreach (List <GameObject> objList in livingPrefabs_Dic.Values) { foreach (GameObject obj in objList) { if (CheckDensity) { Building b = obj.GetComponent <Building>(); if (b.m_Density == _density) { validPrefabs.Add(obj); } } else { validPrefabs.Add(obj); } } } break; case EAssignment.BUSINESS: foreach (List <GameObject> objList in businessPrefabs_Dic.Values) { foreach (GameObject obj in objList) { if (CheckDensity) { Building b = obj.GetComponent <Building>(); if (b.m_Density == _density) { validPrefabs.Add(obj); } } else { validPrefabs.Add(obj); } } } break; case EAssignment.INDUSTRY: foreach (List <GameObject> objList in industryPrefabs_Dic.Values) { foreach (GameObject obj in objList) { if (CheckDensity) { Building b = obj.GetComponent <Building>(); if (b.m_Density == _density) { validPrefabs.Add(obj); } } else { validPrefabs.Add(obj); } } } break; } if (validPrefabs.Count == 0) { return(null); } int index = Random.Range(0, validPrefabs.Count); return(validPrefabs[index]); }
private void SetIndustry_Ratio(float value) { industry_Ratio = value; m_IndustryDemand = GetDemand(industry_Ratio); UIManager.Instance.SetDemandRatio(EAssignment.INDUSTRY, industry_Ratio); }
private void SetBusiness_Ratio(float value) { business_Ratio = value; m_BusinessDemand = GetDemand(business_Ratio); UIManager.Instance.SetDemandRatio(EAssignment.BUSINESS, business_Ratio); }
private void SetLiving_Ratio(float value) { living_Ratio = value; m_LivingDemand = GetDemand(living_Ratio); UIManager.Instance.SetDemandRatio(EAssignment.LIVING, living_Ratio); }