void handleGameModelLoaded(AbstractMessage message) { int galaxiesCount = gameModel.User.Galaxies.Count; if (galaxiesCount > 0) { for (int solarIndex = 0; solarIndex < galaxiesCount; solarIndex++) { GameObject solarPrefabInstance = Instantiate(solarPrefab, galaxy.transform); SolarComponent solar = solarPrefabInstance.GetComponent <SolarComponent>(); solar.Setup(gameModel.User.Galaxies[solarIndex]); } } }
private void handleCreateSolar(AbstractMessage message) { float SC = (message as SolarMessage).SC; float maxSC = (message as SolarMessage).maxSC; /**/ if (SC > gameModel.User.SC) { Debug.Log("Not enough SC to create Solar system!"); return; } Messenger.Dispatch(AtomMessage.SPEND_ATOMS, new AtomMessage(0, 0, SC)); /**/ SolarModel generatedSolarModel = SMM.GenerateSolar(SC); gameModel.User.Galaxies.Add(generatedSolarModel); GameObject solarPrefabInstance = Instantiate(solarPrefab, galaxy.transform); SolarComponent solar = solarPrefabInstance.GetComponent <SolarComponent>(); solar.Setup(generatedSolarModel); Messenger.Dispatch(SolarMessage.SOLAR_CREATED); }