using System.Collections.Generic; using UnityEngine; using Platformer.Mechanics; namespace EerieVillage.Progression { /// /// 레벨업 발화 시 일시정지 + UI 호출 + 카드 선택 결과 수령. /// PlayerProgression.OnLevelUp 구독. /// /// Phase 2-A 영역 — UI 호출 placeholder (Debug.Log). /// Phase 2-B 영역 — SkillSelectionUI 영역 통합. /// public class LevelUpManager : MonoBehaviour { public static LevelUpManager Instance { get; private set; } [SerializeField] SkillCardPlaceholderPool _pool; // Phase 2-B 영역 — SkillSelectionUI 영역 부착 // [SerializeField] SkillSelectionUI _ui; PlayerController _player; PlayerProgression _progression; bool _isLevelUpActive = false; void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); return; } Instance = this; } void Start() { _player = Object.FindFirstObjectByType(); if (_player == null) { Debug.LogWarning("[LevelUpManager] PlayerController 영역 부재 — Start 시점 참조 X"); return; } _progression = _player.GetComponent(); if (_progression == null) { _progression = _player.gameObject.AddComponent(); } _progression.OnLevelUp += HandleLevelUp; if (_pool == null) _pool = GetComponent(); } void OnDestroy() { if (_progression != null) _progression.OnLevelUp -= HandleLevelUp; if (Instance == this) Instance = null; } void HandleLevelUp(int newLevel) { if (_isLevelUpActive) return; _isLevelUpActive = true; // 일시정지 + 입력 차단 Time.timeScale = 0f; if (_player != null) _player.controlEnabled = false; // 카드 3장 무작위 추출 List cards = _pool != null ? _pool.Draw3Random() : new List(); // Phase 2-A 영역 placeholder — UI 호출 영역 Phase 2-B 영역 통합 Debug.Log($"[LevelUpManager] LevelUp Lv.{newLevel} — 카드 {cards.Count}장 영역 (UI placeholder·Phase 2-B 통합 예정)"); for (int i = 0; i < cards.Count; i++) { var c = cards[i]; Debug.Log($" [{i + 1}] {c.displayName} ({c.rarity}·Lv.{c.currentLevel}{(c.IsMaxLevel ? "·최대" : "")})"); } // Phase 2-A 영역 임시 — 즉시 첫 카드 자동 확인 + 게임 재개 // Phase 2-B 영역 = SkillSelectionUI.Show + 사용자 클릭·확인 후 콜백 HandleCardConfirmed(cards.Count > 0 ? cards[0] : null); } void HandleCardConfirmed(SkillCardPlaceholder selected) { // 차기 BT12-Dev 영역 = PlayerSkillInventory.AddSkillByCardId(selected.id) // BT12-MVP-A 영역 = UI 닫기·게임 재개만 Debug.Log($"[LevelUpManager] 카드 확정 영역 — {(selected != null ? selected.displayName : "NONE")} (효과 적용 X·BT12-Dev 본격 영역)"); Time.timeScale = 1f; if (_player != null) _player.controlEnabled = true; _isLevelUpActive = false; } } }