public void Execute(TaskComplete callback) { // Find all the matches we can to various weathers var match = WeatherUtils.OrderedMatches(phrase); // Debugging why we picked X if (debug) { Debug.Log(""); Debug.Log("------ WEATHER CHOICE DEBUG ------"); Debug.Log("found " + match.Count + " possible weather matches..."); foreach (var m in match) { m.Debug(); } } // Select best match~ selected = match.Count > 0 ? match[0] : null; var selectedId = match.Count > 0 ? match[0].weather.weather : WeatherId.FINE; // Update symbol phrase phrase.weather = selectedId; phrase.weatherPrefab = WeatherUtils.WeatherPrefab(phrase.weather); if (debug) { Debug.Log(string.Format("Pick weather for phrase: {0}", selected)); Debug.Log(""); } // Done~ if (callback != null) { callback(this); } }
/// Return a sorted by best-match list of WeatherDelta's public static List<WeatherDelta> OrderedMatches(SymbolPhrase phrase) { var rtn = new List<WeatherDelta>(); foreach (var pattern in Scene.FindComponents<KnownWeatherPattern>()) { var match = new WeatherDelta(phrase, pattern); rtn.Add(match); } rtn = rtn.OrderBy(o => o.match).ToList(); rtn.Reverse(); return rtn; }
public void UpdateState(WeatherDelta newWeather) { // Update shader state var wind = minWind + newWeather.normalized.wind * (maxWind - minWind); UpdateShaderState(wind); // Get a delta between current weather and targets weather var delta = targetWeather.Delta(newWeather.weather.detail); Debug.Log("Request: " + targetWeather.Debug()); Debug.Log("Weather: " + newWeather.weather.detail.Debug()); Debug.Log("------> VALUE: " + delta + " vs THREASHOLD " + matchThreshold); if (delta < matchThreshold) { UpdateAnimationState(true); PickRandomWeatherTarget(); } else { UpdateAnimationState(false); } }
public UpdatePlantsWithNewWeather(WeatherDelta delta) { this.delta = delta; }