private void Awake() { // Find the tilemap game object and cache the behaviour. m_tileMap = GameObject.Find("TileMap").GetComponent <TileMapBehaviour>(); if (m_tileMap == null) { Debug.LogError("TileMapBehaviour not found"); return; } // Rather than hardcode the resolution of a tile, use the size of the first sprite. var tileSheet = m_tileMap.TileSheet; if (tileSheet.Count == 0) { Debug.LogError("Add some sprites before running the game"); return; } var spriteSize = tileSheet.Get(0).rect; // Define and apply the settings for the tilemap. var settings = new TileMeshSettings(SizeX, SizeY, (int)spriteSize.width); m_tileMap.MeshSettings = settings; // Map type of tile to sprite m_tiles = new TileEnumMapper <TileType>(m_tileMap); m_tiles.Map(TileType.Wall, "Wall2"); m_tiles.Map(TileType.Floor, "Floor"); m_tiles.Map(TileType.StairsUp, "StairsUp"); m_tiles.Map(TileType.StairsDown, "StairsDown"); }
private void Awake() { // Find the tilemap game object and cache the behaviour. m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>(); if (m_tileMap == null) { Debug.LogError("TileMapBehaviour not found"); return; } // Rather than hardcode the resolution of a tile, use the size of the first sprite. var tileSheet = m_tileMap.TileSheet; if (tileSheet.Count == 0) { Debug.LogError("Add some sprites before running the game"); return; } var spriteSize = tileSheet.Get(0).rect; // Define and apply the settings for the tilemap. var settings = new TileMeshSettings(SizeX, SizeY, (int)spriteSize.width); m_tileMap.MeshSettings = settings; // Map type of tile to sprite m_tiles = new TileEnumMapper<TileType>(m_tileMap); m_tiles.Map(TileType.Wall, "Wall2"); m_tiles.Map(TileType.Floor, "Floor"); m_tiles.Map(TileType.StairsUp, "StairsUp"); m_tiles.Map(TileType.StairsDown, "StairsDown"); }
[UsedImplicitly] private void Awake () { self = this; // Parse and load a map into cache. FileParser.LoadFromFile (_map); // Find the tilemap game object and cache the behaviour. _tileMap = GameObject.Find ("TileMap").GetComponent<TileMap>(); if (_tileMap == null) { Debug.LogError ("TileMapBehaviour not found."); return; } TileSheet tileSheet = _tileMap.TileSheet; if (tileSheet.Count == 0) { Debug.LogError ("Add some sprites before running the game."); return; } Sprite sprite = tileSheet.Get (1); _tileMap.MeshSettings = new TileMeshSettings (new IVector2 (FileParser.Width, FileParser.Height), (int)sprite.rect.width); // Map type of tile to sprite _tiles = new TileEnumMapper<TileType> (_tileMap); _tiles.Map (TileType.OUT_BOUNDS, "OutOfBound"); _tiles.Map (TileType.GRASS, "NormalGrass"); _tiles.Map (TileType.SWAMP, "SwampGrass"); _tiles.Map (TileType.WATER, "ShallowWater"); }
private void Awake() { // Find the tilemap game object and cache the behaviour. m_tileMap = GameObject.Find("TileMap").GetComponent<TileMapBehaviour>(); if (m_tileMap == null) { Debug.LogError("TileMapBehaviour not found"); return; } itens = GameObject.Find("Itens"); if (itens == null) { Debug.LogError("itens not found"); return; } blocks = GameObject.Find("Blocks"); if (blocks == null) { Debug.LogError("blocks not found"); return; } mapPrefab= GameObject.Find("Map"); if (mapPrefab == null) { Debug.LogError("Map not found"); return; } enemies = GameObject.Find ("Enemies"); if (enemies == null) { Debug.LogError("Enemies not found"); return; } tmx_map = GameObject.Find ("TMX - MAP"); if (enemies == null) { Debug.LogError("tmx map not found"); return; } // Rather than hardcode the resolution of a tile, use the size of the first sprite. var tileSheet = m_tileMap.TileSheet; if (tileSheet.Count == 0) { Debug.LogError("Add some sprites before running the game"); return; } var spriteSize = tileSheet.Get(0).rect; // Define and apply the settings for the tilemap. var settings = new TileMeshSettings(SizeX, SizeY, (int)spriteSize.width); m_tileMap.MeshSettings = settings; // Map type of tile to sprite m_tiles = new TileEnumMapper<TileType>(m_tileMap); m_tiles.Map(TileType.Wall, "Wall2"); m_tiles.Map(TileType.Floor, "Floor"); m_tiles.Map(TileType.Totem, "Totem"); m_tiles.Map(TileType.Totem1, "Totem1"); m_tiles.Map(TileType.Totem2, "Totem2"); m_tiles.Map(TileType.ALWAYS_CLOSED_DOOR, "ALWAYS_CLOSED_DOOR"); m_tiles.Map(TileType.ALWAYS_OPEN_DOOR, "ALWAYS_OPEN_DOOR"); m_tiles.Map(TileType.LOCALLY_CLOSED_DOOR, "LOCALLY_CLOSED_DOOR"); m_tiles.Map(TileType.KEY_RECQUIRING_DOOR, "KEY_RECQUIRING_DOOR"); m_tiles.Map(TileType.GEM, "GEM"); m_tiles.Map(TileType.BIG_CRYSTAL, "BIG_CRYSTAL"); m_tiles.Map(TileType.SMALL_CRYSTAL, "SMALL_CRYSTAL"); m_tiles.Map(TileType.CLIPPING, "CLIPPING"); m_tiles.Map(TileType.ONE_HP_REFILL, "ONE_HP_REFILL"); m_tiles.Map(TileType.ENEMY_INSTANCE, "ENEMY_INSTANCE"); m_tiles.Map(TileType.COLLECTIBLE_INSTANCE, "COLLECTIBLE_INSTANCE"); m_tiles.Map(TileType.KEY, "KEY"); }