//what to do when zone structure is placed public static void PrepareZoneStructure(Vector3Int gridPosition, GridStructure grid) { PrepareNewStructure(gridPosition, grid); ZoneStructureSO zoneData = (ZoneStructureSO)grid.GetStructureDataFromTheGrid(gridPosition); if (DoesStructureRequireAnyResource(zoneData)) { var structuresAroundPositions = grid.GetStructurePositionsInRange(gridPosition, zoneData.maxFacilitySearchRange); foreach (var structurePositionNearby in structuresAroundPositions) { var data = grid.GetStructureDataFromTheGrid(structurePositionNearby); if (data.GetType() == typeof(SingleFacilitySO)) { SingleFacilitySO facility = (SingleFacilitySO)data; if ((facility.facilityType == FacilityType.Power && zoneData.HasPower() == false && zoneData.requirePower) || (facility.facilityType == FacilityType.Water && zoneData.HasWater() == false && zoneData.requireWater)) { if (grid.ArePositionsInRange(gridPosition, structurePositionNearby, facility.singleStructureRange)) { if (facility.IsFull() == false) { facility.AddClients(new StructureBaseSO[] { zoneData }); if (DoesStructureRequireAnyResource(zoneData) == false) { return; } } } } } } } }
public void StructureManagerEconomyTestsAddReidentialStructureNearRoadConnections() { CreateRoadAtPosition(new Vector3Int(3, 0, 0)); ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); Assert.True(residentialZone.HasRoadAccess()); }
public void StructureEconomyManagerAddReidentialStructureNearRoadDiagonalNoConnection() { CreateRoadATPosition(new Vector3Int(3, 0, 3)); ZoneStructureSO residentialZone = CreateZOneAtPosition(new Vector3Int(0, 0, 0)); Assert.False(residentialZone.HasRoadAccess()); }
public void StructureManagerEconomyTestsAddRoadNearReidentialStructureRoadDiagonalNoConnections() { ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); CreateRoadAtPosition(new Vector3Int(3, 0, 3)); Assert.False(residentialZone.HasRoadAccess()); }
public void DisplayZoneStructureInfo(ZoneStructureSO data) { Show(); HideElement(clientsTxt.gameObject); SetText(nameTxt, data.buildingName); SetText(incomeTxt, data.GetIncome() + ""); SetText(upkeepTxt, data.upkeepCost + ""); if (data.requirePower) { SetToggle(powerToggle, data.HasPower()); } else { HideElement(powerToggle.gameObject); } if (data.requireWater) { SetToggle(waterToggle, data.HasWater()); } else { HideElement(waterToggle.gameObject); } if (data.requireRoadAccess) { SetToggle(roadToggle, data.HasRoadAccess()); } else { HideElement(roadToggle.gameObject); } }
public void StructureEconomyManagerAddRoadNearReidentialStructureConnection() { ZoneStructureSO residentialZone = CreateZOneAtPosition(new Vector3Int(0, 0, 0)); CreateRoadATPosition(new Vector3Int(3, 0, 0)); Assert.True(residentialZone.HasRoadAccess()); }
public void Init() { structureRepo = Substitute.For <StructureRepository>(); CollectionSO collection = new CollectionSO(); testRoad = new GameObject(); testSingleStructure = new GameObject(); testZone = new GameObject(); var road = new RoadStructureSO(); road.buildingName = "Road"; road.prefab = testRoad; var facility = new SingleFacilitySO(); facility.buildingName = "PowerPlant"; facility.prefab = testSingleStructure; var zone = new ZoneStructureSO(); zone.buildingName = "Commercial"; zone.prefab = testZone; collection.roadStructure = road; collection.singleStructureList = new List <SingleStructureBaseSO>(); collection.singleStructureList.Add(facility); collection.zonesList = new List <ZoneStructureSO>(); collection.zonesList.Add(zone); structureRepo.modelDataCollection = collection; }
public void Init() { CollectionSO collection = new CollectionSO(); var road = new RoadStructureSO(); road.buildingName = "Road"; collection.roadStructure = road; var facility = new SingleFacilitySO(); facility.buildingName = "PowerPlant"; collection.singleStructureList = new List <SingleStructureBaseSO>(); collection.singleStructureList.Add(facility); var zone = new ZoneStructureSO(); zone.buildingName = "Commercial"; collection.zonesList = new List <ZoneStructureSO>(); collection.zonesList.Add(zone); GameObject testObject = new GameObject(); repository = testObject.AddComponent <StructureRepository>(); repository.modelDataCollection = collection; }
public void StructureEconomyManagerPlaceResidentialAfterFacilityTooFar() { SingleFacilitySO facility = CreateFacilityAtPosition(new Vector3Int(6, 0, 6), FacilityType.Power); ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); Assert.False(residentialZone.HasPower()); Assert.True(facility.GetNumberOfCustomers() == 0); }
private ZoneStructureSO CreateAgricultureZoneAtPosition(Vector3Int position) { ZoneStructureSO agricultureZone = CreateAgricultureZone(); _grid.PlaceStructureOnTheGrid(_structureObject, position, agricultureZone); StructureEconomyManager.PrepareZoneStructure(position, _grid); return(agricultureZone); }
private ZoneStructureSO CreateZoneAtPosition(Vector3Int position) { ZoneStructureSO residentialZone = CreateResidentialZone(); _grid.PlaceStructureOnTheGrid(_structureObject, position, residentialZone); StructureEconomyManager.PrepareZoneStructure(position, _grid); return(residentialZone); }
public void StructureEconomyManagerRemoveRoadNearReidentialStructureDiagonalNoConnection() { ZoneStructureSO residentialZone = CreateZOneAtPosition(new Vector3Int(0, 0, 0)); CreateRoadATPosition(new Vector3Int(3, 0, 3)); StructureEconomyManager.PrepareRoadDemolition(new Vector3Int(3, 0, 3), grid); grid.RemoveStructureFromTheGrid(new Vector3(3, 0, 3)); Assert.False(residentialZone.HasRoadAccess()); }
public void StructureEconomyManagerRemoveRoadNearReidentialStructureConnection() { ZoneStructureSO residentialZone = CreateZOneAtPosition(new Vector3Int(0, 0, 0)); RoadStructureSO roadStructure = ScriptableObject.CreateInstance <RoadStructureSO>(); CreateRoadATPosition(new Vector3Int(3, 0, 0)); StructureEconomyManager.PrepareRoadDemolition(new Vector3Int(3, 0, 0), grid); grid.RemoveStructureFromTheGrid(new Vector3(3, 0, 0)); Assert.False(residentialZone.HasRoadAccess()); }
public void StructureManagerEconomyTestsRemoveRoadNearReidentialStructureRoadDiagonalConnections() { ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); RoadStructureSO roadStructure = ScriptableObject.CreateInstance <RoadStructureSO>(); CreateRoadAtPosition(new Vector3Int(3, 0, 3)); StructureEconomyManager.PrepareRoadRemoval(new Vector3Int(3, 0, 3), _grid); _grid.RemoveStructureFromTheGrid(new Vector3(3, 0, 3)); Assert.False(residentialZone.HasRoadAccess()); }
public void StructureEconomyManagerPlaceUpgradedFacilityAddsMoreClients() { //Add Test here for upgraded silo SingleFacilitySO facility = CreateFacilityAtPosition(new Vector3Int(6, 0, 0), FacilityType.Power); facility.singleStructureRange = 1; ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); Assert.True(facility.GetNumberOfCustomers() == 0); }
private static ZoneStructureSO CreateResidentialZone() { ZoneStructureSO residentialZone = ScriptableObject.CreateInstance <ZoneStructureSO>(); residentialZone.requireRoadAccess = true; residentialZone.requirePower = true; residentialZone.requireWater = true; residentialZone.upkeepCost = 30; residentialZone.maxFacilitySearchRange = 2; return(residentialZone); }
private void CheckStructureToDisplayResidentsText(ZoneStructureSO structure) { if (structure.zoneType == ZoneType.Residential) { SetText(residentsText, structure.GetResidentsAmount() + ""); } else { HideElement(residentsText.gameObject); } }
public void StructureEconomyManagerAdd3ReidentialStructureNearRoadConnectionWith1() { CreateRoadATPosition(new Vector3Int(3, 0, 3)); ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); ZoneStructureSO residentialZone1 = CreateZoneAtPosition(new Vector3Int(0, 0, 3)); ZoneStructureSO residentialZone2 = CreateZoneAtPosition(new Vector3Int(0, 0, 6)); Assert.False(residentialZone.HasRoadAccess()); Assert.True(residentialZone1.HasRoadAccess()); Assert.False(residentialZone2.HasRoadAccess()); }
public void StructureEconomyManagerAddPowerFacilityNear3Residential3Connected() { ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); ZoneStructureSO residentialZone1 = CreateZoneAtPosition(new Vector3Int(0, 0, 3)); ZoneStructureSO residentialZone2 = CreateZoneAtPosition(new Vector3Int(0, 0, 6)); SingleFacilitySO facility = CreateFacilityAtPosition(new Vector3Int(6, 0, 6), FacilityType.Power); Assert.True(residentialZone.HasPower()); Assert.True(residentialZone1.HasPower()); Assert.True(residentialZone2.HasPower()); Assert.True(facility.GetNumberOfCustomers() == 3); }
public void StructureEconomyManager3ResidentialsConnectedToFacilityRemove2() { ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); ZoneStructureSO residentialZone1 = CreateZoneAtPosition(new Vector3Int(0, 0, 3)); ZoneStructureSO residentialZone2 = CreateZoneAtPosition(new Vector3Int(0, 0, 6)); SingleFacilitySO facility = CreateFacilityAtPosition(new Vector3Int(6, 0, 6), FacilityType.Power); StructureEconomyManager.PrepareStructureForRemoval(new Vector3Int(0, 0, 0), _grid); StructureEconomyManager.PrepareStructureForRemoval(new Vector3Int(0, 0, 3), _grid); _grid.RemoveStructureFromTheGrid(new Vector3(0, 0, 0)); _grid.RemoveStructureFromTheGrid(new Vector3(0, 0, 3)); Assert.True(residentialZone2.HasPower()); Assert.True(facility.GetNumberOfCustomers() == 1); }
public void StructureEconomyManagerRemovePowerFacilityNear3Residential3Connected() { ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); ZoneStructureSO residentialZone1 = CreateZoneAtPosition(new Vector3Int(0, 0, 3)); ZoneStructureSO residentialZone2 = CreateZoneAtPosition(new Vector3Int(0, 0, 6)); SingleFacilitySO facility = CreateFacilityAtPosition(new Vector3Int(6, 0, 6), FacilityType.Power); StructureEconomyManager.PrepareFacilityRemoval(new Vector3Int(6, 0, 6), _grid); _grid.RemoveStructureFromTheGrid(new Vector3Int(6, 0, 6)); Assert.False(residentialZone.HasPower()); Assert.False(residentialZone1.HasPower()); Assert.False(residentialZone2.HasPower()); Assert.True(_grid.GetStructureDataFromTheGrid(new Vector3Int(6, 0, 6)) == null); }
private static ZoneStructureSO CreateAgricultureZone() { ZoneStructureSO agricultureZone = ScriptableObject.CreateInstance <ZoneStructureSO>(); GameObject TestPrefab = new GameObject(); GameObject TestPrefab2 = new GameObject(); agricultureZone.buildingName = "Agriculture"; agricultureZone.zoneType = ZoneType.Agridcultural; agricultureZone.requireRoadAccess = true; agricultureZone.requirePower = true; agricultureZone.requireWater = true; agricultureZone.upgradable = true; agricultureZone.fullyUpgraded = false; agricultureZone.upkeepCost = 0; agricultureZone.prefab = TestPrefab; agricultureZone.maxFacilitySearchRange = 2; agricultureZone.upgradeLevelPrefabs[0] = TestPrefab2; return(agricultureZone); }
public static StructureRepository CreateStructureRepositoryContainingZoneStructure() { StructureRepository structureRepository = Substitute.For <StructureRepository>(); CollectionSO collection = ScriptableObject.CreateInstance <CollectionSO>(); ZoneStructureSO zone = ScriptableObject.CreateInstance <ZoneStructureSO>(); GameObject TestPrefab = new GameObject(); GameObject TestPrefab2 = new GameObject(); zone.buildingName = "Commercial"; zone.prefab = GetAGameObjectWithMaterial(); zone.upgradable = true; zone.fullyUpgraded = false; zone.prefab = TestPrefab; //zone.upgradePrefab = TestPrefab2; //zone.upgradePrefabVariants = new GameObject[1]; collection.zoneStructures = new List <ZoneStructureSO>(); collection.zoneStructures.Add(zone); structureRepository.modelDataCollection = collection; return(structureRepository); }
public void DisplayZoneStructureInfo(ZoneStructureSO data) { Show(); HideElement(clientText.gameObject); HideElement(upkeepText.gameObject); SetText(nameText, data.buildingName); SetText(incomeText, data.GetIncome() + ""); CheckStructureToDisplayMaterialBuildTimeText(data); CheckStructureToDisplayUpgradeAmountText(data); CheckStructureToDisplayResidentsText(data); CheckStructureToDisplayPowerToggle(data); CheckStructureToDisplayRoadToggle(data); CheckStructureToDisplayWaterToggle(data); CheckStructureToDisplayUpgradeToggle(data); CheckStructureToDisplaySiloToggle(data); CheckStructureToDisplayLawEnforcementToggle(data); CheckStructureToDisplayFireProtectionToggle(data); CheckStructureToDisplayHealthcareToggle(data); CheckStructureToDisplayPostalServiceToggle(data); CheckStructureToDisplayBankingServiceToggle(data); CheckStructureToDisplayGarbageServiceToggle(data); }
public void Init() { CollectionSO collection = ScriptableObject.CreateInstance <CollectionSO>(); RoadStructureSO road = ScriptableObject.CreateInstance <RoadStructureSO>(); ZoneStructureSO zone = ScriptableObject.CreateInstance <ZoneStructureSO>(); SingleFacilitySO facility = ScriptableObject.CreateInstance <SingleFacilitySO>(); //SingleStructureBaseSO single = ScriptableObject.CreateInstance<SingleStructureBaseSO>(); road.buildingName = "Road"; zone.buildingName = "Commercial"; facility.buildingName = "PowerPlant"; collection.roadStructure = road; collection.singleStructures = new List <SingleStructureBaseSO>(); collection.singleStructures.Add(facility); collection.zoneStructures.Add(zone); GameObject testObject = new GameObject(); _repository = testObject.AddComponent <StructureRepository>(); _repository.modelDataCollection = collection; }
private static bool DoesStructureRequireAnyResource(ZoneStructureSO zoneData) { return((zoneData.requirePower && zoneData.HasPower() == false) || (zoneData.requireWater && zoneData.HasWater() == false)); }
public void DisplayZoneStructureInfo(ZoneStructureSO data) { structureInfoPanelHelper.DisplayZoneStructureInfo(data); }
public void StructureManagerEconomyTestsAddReidentialStructureNoRoad() { ZoneStructureSO residentialZone = CreateZoneAtPosition(new Vector3Int(0, 0, 0)); Assert.False(residentialZone.HasRoadAccess()); }