예제 #1
0
 /// <summary>
 /// Generate a map with defined size an random terrain types
 /// </summary>
 void GenerateRandomMapData()
 {
     mapTiles = new TileModel[width][];
     for (int x = 0; x < width; x++)
     {
         mapTiles[x] = new TileModel[height];
         for (int z = 0; z < height; z++)
         {
             Array                   values = Enum.GetValues(typeof(TileModel.TERRAIN_TYPES));
             System.Random           random = new System.Random();
             TileModel.TERRAIN_TYPES tT     = (TileModel.TERRAIN_TYPES)values.GetValue(random.Next(values.Length));
             TileModel               tile   = new TileModel(tT, textureVersion);
             mapTiles[x][z] = tile;
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Get the TileModel.TERRAIN_TYPES of the color hex code
 /// </summary>
 /// <param name="hex">The color hex code of the tile</param>
 /// <returns>The TileModel.TERRAIN_TYPES out of the dictionary</returns>
 public TileModel.TERRAIN_TYPES getTerrainType(string hex)
 {
     TileModel.TERRAIN_TYPES value = TileModel.TERRAIN_TYPES.EMPTY; // Default value if key doesn't exist
     terrainTypeMap.TryGetValue(hex, out value);
     return(value);
 }