2026-05-07 06:29:34 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Tilemaps;
|
|
|
|
|
|
|
|
|
|
namespace Platformer.Mechanics
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 게임 시작 시 프레임·렌더·물리 영역 기본 최적화 + One-Way Platform 자동 적용.
|
|
|
|
|
/// PD 지시 2026-05-07 — 스크롤 버벅임 보완 + 점프·이동 시 지형 통과(One-Way Platform).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class GameOptimizer
|
|
|
|
|
{
|
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
|
|
|
|
static void Init()
|
|
|
|
|
{
|
|
|
|
|
Application.targetFrameRate = 60;
|
|
|
|
|
QualitySettings.vSyncCount = 0;
|
|
|
|
|
Time.fixedDeltaTime = 1f / 60f;
|
2026-05-07 07:09:54 +00:00
|
|
|
|
2026-05-07 08:49:58 +00:00
|
|
|
// BT5-Dev #34 — Layer Matrix 영역 = Player(13) ↔ Enemy(14)만 OFF. JumpThrough Layer 8 영역 폐기.
|
|
|
|
|
// OneWay = PlatformEffector2D 영역 표준 패턴 활용 (Layer Matrix 폐기)
|
2026-05-07 07:09:54 +00:00
|
|
|
Physics2D.IgnoreLayerCollision(13, 14, true);
|
2026-05-07 08:49:58 +00:00
|
|
|
Debug.Log($"[BT34-LayerSep] Player(13) ↔ Enemy(14) collision OFF (Layer 8 영역 폐기·PlatformEffector2D 영역 활용)");
|
2026-05-07 06:29:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-05-07 08:04:25 +00:00
|
|
|
/// BT5-Dev #27 — PD 제안: Layer 8(JumpThrough) + Raycast 동적 충돌.
|
|
|
|
|
/// PlatformEffector2D 폐기. 모든 일반 BoxCollider2D를 Layer 8로 변환 → 기본 통과 + Player 발 Raycast 시점만 충돌 활성.
|
|
|
|
|
/// 제외: Tilemap·Player·Enemy·DeathZone·VictoryZone·TokenInstance·AttackHitbox·Trigger Collider.
|
2026-05-07 06:29:34 +00:00
|
|
|
/// </summary>
|
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
2026-05-07 08:04:25 +00:00
|
|
|
static void SetupJumpThroughPlatforms()
|
2026-05-07 06:29:34 +00:00
|
|
|
{
|
2026-05-07 08:49:58 +00:00
|
|
|
// BT5-Dev #34 — Unity 표준 OneWay Platform = PlatformEffector2D + useOneWay + surfaceArc 180.
|
|
|
|
|
// 모든 일반 Collider(Tilemap 포함) PlatformEffector2D 적용. Layer 영역 무관 (기본 Layer 0 유지).
|
|
|
|
|
// 동작: 위에서 떨어지면 충돌(착지) / 옆·아래·점프 상승 시 통과
|
2026-05-07 08:04:25 +00:00
|
|
|
int applied = 0, excluded = 0;
|
2026-05-07 06:50:17 +00:00
|
|
|
var allColliders = Object.FindObjectsByType<Collider2D>(FindObjectsSortMode.None);
|
2026-05-07 07:00:40 +00:00
|
|
|
var appliedNames = new System.Collections.Generic.List<string>();
|
2026-05-07 06:50:17 +00:00
|
|
|
foreach (var c in allColliders)
|
2026-05-07 06:29:34 +00:00
|
|
|
{
|
2026-05-07 06:50:17 +00:00
|
|
|
if (c == null) continue;
|
2026-05-07 08:04:25 +00:00
|
|
|
if (c.isTrigger) { excluded++; continue; }
|
2026-05-07 07:00:40 +00:00
|
|
|
if (c.GetComponent<PlayerController>() != null
|
|
|
|
|
|| c.GetComponent<EnemyController>() != null
|
|
|
|
|
|| c.GetComponent<DeathZone>() != null
|
|
|
|
|
|| c.GetComponent<TokenInstance>() != null
|
|
|
|
|
|| c.GetComponent<VictoryZone>() != null
|
|
|
|
|
|| c.GetComponent<AttackHitbox>() != null)
|
|
|
|
|
{
|
2026-05-07 08:04:25 +00:00
|
|
|
excluded++;
|
2026-05-07 07:00:40 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2026-05-07 06:50:17 +00:00
|
|
|
|
2026-05-07 08:49:58 +00:00
|
|
|
// BT34 — Layer 8 변환 폐기 (Layer 0 유지) + PlatformEffector2D 영역 OneWay 적용
|
|
|
|
|
// BT31 영역 잔존 Layer 8 영역 → Layer 0 복원
|
|
|
|
|
if (c.gameObject.layer == 8) c.gameObject.layer = 0;
|
|
|
|
|
|
|
|
|
|
c.usedByEffector = true;
|
2026-05-07 06:29:34 +00:00
|
|
|
var effector = c.GetComponent<PlatformEffector2D>();
|
2026-05-07 08:49:58 +00:00
|
|
|
if (effector == null) effector = c.gameObject.AddComponent<PlatformEffector2D>();
|
|
|
|
|
effector.useOneWay = true;
|
|
|
|
|
effector.surfaceArc = 180f;
|
|
|
|
|
effector.rotationalOffset = 0f;
|
|
|
|
|
effector.useSideFriction = false;
|
|
|
|
|
effector.useSideBounce = false;
|
2026-05-07 06:50:17 +00:00
|
|
|
applied++;
|
2026-05-07 07:00:40 +00:00
|
|
|
if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}({c.GetType().Name})");
|
2026-05-07 06:29:34 +00:00
|
|
|
}
|
2026-05-07 08:49:58 +00:00
|
|
|
Debug.Log($"[BT34-OneWay] applied={applied} excluded={excluded} total={allColliders.Length}");
|
|
|
|
|
Debug.Log($"[BT34-OneWay] appliedSamples=[{string.Join(", ", appliedNames)}]");
|
2026-05-07 06:29:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|