static public void PushTile(Tile_custom t) { // Remove the Tile from MAP_TILES if necessary if (t.x >= 0 && t.x < S.w && t.y >= 0 && t.y < S.h) { if (MAP_TILES[t.x, t.y] == t) { MAP_TILES[t.x, t.y] = null; } } t.gameObject.SetActive(false); TILE_POOL.Add(t); }
static public Tile_custom GetTile() { int n = TILE_POOL.Count - 1; // If the pool is empty, create a new Tile if (n < 0) { GameObject go = Instantiate <GameObject>(S.tilePrefab); go.transform.SetParent(S.mapAnchor, true); go.SetActive(false); return(go.GetComponent <Tile_custom>()); } Tile_custom t = TILE_POOL[n]; TILE_POOL.RemoveAt(n); return(t); }