void SpawnNewRandomCityBuilding() { // TODO: need to find a fit for the tile specified (e.g. if 2x2 and only 1x1 area to build in, go for small building) CityBuildingModel randomModel = CityBuildingStore.GetRandomCityBuilding(); // TODO: definitely inefficient List <BuildGridReference> gridRefs = new List <BuildGridReference>(expansionAreas); for (int i = 0; i < 20; i++) { BuildGridReference spawnReference = Curveball.Utilities.SelectRandomlyFromList(gridRefs); if (BuildGridManager.CanBuildAt(spawnReference, randomModel.Size)) { CreateBuilding(randomModel, spawnReference); return; } } // was unable to spawn a building: set spawn timer to 0f to try again next frame spawnTimer = 0f; }
private void Awake() { DontDestroyOnLoad(gameObject); singleton = this; }
void OnLevelLoaded(LevelLoadedEvent e) { CreateBuilding(CityBuildingStore.GetCityCentrePrefab(), new BuildGridReference(0, 0)); startSpawning = true; spawnTimer = SECONDS_BETWEEN_BUILDING_SPAWNS; }