74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using Core.SaveLoad;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using Core;
|
|
|
|
namespace UI.CardSystem.StateMachine.States
|
|
{
|
|
/// <summary>
|
|
/// Dragging state - handles card being dragged for album placement.
|
|
/// Integrates with existing drag/drop system.
|
|
/// </summary>
|
|
public class CardDraggingState : AppleState
|
|
{
|
|
[Header("Drag Settings")]
|
|
[SerializeField] private float dragScale = 1.1f;
|
|
|
|
private CardContext _context;
|
|
private Vector3 _originalScale;
|
|
private Vector3 _dragStartPosition;
|
|
|
|
private void Awake()
|
|
{
|
|
_context = GetComponentInParent<CardContext>();
|
|
}
|
|
|
|
public override void OnEnterState()
|
|
{
|
|
// Store original transform
|
|
_originalScale = _context.RootTransform.localScale;
|
|
_dragStartPosition = _context.RootTransform.position;
|
|
|
|
// Scale up slightly during drag for visual feedback
|
|
_context.RootTransform.localScale = _originalScale * dragScale;
|
|
|
|
Logging.Debug($"[CardDraggingState] Entered drag state for card: {_context.CardData?.Name}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update drag position (called by external drag handler)
|
|
/// </summary>
|
|
public void UpdateDragPosition(Vector3 worldPosition)
|
|
{
|
|
_context.RootTransform.position = worldPosition;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when drag is released and card snaps to slot
|
|
/// </summary>
|
|
public void OnDroppedInSlot()
|
|
{
|
|
_context.StateMachine.ChangeState("PlacedInSlotState");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when drag is released but not over valid slot
|
|
/// </summary>
|
|
public void OnDroppedOutsideSlot()
|
|
{
|
|
// Return to revealed state
|
|
_context.StateMachine.ChangeState("RevealedState");
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
// Restore original scale when exiting drag
|
|
if (_context?.RootTransform != null)
|
|
{
|
|
_context.RootTransform.localScale = _originalScale;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|