public bool Reached() { if (Disabled) { return(false); } if (_currentObjective == Objective.OneHouse) { return(_worldPlane.GetBlocksWithHouses().Count > 0); } else if (_currentObjective == Objective.OneBigHouse) { return(_worldPlane .GetBlocksWithHouses() .Select(block => block.GetOccupantHouse()) .Count(house => house.IsBig()) > 0); } else if (_currentObjective == Objective.OneMegaHouse) { return(_worldPlane .GetBlocksWithHouses() .Select(block => block.GetOccupantHouse()) .Count(house => house.IsMegaBig()) > 0); } else { return(false); } }
void Update() { if (!CanWorkThisFrame()) { return; } if (_featureToggles.houseSpawn) { var delta = Time.fixedTime - _lastPlacedHouse; if (delta > 10f && Random.value < .1f) { if (CanSpawnAnotherHouse()) { SpawnOneHouse(); } } var innerCityDelta = Time.fixedTime - _lastPlacedInnerCityHouse; if (innerCityDelta > 10f && Random.value < .2f) { if (Random.value < .1f) { SpawnInnerCityHouse(); } } } if (Random.value < .01f && HasNoOtherBigHouses()) { SpawnBigHouse(); } if (!_featureToggles.desertsAreBeaches) { if (!_sandSpawned ? Random.value < _sandSpreadController.startingThreshold : Random.value < _sandSpreadController.continuationThreshold) { var houseCount = _worldPlane.GetBlocksWithHouses().Count; if (houseCount > _sandSpreadController.houseCountThreshold) { if (_worldPlane.CountBlocksOfType(Block.BlockType.Sand) == 0) { SpawnSandBlock(); _sandSpawned = true; } } } } }
void Update() { if (!_featureToggles.farmsSpawn) { return; } if (!_placedFirstFarm && Random.value < .01f) { var houses = _worldPlane.GetBlocksWithHousesNotNearWater().ToList(); if (houses.Count > 0) { SpawnMasterFarm(houses); } else { var bigHouses = _worldPlane.GetBlocksWithHouses() .Where(block => block.GetOccupantHouse().IsInnerCityHouse()) .ToList(); if (bigHouses.Count > 0) { SpawnMasterFarm(bigHouses); } } } }
public bool CanBuildADock() { var houseCount = _worldPlane .GetBlocksWithHouses() .Count(blockWithHouse => blockWithHouse.GetOccupantHouse()); if (houseCount < 1) { return(false); } var docks = _worldPlane.GetBlocksWithDocks().Count(); if (docks > 0) { var docksToHouseRatio = (float)Mathf.Max(docks, 1) / (float)houseCount; if (docksToHouseRatio > .1f) { return(false); } } return(true); }
void Update() { if (!FeatureToggles.Get().woodcutters) { return; } if (Random.value < .01f) { var houseCount = _worldPlane.GetBlocksWithHouses().Count; if (houseCount < 3) { return; } var woodcutters = _worldPlane.GetBlocksWithWoodcutters().Count(); var woodcutterToHouseRatio = (float)Mathf.Max(woodcutters, 1) / (float)houseCount; if (woodcutterToHouseRatio > .1f) { return; } var greensAndVacantLot = _worldPlane .GetBlocksWithGreens() .SelectMany(block => { return(_worldPlane .GetNearbyVacantLots(block.GetGridPosition()) .Select(vacantLot => new Tuple <Block, Block>(block, vacantLot))); }) .OrderBy(_ => Random.value) .FirstOrDefault(); if (greensAndVacantLot != null) { SpawnWoodcutter(greensAndVacantLot); } } if (_hasUnfulfilledRequestToStoreWood) { _hasUnfulfilledRequestToStoreWood = false; SpawnStockpile(); } }