/// <summary> /// Called to create the tile map. /// </summary> public void InitializeMap(MapTraits.GridRotation rotation, int tileLength, int tileWidth, int tileHeight) { if (!initialized) { setRotation(rotation); setGridPosition(tileLength, tileWidth, tileHeight); tileMap = new Tile[length, width]; if (bumpMap != null) { bumpMap.initializeBumpMap(); } for (int i = 0; i < length; i++) { for (int j = 0; j < width; j++) { if (bumpMap != null) { if (bumpMap.checkValidMap(length, width)) { if (bumpMap.checkBump(i, j) != MapTraits.TileType.None) { tileMap[i, j] = Instantiate(display, new Vector3(i + tileLength, tileHeight, j + tileWidth), Quaternion.identity).AddComponent <Tile>(); tileMap[i, j].setPosition(i + tileLength, j + tileWidth, tileHeight); tileMap[i, j].setDisplay(display, bumpMap.checkBump(i, j)); tileMap[i, j].transform.parent = transform; setGridEnd(tileMap[i, j]); } else { } } else { tileMap[i, j] = Instantiate(display, new Vector3(i + tileLength, tileHeight, j + tileWidth), Quaternion.identity).AddComponent <Tile>(); tileMap[i, j].setPosition(i + tileLength, j + tileWidth, tileHeight); tileMap[i, j].setDisplay(display); tileMap[i, j].transform.parent = transform; setGridEnd(tileMap[i, j]); } } else { tileMap[i, j] = Instantiate(display, new Vector3(i + tileLength, tileHeight, j + tileWidth), Quaternion.identity).AddComponent <Tile>(); tileMap[i, j].setPosition(i + tileLength, j + tileWidth, tileHeight); tileMap[i, j].setDisplay(display); tileMap[i, j].transform.parent = transform; setGridEnd(tileMap[i, j]); } } } setOrigin(tileMap[0, 0]); initialized = true; transform.rotation = myRotation; } }
/// <summary> /// Called to create the tile map. /// </summary> public void InitializeMap(MapTraits.GridRotation rotation, int tileWidth, int tileLength, int tileHeight, MapGenerator parent, TileMap newMap) { if (!initialized) { myParent = parent; myTileMap = newMap; setRotation(rotation); setGridPosition(tileWidth, tileLength, tileHeight); tileMap = new Tile[width, length]; int count = -1; if (bumpMap != null) { bumpMap.initializeBumpMap(); } for (int i = 0; i < width; i++) { for (int j = 0; j < length; j++) { count++; if (bumpMap != null) { if (bumpMap.checkValidMap(width, length)) { if (bumpMap.checkBump(i, j) != MapTraits.TileType.None) { tileMap[i, j] = Instantiate(rendered, new Vector3(i + tileWidth, tileHeight, j + tileLength), Quaternion.identity).AddComponent <Tile>(); tileMap[i, j].name = count.ToString(); tileMap[i, j].setPosition(i + tileWidth, j + tileLength, tileHeight, this); tileMap[i, j].setDisplay(display, bumpMap.checkBump(i, j)); newMap.addTile(tileMap[i, j]); tileMap[i, j].transform.parent = transform; setGridEnd(tileMap[i, j]); } else { } } else { tileMap[i, j] = Instantiate(rendered, new Vector3(i + tileWidth, tileHeight, j + tileLength), Quaternion.identity).AddComponent <Tile>(); tileMap[i, j].name = count.ToString(); tileMap[i, j].setPosition(i + tileWidth, j + tileLength, tileHeight, this); tileMap[i, j].setDisplay(display); newMap.addTile(tileMap[i, j]); tileMap[i, j].transform.parent = transform; setGridEnd(tileMap[i, j]); } } else { tileMap[i, j] = Instantiate(rendered, new Vector3(i + tileWidth, tileHeight, j + tileLength), Quaternion.identity).AddComponent <Tile>(); tileMap[i, j].name = count.ToString(); tileMap[i, j].setPosition(i + tileWidth, j + tileLength, tileHeight, this); tileMap[i, j].setDisplay(display); newMap.addTile(tileMap[i, j]); tileMap[i, j].transform.parent = transform; setGridEnd(tileMap[i, j]); } } } setOrigin(tileMap[0, 0]); initialized = true; transform.rotation = myRotation; } }