Beispiel #1
0
    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));
        }
    }
Beispiel #2
0
 public void ChangeWeather(int weatherIndex)
 {
     currentWeather = weatherConditions[weatherIndex];
     GetComponent <DisplayUIImage>().Display(currentWeather.icon);
 }