Esempio n. 1
0
  private static void ApplyPhrase(Age.TerrainChunk map, Phrase phrase) {
    // Let param changing adjectives have their turn

    ChunkParameters parms = new ChunkParameters();

    parms.targetRadius = 0.5f;
    parms.targetHeight = 0.5f;
    parms.world = map;

    // Default location
    int x = map.GetWidth() / 2;
    int y = map.GetHeight() / 2;

    foreach (Adjective adjective in phrase.adjectives) {
      adjective.MutateParameters(parms);
    }

    Age.TerrainPoint[] points = new Age.TerrainPoint[]{new Age.TerrainPoint(x, y)};
    if (phrase.location != null) {
      points = phrase.location.GetPoints(parms);
    }
    foreach (Age.TerrainPoint point in points) {
      Age.TerrainChunk chunk = phrase.feature.GetChunk(parms);
      foreach (Adjective adjective in phrase.adjectives) {
        if (adjective.adverbDelegate == null) {
          adjective.MutateChunk(chunk, parms);
        } else {
          adjective.adverbDelegate.MutateChunk(chunk, parms);
        }
      }
      int px = point.x - chunk.GetWidth() / 2;
      int py = point.y - chunk.GetHeight() / 2;
      map.AddChunk(chunk, px, py, parms.addMode); 
    }
  }
Esempio n. 2
0
 override public Age.TerrainPoint[] GetPoints(ChunkParameters parms) {
   int max = (int)(this.quantity * 25);
   Age.TerrainPoint[] output = new Age.TerrainPoint[max];
   for (int n = 0; n < max; n++) {
     float x = (parms.world.GetWidth() / 2) + (Random.value - 0.5f) * (parms.world.GetWidth() * this.quantity / 2);
     float y = (parms.world.GetHeight() / 2) + (Random.value - 0.5f) * (parms.world.GetHeight() * this.quantity / 2);
     output[n] = new Age.TerrainPoint((int)(x), (int)(y));
   }
   return output;
 }