public void UpdateCollisionMapDebug(bool walls) { Tilemap debug = walls ? GameObject.Find("CollisionMap").GetComponent <Tilemap>() : GameObject.Find("PitCollisionMap").GetComponent <Tilemap>(); //Tilemap debug = GameObject.Find("CollisionMap").GetComponent<Tilemap>(); debug.ClearAllTiles(); for (int i = 0; i < CollisionMap.GetLength(0); i++) { for (int j = 0; j < CollisionMap.GetLength(1); j++) { int collisionIndex = CollisionMap[i, j]; if (walls && collisionIndex == 1) { debug.SetTile(new Vector3Int(Bounds.xMin + i, Bounds.yMin + j, 0), MapManager.Instance.selectedDungeonData.tileSet.FloorTiles.ElementAt(0).value); } else if (!walls && collisionIndex == 2) { Vector3Int pos = new Vector3Int(Bounds.xMin + i, Bounds.yMin + j, 0); debug.SetTile(pos, _pits.GetTile(pos)); //FloorTiles[0]); } } } }
private void ClearCollisionMaps() { GameObject.Find("CollisionMap").GetComponent <Tilemap>().ClearAllTiles(); GameObject.Find("PitCollisionMap").GetComponent <Tilemap>().ClearAllTiles(); CollisionMap = new int[CollisionMap.GetLength(0), CollisionMap.GetLength(1)]; }
public int GetCollisionIndex(int x, int y) { int i = x - Bounds.xMin; int j = y - Bounds.yMin; if (i < 0 || i >= CollisionMap.GetLength(0) || j < 0 || j >= CollisionMap.GetLength(1)) { return(-1); } return(CollisionMap[i, j]); }