private bool TryAddNonStandardTiles(MapTile tile, Point location) { // ReSharper disable once SwitchStatementMissingSomeCases (cases are covered elsewhere) switch (tile) { case MapTile.Key: Items.Add(new Key(location, this)); break; case MapTile.Compass: Items.Add(new Compass(location)); break; case MapTile.Map: Items.Add(new Map(location)); break; case MapTile.Bow: Items.Add(new BowItem(location, Secondary.Bow, 10)); break; case MapTile.Triforce: Items.Add(new Triforce(location)); break; case MapTile.PushableBlock: var pushableBlock = new MovableBlock(location); Collidables.Add(pushableBlock); Drawables.Add(pushableBlock); TransitionResetables.Add(pushableBlock); break; case MapTile.SpawnEnemy: SpawnTiles.Add(location); break; case MapTile.Sand: Drawables.Add(new Overlay(location, BlockType.Sand)); break; case MapTile.Heart: Items.Add(new HeartContainer(location, this)); break; case MapTile.Boomerang: Items.Add(new BoomerangItem(location, this, 20)); break; case MapTile.BasementBricks: case MapTile.BlackOverlay: case MapTile.None: case MapTile.Room2_1Block: break; default: return(false); } return(true); }
public Tile[,,] ReadMap(Transform parentContainer) { Size = Vector3Int.one * -1; Bounds mapBounds = new Bounds(); foreach (Transform t in parentContainer) { Tile tile = t.GetComponent <Tile>(); if (tile != null) { mapBounds.Encapsulate(tile.position); } } Size = mapBounds.size.Round() + Vector3Int.one; Vector3Int offset = mapBounds.min.Round(); Tile[,,] tiles = new Tile[Size.x, Size.y, Size.z]; foreach (Transform t in parentContainer) { Tile tile = t.GetComponent <Tile>(); if (tile != null) { Vector3Int pos = tile.position - offset; tiles[pos.x, pos.y, pos.z] = tile; switch (tile.Type) { case Tile.TileType.SpawnPoint: SpawnTiles.Add((SpawnTile)tile); break; case Tile.TileType.Item: ItemTiles.Add((ItemTile)tile); break; } } } return(tiles); }