Files
Colosseum/Assets/_Game/Scripts/UI/SkillQuickSlotUI.cs
dal4segno c265f980db chore: Assets 디렉토리 구조 정리 및 네이밍 컨벤션 적용
- Assets/_Game/ 하위로 게임 에셋 통합
- External/ 패키지 벤더별 분류 (Synty, Animations, UI)
- 에셋 네이밍 컨벤션 확립 및 적용
  (Data_Skill_, Data_SkillEffect_, Prefab_, Anim_, Model_, BT_ 등)
- pre-commit hook으로 네이밍 컨벤션 자동 검사 추가
- RESTRUCTURE_CHECKLIST.md 작성

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 19:08:27 +09:00

143 lines
4.7 KiB
C#

using UnityEngine;
using Colosseum.Player;
using Colosseum.Skills;
namespace Colosseum.UI
{
/// <summary>
/// 스킬 퀵슬롯 UI 관리자.
/// PlayerSkillInput과 연동하여 쿨타임, 마나 등을 표시합니다.
/// </summary>
public class SkillQuickSlotUI : MonoBehaviour
{
[Header("Skill Slots")]
[Tooltip("6개의 스킬 슬롯 UI (인덱스 순서대로)")]
[SerializeField] private SkillSlotUI[] skillSlots = new SkillSlotUI[6];
[Header("Debug")]
[SerializeField] private bool debugMode = false;
[Header("Keybind Labels")]
[Tooltip("키바인딩 표시 텍스트 (기본: Q, W, E, R, A, S)")]
[SerializeField] private string[] keyLabels = { "Q", "W", "E", "R", "A", "S" };
private PlayerSkillInput playerSkillInput;
private PlayerNetworkController networkController;
private void Start()
{
// 로컬 플레이어 찾기
FindLocalPlayer();
}
private void FindLocalPlayer()
{
var players = FindObjectsByType<PlayerSkillInput>(FindObjectsSortMode.None);
if (players.Length == 0)
{
Debug.LogWarning("[SkillQuickSlotUI] No PlayerSkillInput found in scene");
return;
}
foreach (var player in players)
{
if (player.IsOwner)
{
playerSkillInput = player;
networkController = player.GetComponent<PlayerNetworkController>();
Debug.Log($"[SkillQuickSlotUI] Found local player: {player.name}");
InitializeSlots();
return;
}
}
Debug.LogWarning("[SkillQuickSlotUI] No local player found (IsOwner = false)");
}
private void InitializeSlots()
{
if (playerSkillInput == null) return;
int initializedCount = 0;
for (int i = 0; i < skillSlots.Length && i < keyLabels.Length; i++)
{
SkillData skill = playerSkillInput.GetSkill(i);
string keyLabel = i < keyLabels.Length ? keyLabels[i] : (i + 1).ToString();
if (skillSlots[i] != null)
{
skillSlots[i].Initialize(i, skill, keyLabel);
if (skill != null) initializedCount++;
}
else
{
Debug.LogWarning($"[SkillQuickSlotUI] Slot {i} is not assigned");
}
}
Debug.Log($"[SkillQuickSlotUI] Initialized {initializedCount} skill slots");
}
private void Update()
{
if (playerSkillInput == null)
{
// 플레이어가 아직 없으면 다시 찾기 시도
FindLocalPlayer();
return;
}
UpdateSlotStates();
}
private float debugLogTimer = 0f;
private void UpdateSlotStates()
{
bool shouldLog = debugMode && Time.time > debugLogTimer;
if (shouldLog) debugLogTimer = Time.time + 1f;
for (int i = 0; i < skillSlots.Length; i++)
{
if (skillSlots[i] == null) continue;
SkillData skill = playerSkillInput.GetSkill(i);
if (skill == null) continue;
float remainingCooldown = playerSkillInput.GetRemainingCooldown(i);
float totalCooldown = skill.Cooldown;
bool hasEnoughMana = networkController == null || networkController.Mana >= skill.ManaCost;
if (shouldLog && remainingCooldown > 0f)
{
Debug.Log($"[SkillQuickSlotUI] Slot {i}: {skill.SkillName}, CD: {remainingCooldown:F1}/{totalCooldown:F1}");
}
skillSlots[i].UpdateState(remainingCooldown, totalCooldown, hasEnoughMana);
}
}
/// <summary>
/// 플레이어 참조 수동 설정 (씬 전환 등에서 사용)
/// </summary>
public void SetPlayer(PlayerSkillInput player)
{
playerSkillInput = player;
networkController = player?.GetComponent<PlayerNetworkController>();
InitializeSlots();
}
/// <summary>
/// 특정 슬롯의 스킬 변경
/// </summary>
public void UpdateSkillSlot(int slotIndex, SkillData skill)
{
if (slotIndex < 0 || slotIndex >= skillSlots.Length) return;
string keyLabel = slotIndex < keyLabels.Length ? keyLabels[slotIndex] : (slotIndex + 1).ToString();
skillSlots[slotIndex].Initialize(slotIndex, skill, keyLabel);
}
}
}