/// Get the prefab symbol for a weather id public static GameObject WeatherPrefab(WeatherId id) { GameObject rtn = null; foreach (var cp in Scene.FindComponents<WeatherSymbolBinding>()) { if (cp.weatherId == id) { rtn = cp.weatherPrefab; } } return rtn; }
/// Return the ambient sound for a weatherId this is set on the associated WeatherSymbolBinding public static AudioClip AmbientSoundFor(WeatherId id) { AudioClip rtn = null; foreach (var cp in Scene.FindComponents<WeatherSymbolBinding>()) { if (cp.weatherId == id) { rtn = cp.ambientSound; } } return rtn; }
public void PickRandomWeatherTarget() { genNewTarget = false; var targets = WeatherUtils.KnownWeather(); KnownWeatherPattern new_target = null; for (var i = 0; i < 10; ++i) { new_target = Jam.Utils.Random.Pick(targets); if (new_target.weather != targetWeatherId) { break; } } if (new_target != null) { targetWeatherId = new_target.weather; targetWeather = new_target.detail; SpawnPrefabForTarget(); } }
public void TransitionTo(WeatherId newState) { if(transition != null) StopCoroutine(transition); transition = TransitionWeather(newState, currentWeather); StartCoroutine(transition); currentWeather = newState; }
void Awake() { currentWeather = defaultWeather; }
IEnumerator TransitionWeather(WeatherId newState, WeatherId oldState) { float t = 0; float startDensity = cloudDensity; float startWind = windSpeed; Color startCloudColour = cloudColour; Color startFogColour = fogColour; Color startSunColour = sunColour; WeatherState cState = stateInfo.weatherStates[(int)newState]; skydome.SetWindSpeed(cState.windSpeed); ToggleSnow(cState.snowing); ToggleRain(cState.raining); if (newState == WeatherId.STORM) ToggleLightning(true); else ToggleLightning(false); while (t < 1) { cloudDensity = Mathf.Lerp(startDensity, cState.cloudDensity, t); skydome.SetCloudDensity(cloudDensity); windSpeed = Mathf.Lerp(startWind, cState.windSpeed, t); skydome.SetWindSpeed(windSpeed); cloudColour = Color.Lerp(startCloudColour, cState.cloudTint, t); skydome.SetCloudColor(cloudColour); fogColour = Color.Lerp(startFogColour, cState.fogColour, t); RenderSettings.fogColor = fogColour; //TODO fog density sunColour = Color.Lerp(startSunColour, cState.lightColour, t); sun.color = sunColour; if (raining) { rainParticles.startColor = new Color(1, 1, 1, t); } if (snowing) { snowParticles.startColor = new Color(1, 1, 1, t); } t += Time.deltaTime / transitionTime; yield return null; } }
/// Clear this phrase public void Clear() { symbols.Clear(); weather = WeatherId.FINE; }