private void CreateRoadAtPosition(Vector3Int position)
        {
            RoadStructureSO roadStructure = ScriptableObject.CreateInstance <RoadStructureSO>();

            _grid.PlaceStructureOnTheGrid(_structureObject, position, roadStructure);
            StructureEconomyManager.PrepareRoadStructure(position, _grid);
        }
        private SingleFacilitySO CreateSiloSingleFacilityAtPosition(Vector3Int position)
        {
            SingleFacilitySO silo = CreateSiloSingleFacility();

            _grid.PlaceStructureOnTheGrid(_structureObject, position, silo);
            StructureEconomyManager.PrepareFacilityStructure(position, _grid);
            return(silo);
        }
        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 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());
        }
示例#6
0
        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());
        }
示例#7
0
        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());
        }
示例#8
0
    public virtual void ConfirmModifications()
    {
        _placementManager.PlaceStructuresOnTheMap(_structuresToBeModified.Values);
        Type structureType = _structureData.GetType();

        foreach (var keyValuePair in _structuresToBeModified)
        {
            _grid.PlaceStructureOnTheGrid(keyValuePair.Value, keyValuePair.Key, GameObject.Instantiate(_structureData));
            StructureEconomyManager.CheckStructureTypeForCreationPreparation(structureType, keyValuePair.Key, _grid);
        }
        ResetHelpersData();
    }
        private SingleFacilitySO CreateFacilityAtPosition(Vector3Int positon, FacilityType facilityType = FacilityType.None)
        {
            SingleFacilitySO facility = new SingleFacilitySO();

            facility.requireRoadAccess    = true;
            facility.singleStructureRange = 3;
            facility.facilityType         = facilityType;
            facility.maxCustomers         = 3;
            _grid.PlaceStructureOnTheGrid(_structureObject, positon, facility);
            StructureEconomyManager.PrepareFacilityStructure(positon, _grid);
            return(facility);
        }
示例#10
0
    public virtual void ConfirmModifications()
    {
        placementManager.PlaceStructuresOnTheMap(structuresToBeModified.Values);
        Type structureType = structureData.GetType();

        foreach (var keyValuePair in structuresToBeModified)
        {
            grid.PlaceStructureOnTheGrid(keyValuePair.Value, keyValuePair.Key, GameObject.Instantiate(structureData));
            StructureEconomyManager.CreateStructureLogic(structureType, keyValuePair.Key, grid);
        }
        ResetHelpersData();
    }
示例#11
0
    private void PrepareStructureForDemolition(Vector3Int gridPosition)
    {
        var data = grid.GetStructureDataFromTheGrid(gridPosition);

        if (data != null)
        {
            Type dataType = data.GetType();
            if (dataType == typeof(ZoneStructureSO) && ((ZoneStructureSO)data).zoneType == ZoneType.Residential)
            {
                resourceManager.ReducePopulation(1);
            }
            StructureEconomyManager.DemolitionStructureLogic(dataType, gridPosition, grid);
        }
    }
        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 void PlaceUpgradedStructuresOnTheMap()
    {
        _placementManager.PlaceStructuresOnTheMap(_structuresToBeModified.Values);
        Type structureDataType;

        foreach (var stuctureGameObject in _structuresToBeModified)
        {
            foreach (var structureData in _newStructureData)
            {
                if (structureData.Key == stuctureGameObject.Key)
                {
                    PrepareStructureForUpgrade(structureData.Value);
                    structureDataType = structureData.Value.GetType();
                    _grid.PlaceStructureOnTheGrid(stuctureGameObject.Value, structureData.Key, GameObject.Instantiate(structureData.Value));
                    StructureEconomyManager.CheckStructureTypeForUpgradePreparation(structureDataType, structureData.Value, stuctureGameObject.Key, _grid);
                }
            }
        }
    }
    private void PrepareStructureForRemoval(Vector3Int gridPosition)
    {
        var structureData = _grid.GetStructureDataFromTheGrid(gridPosition);

        if (structureData != null)
        {
            Type dataType = structureData.GetType();
            if (dataType == typeof(ZoneStructureSO) && ((ZoneStructureSO)structureData).zoneType == ZoneType.Residential)
            {
                if (structureData.HasFullyUpgraded() == true)
                {
                    _resourceManager.ReducePopulation(((ZoneStructureSO)structureData).SetUpgradedResidentsAmount());
                }
                else
                {
                    _resourceManager.ReducePopulation(((ZoneStructureSO)structureData).GetResidentsAmount());
                }
            }
            StructureEconomyManager.CheckStructureTypeForRemovalPreparation(dataType, gridPosition, _grid);
        }
    }