示例#1
0
 public void changeWeatherChance(weatherTypes weather, int changeAmount)
 {
     chances[weather] += changeAmount;
     if (chances[weather] < 0)
     {
         chances[weather] = 0;
     }
 }
示例#2
0
    public void setWeatherChance(weatherTypes weather, int chance)
    {
        if (chance < 0)
        {
            chance = 0;
        }

        chances[weather] = chance;
    }
示例#3
0
    public weatherTypes getWeather(float temp)
    {
        int weightedChanceSum = 0;

        QueueDirectAccess <weatherTypes> allowedWeather = new QueueDirectAccess <weatherTypes>();

        allowedWeather.resize(weatherTypesCount);

        allowedWeather.enqueue(weatherTypes.PERFECT_WEATHER);
        weightedChanceSum += chances[weatherTypes.PERFECT_WEATHER];

        allowedWeather.enqueue(weatherTypes.SUNNY);
        weightedChanceSum += chances[weatherTypes.SUNNY];

        allowedWeather.enqueue(weatherTypes.CLOUDY);
        weightedChanceSum += chances[weatherTypes.CLOUDY];

        allowedWeather.enqueue(weatherTypes.SCARY_LIGHTNING);
        weightedChanceSum += chances[weatherTypes.SCARY_LIGHTNING];

        allowedWeather.enqueue(weatherTypes.HELLFIRE);
        weightedChanceSum += chances[weatherTypes.HELLFIRE];

        if (temp >= 20)
        {
            allowedWeather.enqueue(weatherTypes.SUPER_HOT);
            weightedChanceSum += chances[weatherTypes.SUPER_HOT];
        }

        if (temp > 0)
        {
            allowedWeather.enqueue(weatherTypes.RAIN);
            weightedChanceSum += chances[weatherTypes.RAIN];

            allowedWeather.enqueue(weatherTypes.ACID_RAIN);
            weightedChanceSum += chances[weatherTypes.ACID_RAIN];
        }
        else
        {
            allowedWeather.enqueue(weatherTypes.SNOW);
            weightedChanceSum += chances[weatherTypes.SNOW];
        }

        if (temp <= -20)
        {
            allowedWeather.enqueue(weatherTypes.BLIZZARD);
            weightedChanceSum += chances[weatherTypes.BLIZZARD];
        }

        int weatherPick = UnityEngine.Random.Range(0, weightedChanceSum);

        weatherTypes weather = allowedWeather[0];

        while (!allowedWeather.isEmpty() && weatherPick > chances[allowedWeather[0]])
        {
            weather      = allowedWeather.dequeue();
            weatherPick -= chances[weather];
        }

        if (!allowedWeather.isEmpty())
        {
            weather = allowedWeather.dequeue();
        }


        return(weather);
    }
示例#4
0
 public int getWeatherWeightedChance(weatherTypes weather)
 {
     return(chances[weather]);
 }