示例#1
0
    public void initTestMap(Vector3 mapSize, MapPosToPrefab function, Vector3 tileSize) {
        this.tiles = new Tile[(int)mapSize.x* (int)mapSize.y* ((int)mapSize.z + 1)];
        this.mapSize = mapSize;
        this.tileSize = tileSize;
        for (int i = 0; i < (int)mapSize.x; i++) {
            for (int j = 0; j < (int)mapSize.y; j++) {
                for (int k = 0; k < (int)mapSize.z; k++) {
					Tile functionTile = function(i,j,k);
					if(functionTile != null) {
	                    GameObject go =(GameObject) GameObject.Instantiate(functionTile.gameObject, Vector3.zero, Quaternion.identity);
	                    Tile t = go.GetComponent<Tile>();
	                    t.Position = Vector3.Scale(new Vector3(i,j,k), tileSize);
	                    go.name = "tile_" + i + j + k;
	                    this[i, j, k] = t;
					}
                }
            }
        }
    }
示例#2
0
 public void initTestMap(Vector3 mapSize, MapPosToPrefab function, Vector3 tileSize)
 {
     this.tiles    = new Tile[(int)mapSize.x * (int)mapSize.y * ((int)mapSize.z + 1)];
     this.mapSize  = mapSize;
     this.tileSize = tileSize;
     for (int i = 0; i < (int)mapSize.x; i++)
     {
         for (int j = 0; j < (int)mapSize.y; j++)
         {
             for (int k = 0; k < (int)mapSize.z; k++)
             {
                 Tile functionTile = function(i, j, k);
                 if (functionTile != null)
                 {
                     GameObject go = (GameObject)GameObject.Instantiate(functionTile.gameObject, Vector3.zero, Quaternion.identity);
                     Tile       t  = go.GetComponent <Tile>();
                     t.Position    = Vector3.Scale(new Vector3(i, j, k), tileSize);
                     go.name       = "tile_" + i + j + k;
                     this[i, j, k] = t;
                 }
             }
         }
     }
 }