diff --git a/Assets/Scripts/Mechanics/GameOptimizer.cs b/Assets/Scripts/Mechanics/GameOptimizer.cs index 1ef373d..ce191e3 100644 --- a/Assets/Scripts/Mechanics/GameOptimizer.cs +++ b/Assets/Scripts/Mechanics/GameOptimizer.cs @@ -87,78 +87,17 @@ namespace Platformer.Mechanics // fgTc null 유지 = 사후 복원 영역(if fgTilemap!=null && fgTc!=null) 자동 skip } - // BT48 — Level → Foreground 자동 분류 강화. 분류 조건 2종 결합: - // (a) 임계값 위 (worldY >= playerY + 1.5) = 공중 = 무조건 Foreground (BT47 호환) - // (b) 임계값 아래여도 위·아래 인접 Tile이 모두 빈 공간 + 가로 연속 길이 8 tile 이하 = 작은 공중 발판 - // → 일반 지면(통상 10+ tile 가로) 잘못 분류 방지 + 첨부 이미지 같은 작은 발판 자동 분류 - var levelGo = GameObject.Find("Level"); - if (levelGo != null && fgTilemap != null) - { - var levelTilemap = levelGo.GetComponent(); - var player = Object.FindFirstObjectByType(); - if (levelTilemap != null && player != null) - { - float playerY = player.transform.position.y; - float airThresholdY = playerY + 1.5f; // Player 시작 Y + 1.5 위 = 공중 (BT47 호환) - const int MAX_PLATFORM_WIDTH = 8; - var bounds = levelTilemap.cellBounds; - int movedHigh = 0, movedSmall = 0; - for (int x = bounds.xMin; x <= bounds.xMax; x++) - { - for (int y = bounds.yMin; y <= bounds.yMax; y++) - { - var pos = new Vector3Int(x, y, 0); - if (!levelTilemap.HasTile(pos)) continue; - - // BT49 — Tile asset의 m_ColliderType=None = 배경 의도 (예: tree·cloud) = 자동 분류 제외 - var tileAsset = levelTilemap.GetTile(pos); - if (tileAsset != null && tileAsset.colliderType == UnityEngine.Tilemaps.Tile.ColliderType.None) continue; - - Vector3 worldPos = levelTilemap.CellToWorld(pos); - bool aboveThreshold = worldPos.y >= airThresholdY; - bool isSmallAir = !aboveThreshold && IsSmallAirPlatform(levelTilemap, pos, MAX_PLATFORM_WIDTH); - if (!aboveThreshold && !isSmallAir) continue; - var tile = levelTilemap.GetTile(pos); - // BT49 — Foreground 이동 시 Tile asset 원래 colliderType 존중 (None=배경, Sprite=발판) - var srcColliderType = (tileAsset != null) ? tileAsset.colliderType : UnityEngine.Tilemaps.Tile.ColliderType.Sprite; - fgTilemap.SetTile(pos, tile); - fgTilemap.SetColliderType(pos, srcColliderType); - levelTilemap.SetTile(pos, null); - if (aboveThreshold) movedHigh++; - else movedSmall++; - } - } - if (fgTc != null) fgTc.ProcessTilemapChanges(); - var lvlTc = levelGo.GetComponent(); - if (lvlTc != null) lvlTc.ProcessTilemapChanges(); - Debug.Log($"[BT48-MoveTiles] moved={movedHigh + movedSmall} (high={movedHigh} thresholdY={airThresholdY:F2} / smallAir={movedSmall} maxWidth={MAX_PLATFORM_WIDTH})"); - } - } - - // BT49 — Foreground Tilemap 자체에 이미 그려진 배경 Tile (예: tree·cloud — Tile asset colliderType=None) ColliderType=None 복원 - // BT47이 SetColliderType(Sprite) 무차별 강제 → 배경 Tile도 발판처럼 충돌 → Tile asset metadata 존중으로 정정 - if (fgTilemap != null && fgTc != null) - { - int restored = 0; - var fgBounds = fgTilemap.cellBounds; - for (int x = fgBounds.xMin; x <= fgBounds.xMax; x++) - { - for (int y = fgBounds.yMin; y <= fgBounds.yMax; y++) - { - var pos = new Vector3Int(x, y, 0); - if (!fgTilemap.HasTile(pos)) continue; - var fgTileAsset = fgTilemap.GetTile(pos); - if (fgTileAsset == null) continue; - if (fgTileAsset.colliderType == UnityEngine.Tilemaps.Tile.ColliderType.None) - { - fgTilemap.SetColliderType(pos, UnityEngine.Tilemaps.Tile.ColliderType.None); - restored++; - } - } - } - if (restored > 0) fgTc.ProcessTilemapChanges(); - Debug.Log($"[BT49-Background] Foreground tile colliderType=None restored: {restored} (배경 Tile 충돌 차단)"); - } + // BT60 — PD 의도 정합 정정 (2026-05-07 PD 보고: "발판 위에 올라갈 수 없게 되었어"). + // BT48/BT49 자동 분류 영역 폐기 — Level → Foreground 이동(SetTile(null))이 Level 발판 Tile 제거 → 영구 충돌 X 유발. + // 결과 (PD 의도 정합): + // - Level Tilemap = Scene yaml 그대로 유지 (영구 충돌·발판·지면 역할) + // - Foreground Tilemap = 시각만 (TilemapRenderer + Layer 16·TilemapCollider X) + // Player가 Level 지면 위 착지 ✅ (영구 충돌) + Foreground 영역 자유 통과 ✅ (충돌 X) + // + // (변경 전 BT48/BT49 자동 분류 영역 코드는 git history `9adfc64`(BT49)·`92f102e`(BT59)에 보존) + // IsSmallAirPlatform 헬퍼는 사용 X (dead code) — 본 메서드 종료 후 헬퍼 제거 별도 정리 권고. + // 사용 변수 unused 컴파일 경고 회피 + _ = fgTilemap; Debug.Log($"[BT48-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}"); Debug.Log($"[BT48-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]");