2026-04-13 스킬,퀵슬롯 시스템 수정중

This commit is contained in:
2026-04-13 18:04:55 +09:00
parent de0ba90953
commit 71a6fda0da
57 changed files with 9074 additions and 59 deletions

View File

@@ -0,0 +1,77 @@
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class SkillEntry : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
[SerializeField] private Image _iconImage;
[SerializeField] private TextMeshProUGUI _nameText;
public SkillData Data { get; private set; }
private Transform _dragTransform;
private Transform _originalParent;
private CanvasGroup _canvasGroup;
private Vector3 _originalLocalPos;
private void Awake()
{
_canvasGroup = GetComponent<CanvasGroup>();
if (_canvasGroup == null)
_canvasGroup = gameObject.AddComponent<CanvasGroup>();
}
public void SetData(SkillData data)
{
Data = data;
if (_iconImage != null)
{
_iconImage.sprite = data != null ? data.Icon : null;
_iconImage.enabled = data != null && data.Icon != null;
}
if (_nameText != null)
_nameText.text = data != null ? data.EntryName : "";
}
public void OnBeginDrag(PointerEventData eventData)
{
if (Data == null)
{
eventData.pointerDrag = null;
return;
}
_dragTransform = GameManager.Instance.InGameUI.DragCanvas;
_originalParent = transform.parent;
_originalLocalPos = transform.localPosition;
transform.SetParent(_dragTransform);
_canvasGroup.blocksRaycasts = false;
}
public void OnDrag(PointerEventData eventData)
{
transform.position = eventData.position;
}
public void OnEndDrag(PointerEventData eventData)
{
_canvasGroup.blocksRaycasts = true;
// 드롭된 오브젝트 판정 — 퀵슬롯이면 등록
GameObject hovered = eventData.pointerEnter;
if (hovered != null)
{
QuickSlot slot = hovered.GetComponentInParent<QuickSlot>();
if (slot != null && Data != null)
{
slot.SetEntry(Data);
}
}
// 엔트리는 항상 제자리로 복귀 (원본은 목록에 남아있어야 함)
transform.SetParent(_originalParent);
transform.localPosition = _originalLocalPos;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 58eac31de8e96ed4c9a5fa7206bd63f3

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
using UnityEngine;
public class SkillWindowUI : MonoBehaviour
{
[SerializeField] private Transform _listContentRoot;
[SerializeField] private GameObject _skillEntryPrefab;
private readonly List<SkillEntry> _entries = new List<SkillEntry>();
public void Toggle()
{
bool willOpen = !gameObject.activeSelf;
gameObject.SetActive(willOpen);
if (willOpen) Refresh();
}
public void Refresh()
{
// 기존 엔트리 정리
foreach (Transform child in _listContentRoot)
Destroy(child.gameObject);
_entries.Clear();
var character = GameManager.Instance.Level.CurrentCharacter;
if (character == null) return;
if (!character.TryGetComponent<SkillModule>(out var skillModule)) return;
var skills = skillModule.GetEquippedSkillDatas();
for (int i = 0; i < skills.Count; i++)
{
if (skills[i] == null) continue;
GameObject entryObj = Instantiate(_skillEntryPrefab, _listContentRoot);
SkillEntry entry = entryObj.GetComponent<SkillEntry>();
if (entry != null)
{
entry.SetData(skills[i]);
_entries.Add(entry);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0abbd5b063416be4c97a8429d13b4b53