private void EndWeatherEvent() { weatherEventType = (WeatherEventType)(-1); weatherEventActive = false; EnableEventScreen(false); Destroy(abstractWeatherEvent.gameObject); }
protected override void StartWeather(WeatherEventType type, WeatherEventData data) { if (enableOnEvent.Contains(type)) { Enable(); } }
protected virtual void StartWeather(WeatherEventType type, WeatherEventData data) { switch (type) { case WeatherEventType.Drought: OnDroughtStart(data); break; case WeatherEventType.HeavyRain: OnHeavyRainStart(data); break; case WeatherEventType.Earthquake: OnEarthQuakeStart(data); break; case WeatherEventType.Storm: OnStormStart(data); break; case WeatherEventType.GasWinning: OnGasWinningStart(data); break; case WeatherEventType.BuildingTunnels: OnBuildingTunnelsStart(data); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
public static AbstractWeatherEvent CreateInstance(WeatherEventType eventType, WeatherEventData weatherEventData) { GameObject gameObject = new GameObject(eventType.ToString()); AbstractWeatherEvent abstractWeatherEvent = AddWeatherComponent(eventType, gameObject); abstractWeatherEvent.WeatherEventData = weatherEventData; return(abstractWeatherEvent); }
private WeatherEventType GetRandomWeather() { IEnumerable <WeatherEventType> weatherEventTypes = availableWeather.Where(element => element != lastType); WeatherEventType randomItem = weatherEventTypes.GetRandomItem(); lastType = randomItem; return(randomItem); }
private void SetUI(WeatherEventType weatherEventType) { string typeKey = typeKeys[weatherEventType]; typeLabel.text = LanguageUtil.GetJsonString(typeKey); string infoKey = infoKeys[weatherEventType]; infoLabel.text = LanguageUtil.GetJsonString(infoKey); icon.sprite = weatherIcons[weatherEventType]; }
public void StartTimer(float timer, Action timerEnd, WeatherEventType weatherEventType) { transform.parent.gameObject.SetActive(true); circleTimer.fillAmount = 1; maxTimer = timer; this.timer = maxTimer; this.timerEnd = timerEnd; icon.sprite = weatherSprites[weatherEventType]; SetInfoButton(weatherEventType); }
private WeatherEventData GetData(WeatherEventType weatherEventType) { for (int i = 0; i < eventDataPerEventType.Count; i++) { if (eventDataPerEventType[i].Key == weatherEventType) { WeatherEventData data = eventDataPerEventType[i].Value; abstractWeatherEvent = WeatherEventInstanceCreator.CreateInstance(weatherEventType, data); return(data); } } throw new NullReferenceException("No Data found for " + weatherEventType); }
private void LoadData() { GameData gameData = UserSettings.GameData; weatherEventType = gameData.WeatherEventType; if (weatherEventType == (WeatherEventType)(-1)) { return; } weatherEventData = GetData(weatherEventType); weatherEventTimer.StartTimer(weatherEventData.Timer, EndWeatherEvent, weatherEventType); weatherEventTimer.Timer = gameData.TimerWeatherEvent; weatherEventActive = true; EventManager.Instance.RaiseEvent(new StartWeatherEvent(abstractWeatherEvent, false)); }
private void TimerToNextWeatherEvent() { timerTillNextEvent -= Time.unscaledDeltaTime; if (timerTillNextEvent <= 0.0f && !PowerUpManager.Instance.AvoidWeatherActive) { if (TimeManager.Instance.IsPaused() || TutorialManager.IsActive) { return; } weatherEventType = GetRandomWeather(); weatherEventData = GetData(weatherEventType); EventManager.Instance.RaiseEvent(new StartWeatherEvent(abstractWeatherEvent)); weatherEventTimer.StartTimer(weatherEventData.Timer, EndWeatherEvent, weatherEventType); EnableEventScreen(true); weatherEventActive = true; timerTillNextEvent = Random.Range(minTime, maxTime); } }
private static AbstractWeatherEvent AddWeatherComponent(WeatherEventType type, GameObject gameObject) { AbstractWeatherEvent abstractWeatherEvent; switch (type) { case WeatherEventType.Drought: abstractWeatherEvent = gameObject.AddComponent <Drought>(); break; case WeatherEventType.HeavyRain: abstractWeatherEvent = gameObject.AddComponent <HeavyRain>(); break; case WeatherEventType.Earthquake: abstractWeatherEvent = gameObject.AddComponent <Earthquake>(); break; case WeatherEventType.Storm: abstractWeatherEvent = gameObject.AddComponent <Storm>(); break; case WeatherEventType.GasWinning: abstractWeatherEvent = gameObject.AddComponent <GasWinning>(); break; case WeatherEventType.BuildingTunnels: abstractWeatherEvent = gameObject.AddComponent <BuildingTunnels>(); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return(abstractWeatherEvent); }
protected override void StartWeather(WeatherEventType type, WeatherEventData data) { SetMaterialSettings(weatherSettings[type]); }
protected override void StartWeather(WeatherEventType type, WeatherEventData data) { StopBackgroundMusic(); base.StartWeather(type, data); }
public void EnablePopup(WeatherEventType weatherEventType) { CachedGameObject.SetActive(true); SetUI(weatherEventType); }