69 lines
3.4 KiB
C#
69 lines
3.4 KiB
C#
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;
|
|
|
|
// BT5-Dev #22 — Player(13) ↔ Enemy(14) 충돌 영구 OFF
|
|
Physics2D.IgnoreLayerCollision(13, 14, true);
|
|
// BT5-Dev #27 — Player(13) ↔ JumpThrough(8) 충돌 기본 OFF (Raycast 시점만 동적 활성)
|
|
Physics2D.IgnoreLayerCollision(13, 8, true);
|
|
Debug.Log($"[BT27-LayerSep] Player(13) ↔ Enemy(14)·JumpThrough(8) collision OFF");
|
|
}
|
|
|
|
/// <summary>
|
|
/// BT5-Dev #27 — PD 제안: Layer 8(JumpThrough) + Raycast 동적 충돌.
|
|
/// PlatformEffector2D 폐기. 모든 일반 BoxCollider2D를 Layer 8로 변환 → 기본 통과 + Player 발 Raycast 시점만 충돌 활성.
|
|
/// 제외: Tilemap·Player·Enemy·DeathZone·VictoryZone·TokenInstance·AttackHitbox·Trigger Collider.
|
|
/// </summary>
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
|
static void SetupJumpThroughPlatforms()
|
|
{
|
|
// BT5-Dev #28 — Tilemap 영역 포함 모든 일반 Collider Layer 8 변환.
|
|
// Drop-Through 표준 패턴 = 모든 발판·지면이 Layer 8. PlatformDropThrough Raycast가 하강 시 충돌 활성 = 착지.
|
|
int applied = 0, excluded = 0;
|
|
var allColliders = Object.FindObjectsByType<Collider2D>(FindObjectsSortMode.None);
|
|
var appliedNames = new System.Collections.Generic.List<string>();
|
|
foreach (var c in allColliders)
|
|
{
|
|
if (c == null) continue;
|
|
if (c.isTrigger) { excluded++; continue; }
|
|
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)
|
|
{
|
|
excluded++;
|
|
continue;
|
|
}
|
|
|
|
// PlatformEffector2D 잔존 제거 (BT25 누적 영향 차단)
|
|
var effector = c.GetComponent<PlatformEffector2D>();
|
|
if (effector != null) Object.Destroy(effector);
|
|
c.usedByEffector = false;
|
|
|
|
// Layer 8 변환 → IgnoreLayerCollision 기본 통과 + PlatformDropThrough Raycast 착지
|
|
c.gameObject.layer = 8;
|
|
applied++;
|
|
if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}({c.GetType().Name})");
|
|
}
|
|
Debug.Log($"[BT28-JumpThrough] applied={applied} excluded={excluded} total={allColliders.Length}");
|
|
Debug.Log($"[BT28-JumpThrough] appliedSamples=[{string.Join(", ", appliedNames)}]");
|
|
}
|
|
}
|
|
}
|