Code up the card part
This commit is contained in:
62
Assets/Scripts/UI/CardSystem/DragDrop/CardDraggable.cs
Normal file
62
Assets/Scripts/UI/CardSystem/DragDrop/CardDraggable.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using AppleHills.Data.CardSystem;
|
||||
using UI.DragAndDrop.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem.DragDrop
|
||||
{
|
||||
/// <summary>
|
||||
/// Card-specific implementation of DraggableObject.
|
||||
/// Manages card data and card-specific drag behavior.
|
||||
/// </summary>
|
||||
public class CardDraggable : DraggableObject
|
||||
{
|
||||
[Header("Card Data")]
|
||||
[SerializeField] private CardData cardData;
|
||||
|
||||
// Events
|
||||
public event System.Action<CardDraggable, CardData> OnCardDataChanged;
|
||||
|
||||
public CardData CardData => cardData;
|
||||
|
||||
/// <summary>
|
||||
/// Set the card data for this draggable card
|
||||
/// </summary>
|
||||
public void SetCardData(CardData data)
|
||||
{
|
||||
cardData = data;
|
||||
OnCardDataChanged?.Invoke(this, cardData);
|
||||
|
||||
// Update visual if it exists
|
||||
if (_visualInstance != null && _visualInstance is CardDraggableVisual cardVisual)
|
||||
{
|
||||
cardVisual.RefreshCardDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDragStartedHook()
|
||||
{
|
||||
base.OnDragStartedHook();
|
||||
// Card-specific drag started behavior
|
||||
}
|
||||
|
||||
protected override void OnDragEndedHook()
|
||||
{
|
||||
base.OnDragEndedHook();
|
||||
// Card-specific drag ended behavior
|
||||
}
|
||||
|
||||
protected override void OnSelectionChangedHook(bool selected)
|
||||
{
|
||||
base.OnSelectionChangedHook(selected);
|
||||
// Card-specific selection behavior
|
||||
}
|
||||
|
||||
protected override void OnSlotChangedHook(DraggableSlot previousSlot, DraggableSlot newSlot)
|
||||
{
|
||||
base.OnSlotChangedHook(previousSlot, newSlot);
|
||||
// Card-specific slot changed behavior
|
||||
// Could trigger events for card collection reordering, etc.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user