Advertisement
Guest User

Grid Map

a guest
Apr 19th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1.  
  2. //exchange this with the current method of version 1.0
  3.  public void initTestMap(Vector3 mapSize, MapPosToPrefab function, Vector3 tileSize) {
  4.         this.tiles = new Tile[(int)mapSize.x* (int)mapSize.y* ((int)mapSize.z + 1)];
  5.         this.mapSize = mapSize;
  6.         this.tileSize = tileSize;
  7.         for (int i = 0; i < (int)mapSize.x; i++) {
  8.             for (int j = 0; j < (int)mapSize.y; j++) {
  9.                 for (int k = 0; k < (int)mapSize.z; k++) {
  10.                     Tile functionTile = function(i,j,k);
  11.                     if(functionTile != null) {
  12.                         GameObject go =(GameObject) GameObject.Instantiate(functionTile.gameObject, Vector3.zero, Quaternion.identity);
  13.                         Tile t = go.GetComponent<Tile>();
  14.                         t.Position = Vector3.Scale(new Vector3(i,j,k), tileSize);
  15.                         go.name = "tile_" + i + j + k;
  16.                         this[i, j, k] = t;
  17.                     }
  18.                 }
  19.             }
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement