Files
AppleHillsProduction/Assets/Scripts/UI/CardSystem/StateMachine/States/CardDraggingRevealedState.cs

65 lines
2.0 KiB
C#
Raw Normal View History

2025-11-17 08:39:41 +01:00
using Core.SaveLoad;
using UnityEngine;
namespace UI.CardSystem.StateMachine.States
{
/// <summary>
2025-11-17 14:30:07 +01:00
/// Dragging revealed state for pending cards after flip.
/// Shows card front without badges, handles placement or return to corner.
2025-11-17 08:39:41 +01:00
/// </summary>
2025-11-17 14:30:07 +01:00
public class CardDraggingRevealedState : AppleState, ICardStateDragHandler
2025-11-17 08:39:41 +01:00
{
2025-11-17 14:30:07 +01:00
private CardContext _context;
private Vector3 _originalScale;
2025-11-17 08:39:41 +01:00
private void Awake()
{
2025-11-17 14:30:07 +01:00
_context = GetComponentInParent<CardContext>();
2025-11-17 08:39:41 +01:00
}
public override void OnEnterState()
{
2025-11-17 14:30:07 +01:00
if (_context == null) return;
if (_context.CardDisplay != null)
2025-11-17 08:39:41 +01:00
{
2025-11-17 14:30:07 +01:00
_context.CardDisplay.gameObject.SetActive(true);
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0,0,0);
2025-11-17 08:39:41 +01:00
}
2025-11-17 14:30:07 +01:00
_originalScale = _context.RootTransform.localScale;
_context.RootTransform.localScale = _originalScale * 1.15f;
}
/// <summary>
/// Already in dragging state, nothing to do
/// </summary>
public bool OnCardDragStarted(CardContext ctx)
{
return true; // Prevent default DraggingState transition
}
/// <summary>
/// Handle drag end - just let AlbumViewPage handle placement logic
/// Stay in this state until AlbumViewPage transitions us after tween
/// </summary>
public bool OnCardDragEnded(CardContext ctx)
{
// Don't do anything - AlbumViewPage will:
// 1. Wait for page flip to complete
// 2. Find the correct slot
// 3. Tween card to slot
// 4. Transition to PlacedInSlotState
// Return true to prevent default behavior
return true;
2025-11-17 08:39:41 +01:00
}
private void OnDisable()
{
2025-11-17 14:30:07 +01:00
if (_context?.RootTransform != null)
2025-11-17 08:39:41 +01:00
{
2025-11-17 14:30:07 +01:00
_context.RootTransform.localScale = _originalScale;
2025-11-17 08:39:41 +01:00
}
}
}
}