private void readMapTexture() { Color[] pixels = mapTexture.GetPixels(0, 0, mapTexture.width, mapTexture.height); for (int y = 0; y < mapTexture.height; y++) { for (int x = 0; x < mapTexture.width; x++) { Color c = pixels [(y * mapTexture.width) + x]; GameObject tile = new GameObject(); tile.transform.position = new Vector3(x, y); tile.transform.SetParent(tile_dump.transform); if (c == Color.black) { WallTiles.Add(tile); tile.name = "Wall"; } else if (c == Color.blue) { StartTilesTeam1.Add(tile); tile.name = "Team 1"; } else if (c == Color.green) { StartTilesTeam2.Add(tile); tile.name = "Team 2"; } else { Tiles.Add(tile); tile.name = "Walkable"; } } } }
//Placeholder for tilecreation private void PlaceTile(int x, int y, Vector3 worldStart, int type) { GameObject newTile = Instantiate(tilePrefabs[type]); Vector3 tilePosition = new Vector3(worldStart.x + TileSize / 2 + (TileSize * x), worldStart.y - TileSize / 2 - (TileSize * y)); newTile.transform.position = tilePosition; // differentiate playing field-stadium if (type == 0 || type == 2) { Tiles.Add(newTile); } if (type == 2) { if (y > MaxYTiles / 2) { StartTilesTeam1.Add(newTile); } else { StartTilesTeam2.Add(newTile); } } if (type == 3) { WallTiles.Add(newTile); } }