/// <summary> /// This will set <see cref="Doors"/> and it will modify tilemap and set doors into correct places /// </summary> /// <param name="doorLocations"></param> public void SetDoors(DoorLocation doorLocations) { Doors = doorLocations; var floorTile = TilemapHelper.GetTile(TilemapHelper.TileType.TilemapGround); var wallTile = TilemapHelper.GetTile(TilemapHelper.TileType.TilemapWall); // TODO: There might be more efficient method to do this // Clear doors Tilemap.SetTile(new Vector3Int(9, 9, 0), wallTile); Tilemap.SetTile(new Vector3Int(17, 5, 0), wallTile); Tilemap.SetTile(new Vector3Int(9, 0, 0), wallTile); Tilemap.SetTile(new Vector3Int(0, 5, 0), wallTile); // If room has top door if (Doors.HasFlag(Room.DoorLocation.Top)) { Tilemap.SetTile(new Vector3Int(9, 9, 0), floorTile); } // If room has right door if (Doors.HasFlag(Room.DoorLocation.Right)) { Tilemap.SetTile(new Vector3Int(17, 5, 0), floorTile); } // If room has bottom door if (Doors.HasFlag(Room.DoorLocation.Bottom)) { Tilemap.SetTile(new Vector3Int(9, 0, 0), floorTile); } // If room has left door if (Doors.HasFlag(Room.DoorLocation.Left)) { Tilemap.SetTile(new Vector3Int(0, 5, 0), floorTile); } }
/// <summary> /// Gets door count /// </summary> /// <returns>Returns count of doors</returns> public int DoorCount() { int count = 0; foreach (DoorLocation d in Enum.GetValues(typeof(DoorLocation))) { if (d == DoorLocation.None) { continue; } if (Doors.HasFlag(d)) { count++; } } return(count); }