Ejemplo n.º 1
0
    // Create the habitat initialization counters
    private int[, ][] CreateInitHabCounters()
    {
        int[, ][] habitatTypeCounters = new int[WorldX, WorldZ][];
        int       index;
        string    wetness;
        string    temperateness;

        // Do this for twenty years
        for (int year = 0; year < 20; year++)
        {
            // Generate a new year
            TempAndRainNewYear();
            // Create arrays with the relevant data for calcluating the habitats
            for (int x = 0; x < WorldX; x++)
            {
                for (int z = 0; z < WorldZ; z++)
                {
                    // If the tile is 100% ocean initialize habitat counters to an empty array
                    if (oceanPer.worldArray[x, z] != 1f)
                    {
                        // initialize the habitattype counter with an empty array the first time round
                        if (year == 0)
                        {
                            habitatTypeCounters[x, z] = new int[13];
                        }
                        // Get the index of the expected habitat for each tile that year
                        wetness       = Habitat.DetermineWetness(rainfallTotal.worldArray[x, z] + River.AverageRiverLevel(x, z));
                        temperateness = Habitat.DetermineTemp(temps[x, z].Count70DegreeDays(), temps[x, z].Count32DegreeDays());
                        index         = Habitat.DetermineHabitatFavored(wetness, temperateness);
                        // Add a counter for that habitat to that tiles counter array
                        habitatTypeCounters[x, z][index] += 1;
                    }
                    else
                    {
                        if (year == 0)
                        {
                            habitatTypeCounters[x, z] = new int[13];
                        }
                    }
                }
            }
        }

        return(habitatTypeCounters);
    }
Ejemplo n.º 2
0
 // Updates the Habitat from year to year based on new data
 private void HabitatUpdate()
 {
     System.Random randy = new System.Random();
     for (int x = 0; x < WorldX; x++)
     {
         for (int z = 0; z < WorldZ; z++)
         {
             habitats.worldArray[x, z].UpdateHabitatYear(temps[x, z].Count70DegreeDays(), temps[x, z].Count32DegreeDays(), rainfallTotal.worldArray[x, z], River.AverageRiverLevel(x, z), River.surfaceSnow.AreAllZero(x, z), randy);
         }
     }
 }