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());
            });
        }
Exemple #2
0
        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));
            });
        }
Exemple #3
0
        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();
        }
Exemple #4
0
 private void Awake()
 {
     Singleton = this;
 }