85 lines
3.0 KiB
C#
85 lines
3.0 KiB
C#
using UnityEngine;
|
|
using EerieVillage.Skills;
|
|
|
|
namespace EerieVillage.MyUI
|
|
{
|
|
/// <summary>
|
|
/// BT12-Dev 시각화 HUD — PlayerSkillInventory 등록 상태를 좌상단에 표시.
|
|
/// PD 지시 2026-05-09 — "PlayerSkillInventory 등록이 되었는지 어떻게 판단해야하지?
|
|
/// 시각적인 변화가 없으니 확인이 불가능해. 유니티 기본 제공 리소스를 활용해도 좋으니 보이게 해줘."
|
|
///
|
|
/// 표시 내용:
|
|
/// - 장착 액티브 스킬 목록 (DisplayName · Lv · CooldownRemaining/EffectiveCooldown)
|
|
/// - 패시브 슬롯 카운트
|
|
///
|
|
/// PlayerController.Awake에서 자동 부착되는 PlayerSkillInventory와 함께 부착.
|
|
/// </summary>
|
|
[RequireComponent(typeof(PlayerSkillInventory))]
|
|
public class SkillInventoryHUD : MonoBehaviour
|
|
{
|
|
PlayerSkillInventory _inventory;
|
|
GUIStyle _boxStyle;
|
|
|
|
void Awake()
|
|
{
|
|
_inventory = GetComponent<PlayerSkillInventory>();
|
|
}
|
|
|
|
void OnGUI()
|
|
{
|
|
if (_inventory == null) return;
|
|
|
|
if (_boxStyle == null)
|
|
{
|
|
_boxStyle = new GUIStyle(GUI.skin.box);
|
|
_boxStyle.alignment = TextAnchor.UpperLeft;
|
|
_boxStyle.fontSize = 14;
|
|
_boxStyle.normal.textColor = Color.white;
|
|
_boxStyle.padding = new RectOffset(10, 10, 6, 6);
|
|
_boxStyle.richText = true;
|
|
}
|
|
|
|
var sb = new System.Text.StringBuilder();
|
|
sb.AppendLine("<b><color=#ffd86b>장착 스킬</color></b>");
|
|
|
|
int activeCount = 0;
|
|
foreach (var active in _inventory.ActiveSkills)
|
|
{
|
|
if (active == null) continue;
|
|
var data = active.Data;
|
|
if (data == null) continue;
|
|
activeCount++;
|
|
|
|
float remaining = 0f;
|
|
float total = 0f;
|
|
if (active is ActiveSkillRuntime rt)
|
|
{
|
|
remaining = Mathf.Max(0f, rt.CooldownRemaining);
|
|
total = rt.EffectiveCooldown;
|
|
}
|
|
|
|
sb.Append($"{activeCount}. {data.DisplayName} <color=#88c8ff>Lv.{active.StackLevel}</color>");
|
|
if (total > 0f)
|
|
{
|
|
sb.Append($" <color=#bbbbbb>CD {remaining:F1}s/{total:F1}s</color>");
|
|
}
|
|
sb.AppendLine();
|
|
}
|
|
|
|
if (activeCount == 0)
|
|
{
|
|
sb.AppendLine("<color=#888888>(없음)</color>");
|
|
}
|
|
|
|
int passiveCount = _inventory.PassiveSkills.Count;
|
|
sb.AppendLine();
|
|
sb.AppendLine($"<b><color=#a0d8a0>패시브: {passiveCount}장</color></b>");
|
|
|
|
// 가변 높이 (라인 수 기반)
|
|
int lines = activeCount + 4 + (activeCount == 0 ? 1 : 0);
|
|
float height = lines * 20f + 16f;
|
|
GUI.Box(new Rect(10f, 10f, 320f, height), sb.ToString(), _boxStyle);
|
|
}
|
|
}
|
|
}
|