Ejemplo n.º 1
0
        private void MeasureNeigbors(Dictionary <Centers, Centers> camefrom, Dictionary <Centers, int> costsofar, Centers cnt, CenterMapData mapdata, Centers othernode, Centers current, Centers next)
        {
            var nextdata = next.mapData;
            var new_cost = costsofar[current] + nextdata.Biome.MovementCost();

            if (!costsofar.TryGetValue(next, out var x) || new_cost < costsofar[next])
            {
                costsofar[next] = new_cost;
                var priority = new_cost + heuristic(othernode.center, next.center);
                frontier.Enqueue(new FastTownNode(next, new_cost), priority * 10);
                camefrom[next] = current;
                mapdata.Villiage.AddTownToList(costsofar[next], next, camefrom);
                next.mapData.Villiage.AddTownToListReversed(costsofar[next], cnt, camefrom);
            }
        }
Ejemplo n.º 2
0
 public IBiomes getBiome(CenterMapData cnt)
 {
     if (cnt.Ocean)
     {
         return(new Ocean());
     }
     else if (cnt.Water)
     {
         if (cnt.Elevation < 0.1)
         {
             return(new Marsh());
         }
         if (cnt.Elevation > 0.8)
         {
             return(new Ice());
         }
         return(new Lake());
     }
     else if (cnt.Coast)
     {
         return(new Beach());
     }
     else if (cnt.Elevation > 0.8)
     {
         if (cnt.Moisture > 0.50)
         {
             return(new Snow());
         }
         else if (cnt.Moisture > 0.33)
         {
             return(new Tundra());
         }
         else if (cnt.Moisture > 0.16)
         {
             return(new Bare());
         }
         else
         {
             return(new Scorched());
         }
     }
     else if (cnt.Elevation > 0.6)
     {
         if (cnt.Moisture > 0.66)
         {
             return(new Taiga());
         }
         else if (cnt.Moisture > 0.33)
         {
             return(new Shrubland());
         }
         else
         {
             return(new Plains());
         }
     }
     else if (cnt.Elevation > 0.3)
     {
         if (cnt.Moisture > 0.83)
         {
             return(new TemperateRainForest());
         }
         else if (cnt.Moisture > 0.50)
         {
             return(new Forest());
         }
         else if (cnt.Moisture > 0.16)
         {
             return(new Grassland());
         }
         else
         {
             return(new Plains());
         }
     }
     else
     {
         if (cnt.Moisture > 0.66)
         {
             return(new TropicalRainForest());
         }
         else if (cnt.Moisture > 0.33)
         {
             return(new Forest());
         }
         else if (cnt.Moisture > 0.16)
         {
             return(new Grassland());
         }
         else
         {
             return(new Desert());
         }
     }
 }
Ejemplo n.º 3
0
        private void MeasureTownDistance(Dictionary <Centers, Centers> camefrom, Dictionary <Centers, int> costsofar, List <Centers> landlist, Centers cnt, CenterMapData mapdata, Centers othernode)
        {
            camefrom.Clear();
            costsofar.Clear();
            frontier.Clear();
            costsofar[cnt] = 0;
            frontier.Enqueue(new FastTownNode(cnt, 0), 0);
            while (frontier.Count != 0)
            {
                var currentnode = frontier.Dequeue();
                var current     = currentnode.cnt;
                if (current == othernode)
                {
                    break;
                }

                foreach (Centers next in current.neigbors)
                {
                    MeasureNeigbors(camefrom, costsofar, cnt, mapdata, othernode, current, next);
                }
            }
            mapdata.Villiage.AddTownToList(costsofar[othernode], othernode, camefrom);
            othernode.mapData.Villiage.AddTownToListReversed(costsofar[othernode], cnt, camefrom);
        }