private void TrySpawnBoat() { if (_boatCount == 1 && Random.value > .1f) { return; } if (_boatCount == 2 && Random.value > .05f) { return; } if (_boatCount == 3 && Random.value > .01f) { return; } if (_boatCount == 4 && Random.value > .001f) { return; } if (_boatCount == 5 && Random.value > .0001f) { return; } if (_boatCount == 6 && Random.value > .00001f) { return; } if (_boatCount == 7 && Random.value > .000001f) { return; } if (_boatCount == 8 && Random.value > .0000001f) { return; } if (_boatCount == 9 && Random.value > .00000001f) { return; } if (FeatureToggles.Get().woodcutters) { var cityWood = CityWoodcutters.Get(); if (!cityWood.RequireWood(BoatCost)) { return; } cityWood.ConsumeWood(BoatCost); } var waterBlock = _worldPlane.GetWaterBlocks() .Where(block => { var blockPosition = block.GetGridPosition(); return(block.IsGroundLevel() && _worldPlane.GetBlocksWithDocks() .Any(dock => Vector3.Distance(dock.GetGridPosition(), blockPosition) < 3f)); }) .OrderBy(_ => Random.value) .First(); var boat = Instantiate(boatTemplate); var boatPosition = _worldPlane.ToRealCoordinates(waterBlock.GetGridPosition()); boatPosition.y = 1.164f; boat.transform.position = boatPosition; _boatCount += 1; }