117 lines
4.4 KiB
C#
117 lines
4.4 KiB
C#
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
using TMPro;
|
|||
|
|
using EerieVillage.Progression;
|
|||
|
|
|
|||
|
|
namespace EerieVillage.MyUI
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// BT12-MVP-A 영역 스킬 선택 UI — PD 첨부 예시 ("기술 선택" 화면) 정합.
|
|||
|
|
/// LevelUpManager 영역 호출 — Show(cards, level, onConfirm).
|
|||
|
|
///
|
|||
|
|
/// 화면 구조:
|
|||
|
|
/// [Header] "기술 선택" 타이틀 + X 닫기 버튼
|
|||
|
|
/// [Body] 카드 3장 가로 배치 (SkillCardSlot ×3)
|
|||
|
|
/// [Footer] "남은 포인트: N" + "확인" 버튼
|
|||
|
|
///
|
|||
|
|
/// 인터랙션:
|
|||
|
|
/// - 카드 클릭 → 선택 (highlight)
|
|||
|
|
/// - 확인 버튼 → onConfirm 콜백 + UI 닫기
|
|||
|
|
/// - X 버튼 → 첫 카드 자동 선택 + 콜백 (취소 영역 placeholder)
|
|||
|
|
/// </summary>
|
|||
|
|
public class SkillSelectionUI : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
[Header("Root")]
|
|||
|
|
[SerializeField] GameObject _rootPanel; // 일시정지 시 활성·복귀 시 비활성
|
|||
|
|
|
|||
|
|
[Header("Header")]
|
|||
|
|
[SerializeField] TMP_Text _titleText; // "기술 선택"
|
|||
|
|
[SerializeField] Button _closeButton; // X 버튼 (우측 상단)
|
|||
|
|
|
|||
|
|
[Header("Card Slots (3개 가로 배치)")]
|
|||
|
|
[SerializeField] SkillCardSlot _slot1;
|
|||
|
|
[SerializeField] SkillCardSlot _slot2;
|
|||
|
|
[SerializeField] SkillCardSlot _slot3;
|
|||
|
|
|
|||
|
|
[Header("Footer")]
|
|||
|
|
[SerializeField] TMP_Text _pointText; // "남은 포인트: N"
|
|||
|
|
[SerializeField] Button _confirmButton; // "확인"
|
|||
|
|
|
|||
|
|
SkillCardPlaceholder _selected;
|
|||
|
|
System.Action<SkillCardPlaceholder> _onConfirm;
|
|||
|
|
|
|||
|
|
void Awake()
|
|||
|
|
{
|
|||
|
|
// unscaledDeltaTime 정합 영역 — Time.timeScale=0 시 UI 인터랙션 보장 (Animator·EventSystem 영역 PD 추후 검증)
|
|||
|
|
if (_rootPanel != null) _rootPanel.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>레벨업 시점 호출 — 카드 3장 표시 + 사용자 선택 대기.</summary>
|
|||
|
|
public void Show(List<SkillCardPlaceholder> cards, int level, System.Action<SkillCardPlaceholder> onConfirm)
|
|||
|
|
{
|
|||
|
|
_onConfirm = onConfirm;
|
|||
|
|
_selected = null;
|
|||
|
|
|
|||
|
|
if (_rootPanel != null) _rootPanel.SetActive(true);
|
|||
|
|
if (_titleText != null) _titleText.text = "기술 선택";
|
|||
|
|
if (_pointText != null) _pointText.text = "남은 포인트: 1";
|
|||
|
|
if (_confirmButton != null) _confirmButton.interactable = false;
|
|||
|
|
|
|||
|
|
// 카드 3장 영역 바인딩 (부족 영역 = 슬롯 hide)
|
|||
|
|
BindSlot(_slot1, cards.Count > 0 ? cards[0] : null);
|
|||
|
|
BindSlot(_slot2, cards.Count > 1 ? cards[1] : null);
|
|||
|
|
BindSlot(_slot3, cards.Count > 2 ? cards[2] : null);
|
|||
|
|
|
|||
|
|
// 버튼 영역 리스너
|
|||
|
|
if (_confirmButton != null)
|
|||
|
|
{
|
|||
|
|
_confirmButton.onClick.RemoveAllListeners();
|
|||
|
|
_confirmButton.onClick.AddListener(OnConfirmClicked);
|
|||
|
|
}
|
|||
|
|
if (_closeButton != null)
|
|||
|
|
{
|
|||
|
|
_closeButton.onClick.RemoveAllListeners();
|
|||
|
|
_closeButton.onClick.AddListener(OnCloseClicked);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Hide()
|
|||
|
|
{
|
|||
|
|
if (_rootPanel != null) _rootPanel.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void BindSlot(SkillCardSlot slot, SkillCardPlaceholder card)
|
|||
|
|
{
|
|||
|
|
if (slot == null) return;
|
|||
|
|
slot.Bind(card, () => OnCardSelected(slot, card));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void OnCardSelected(SkillCardSlot clickedSlot, SkillCardPlaceholder card)
|
|||
|
|
{
|
|||
|
|
if (card == null) return;
|
|||
|
|
_selected = card;
|
|||
|
|
if (_confirmButton != null) _confirmButton.interactable = true;
|
|||
|
|
|
|||
|
|
// 다른 슬롯 영역 highlight 해제 + 선택 슬롯만 활성
|
|||
|
|
if (_slot1 != null) _slot1.SetHighlight(_slot1 == clickedSlot);
|
|||
|
|
if (_slot2 != null) _slot2.SetHighlight(_slot2 == clickedSlot);
|
|||
|
|
if (_slot3 != null) _slot3.SetHighlight(_slot3 == clickedSlot);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void OnConfirmClicked()
|
|||
|
|
{
|
|||
|
|
if (_selected == null) return;
|
|||
|
|
var sel = _selected;
|
|||
|
|
_onConfirm?.Invoke(sel);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void OnCloseClicked()
|
|||
|
|
{
|
|||
|
|
// 취소 영역 = 첫 카드 자동 확정 (BT12-MVP-A 영역 placeholder · 차기 영역 PD 결정 영역)
|
|||
|
|
var fallback = _slot1 != null ? _slot1.Card : null;
|
|||
|
|
_onConfirm?.Invoke(fallback);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|