private void Awake() { if (mapLib == null) { mapLib = this; //Bitmap bmp = new Bitmap(@"C:\Users\TwoTen512\Desktop\cs198\project3 beta\Project3DRW\KingOfTheCubes\KingOfTheCubes\proj3TEST\Assets\Resources\Bitmaps\Map 0.bmp"); //Texture2D t = Resources.Load("Bitmaps/Map 0") as Texture2D; //print(">>>" +t.GetPixel(0,0)); bitmaps = Resources.LoadAll <Texture2D>("Bitmaps"); InstantiateMovingTiles(); InstantiateColorToTileMapping(); InstantiateTeleportTiles(); } }
void Awake() { tileLib = GameObject.FindGameObjectWithTag("Library").GetComponent<TileLibrary>(); camCtrl = GetComponent<CameraController>(); act = MenuUpdate; mapLib = GameObject.FindGameObjectWithTag("Library").GetComponent<MapLibrary>(); }
void Awake() { gameCtrl = GetComponent<GameController>(); tileLib = GameObject.FindGameObjectWithTag("Library").GetComponent<TileLibrary>(); mapLib = GameObject.FindGameObjectWithTag("Library").GetComponent<MapLibrary>(); }
public void SpawnMap(int mapID, int playerCount) { Texture2D bitmap = MapLibrary.bitmaps[mapID]; width = bitmap.width; height = bitmap.height; int playerSpawn = 0; List <GameObject> tpTiles = new List <GameObject>(); List <GameObject> movingTiles = new List <GameObject>(); for (int y = 0; y < bitmap.height; y++) { for (int x = 0; x < bitmap.width; x++) { int k; Color32 c = bitmap.GetPixel(x, y);// *255; k = MapLibrary.ColorToTile(c); if (k % 2 == 0 && k > 0) { if (playerSpawn < 4) { playerSpawnPoints[playerSpawn].transform.position = transform.position + new Vector3(x * scaling, 0, -y * scaling); playerSpawn++; } k /= 2; } else if (k > 2) { k = (k + 1) / 2; } if (k > 0) { GameObject tile = Instantiate(tilePrefabs[k]); tile.transform.GetComponent <Tile>().tileID = (y * width) + x; tile.transform.SetParent(tilesHolder.transform); tile.transform.position = transform.position + new Vector3(x * scaling, 0, -y * scaling); if (k == 5) { tpTiles.Add(tile); } else if (k == 6) { movingTiles.Add(tile); tile.transform.position += new Vector3(0, 1.5f, 0); } } } } //print(bitmap.GetPixel(j, i) * 255); /* * for (int i = 0; i < dim; i++) * { * for (int j = 0; j < dim; j++) * { * int k; * if (i > dim / 2) * k = 0; * else * k = 1; * k = 0; * k = MapLibrary.maps25x25[mapID, i, j]; * if (k % 2 == 0 && k > 0) * { * if (playerSpawn < 4) * { * playerSpawnPoints[playerSpawn].transform.position = transform.position + new Vector3(j * 1.5f, 0, i * 1.5f); * playerSpawn++; * } * k /= 2; * } * else if (k > 2) * { * k = (k + 1) / 2; * } * GameObject tile = Instantiate(tilePrefabs[k]); * tile.transform.GetComponent<Tile>().tileID = (i * dim) + j; * tile.transform.SetParent(tilesHolder.transform); * tile.transform.position = transform.position + new Vector3(j * 1.5f, 0, i * 1.5f); * if (k == 5) * { * tpTiles.Add(tile); * } * } * }*/ List <int> tpTileMap = (List <int>)MapLibrary.teleportTiles[mapID]; if (tpTileMap != null) { for (int i = 0; i < tpTiles.Count; i++) { TeleportTile t = tpTiles[i].transform.GetComponent <TeleportTile>(); int rcver = tpTileMap[i]; if (rcver >= 0) { t.receiver = tpTiles[rcver]; tpTiles[rcver].transform.GetComponent <TeleportTile>().senders.Add(t.gameObject); } } } List <List <float> > destinations = (List <List <float> >)MapLibrary.movingTiles[mapID]; List <Vector3> sizes = (List <Vector3>)MapLibrary.movingTilesSizes[mapID]; if (destinations != null) { for (int i = 0; i < destinations.Count; i++) { MovingTile m = movingTiles[i].transform.GetComponent <MovingTile>(); m.destinations = new List <Vector3>(); m.transform.localScale = new Vector3(scaling * sizes[i].x, sizes[i].y, scaling * sizes[i].z); m.originalPosition = m.transform.position; List <float> coords = destinations[i]; for (int j = 0; j < coords.Count; j += 3) { float xScale = sizes[i].x, zScale = sizes[i].z, yScale = sizes[i].y; xScale--; yScale--; zScale--; Vector3 dest = m.originalPosition + new Vector3(coords[j], coords[j + 1], coords[j + 2]) * scaling + new Vector3(xScale, yScale, -zScale) * scaling / 2;; m.destinations.Add(dest); } } } transform.name = "Map " + (mapID + 1); for (int i = 0; i < 4; i++) { GameObject.Find("Player " + (i + 1)).transform.position = new Vector3(playerSpawnPoints [i].transform.position.x, 2, playerSpawnPoints [i].transform.position.z); } }