void OnModelsInitialised(ModelsInitialisedEvent e) { DestroyView(); CityModel currentCity = CityModel.CurrentCity; GameObject basePrefab = PrefabDictionary.GetCityWithName(currentCity.Name).gameObject; cityGameObject = Instantiate(basePrefab, CityRoot); if (!e.FromSaveFile) { cityGameObject.GetComponent <CityModel>().InitialiseNew(); } else { cityGameObject.GetComponent <CityModel>().CopyFrom(currentCity); } CityModel.CurrentCity = cityGameObject.GetComponent <CityModel>(); Timer.CreateTimer(gameObject, 0.05f, () => { EventSystem.Publish(new ViewInitialisedEvent()); }); }
private void OnNewGame(NewGameEvent e) { CityModel.CurrentCity = PrefabDictionary.GetRandomStartCity(); // TODO: setup base SurvivorModel.Initialise(); SurvivorGenerator.GenerateInitialSurvivors(); Timer.CreateTimer(gameObject, 0.05f, () => { EventSystem.Publish(new ModelsInitialisedEvent(false)); }); }
public void InitialiseNew() { List <CityBuildingModel> createdModels = new List <CityBuildingModel>(); foreach (CityBuildingSpawnSlot spawnSlot in SpawnSlots) { CityBuildingModel model = Instantiate(PrefabDictionary.GetRandomBuildingModelForSpawnSlot(spawnSlot).gameObject, transform).GetComponent <CityBuildingModel>(); model.RandomizeProperties(); model.RandomizeDanger(); model.transform.position = model.Location = spawnSlot.transform.position; model.transform.rotation = model.Rotation = spawnSlot.transform.rotation; createdModels.Add(model); } BuildingModels = createdModels.ToArray(); }
private void Awake() { Singleton = this; }