IEnumerator ChooseWeather() { while (canChange) { int randomNum = Random.Range(0, 100); int cumulative = 0; for (int i = 0; i < (weatherConditions.Count); i++) { cumulative += weatherConditions[i].weatherChance; if (randomNum < cumulative) { currentWeather = weatherConditions[i]; anim.SetTrigger(animParameters[i]); ChangeWeather(i); break; } } int waitTime = Random.Range(currentWeather.weatherTimeMin, currentWeather.weatherTimeMax); yield return(new WaitForSeconds(waitTime)); } }
public void ChangeWeather(int weatherIndex) { currentWeather = weatherConditions[weatherIndex]; GetComponent <DisplayUIImage>().Display(currentWeather.icon); }