public void DisableWeatherSystem(ManagedWeatherSystem weather) { for (int i = 0; i < weatherSystems.Length; ++i) { var weatherSystem = weatherSystems [i]; if (weatherSystem == weather) { EnableWeather(i, -1); break; } } }
public void EnableWeatherSystem(ManagedWeatherSystem weather) { for (int i = 0; i < weatherSystems.Length; ++i) { var weatherSystem = weatherSystems [i]; if (weatherSystem == null) { weatherSystems [i] = weather; EnableWeather(i, weather.weatherIndex); break; } else if (weatherSystem == weather) { break; } } }
public void UpdateMainWeather() { var pos = Camera.main.transform.position; var dir = Camera.main.transform.forward * 1000; ManagedWeatherSystem mainWeather = mainWeatherSystem == null?weatherSystems[0]:mainWeatherSystem; float minDistance = float.MaxValue; ManagedWeatherSystem weatherSystem; float distance = float.MaxValue; Vector3 interectPoint; for (int i = 0; i < weatherSystems.Length; ++i) { weatherSystem = weatherSystems [i]; if (weatherSystem != null && weatherSystem.gameObject.activeInHierarchy) { if (MathUtility.GetInterectPoint(weatherSystem.influenceArea, pos, dir, out interectPoint)) { distance = (pos - interectPoint).magnitude; } if (distance < minDistance) { if (mainWeather != null && mainWeather != weatherSystem) { mainWeather.isMainWeather = false; } minDistance = distance; mainWeather = weatherSystem; } else { weatherSystem.isMainWeather = false; } } } if (mainWeather != null) { mainWeather.isMainWeather = true; } mainWeatherSystem = mainWeather; skySystem.Update(mainWeatherSystem); }
void LateUpdate() { ManagedWeatherSystem.UpdateWeatherVaribles(false); }