Update assets, working save kerfuffle
This commit is contained in:
@@ -4,35 +4,60 @@ using UnityEngine;
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
/// <summary>
|
||||
/// Dragging revealed state for pending cards after flip; minimal overlay of CardDraggingState but no badges.
|
||||
/// Dragging revealed state for pending cards after flip.
|
||||
/// Shows card front without badges, handles placement or return to corner.
|
||||
/// </summary>
|
||||
public class CardDraggingRevealedState : AppleState
|
||||
public class CardDraggingRevealedState : AppleState, ICardStateDragHandler
|
||||
{
|
||||
private CardContext context;
|
||||
private Vector3 originalScale;
|
||||
private CardContext _context;
|
||||
private Vector3 _originalScale;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
context = GetComponentInParent<CardContext>();
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
{
|
||||
if (context == null) return;
|
||||
if (context.CardDisplay != null)
|
||||
if (_context == null) return;
|
||||
if (_context.CardDisplay != null)
|
||||
{
|
||||
context.CardDisplay.gameObject.SetActive(true);
|
||||
context.CardDisplay.transform.localRotation = Quaternion.Euler(0,0,0);
|
||||
_context.CardDisplay.gameObject.SetActive(true);
|
||||
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0,0,0);
|
||||
}
|
||||
originalScale = context.RootTransform.localScale;
|
||||
context.RootTransform.localScale = originalScale * 1.15f;
|
||||
_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;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (context?.RootTransform != null)
|
||||
if (_context?.RootTransform != null)
|
||||
{
|
||||
context.RootTransform.localScale = originalScale;
|
||||
_context.RootTransform.localScale = _originalScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using Core.SaveLoad;
|
||||
using Core;
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
/// <summary>
|
||||
/// Card is in pending face-down state in corner, awaiting drag.
|
||||
/// On drag start, triggers data assignment, flip animation, and page navigation.
|
||||
/// On drag start, triggers flip animation and transitions to revealed dragging.
|
||||
/// </summary>
|
||||
public class CardPendingFaceDownState : AppleState
|
||||
public class CardPendingFaceDownState : AppleState, ICardStateDragHandler
|
||||
{
|
||||
[Header("State-Owned Visuals")]
|
||||
[SerializeField] private GameObject cardBackVisual;
|
||||
@@ -44,15 +45,31 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by Card.OnDragStartedHook when user starts dragging.
|
||||
/// This triggers the smart selection, page navigation, and flip animation.
|
||||
/// Handle drag start - triggers flip animation and page navigation
|
||||
/// </summary>
|
||||
public void OnDragStarted()
|
||||
public bool OnCardDragStarted(CardContext context)
|
||||
{
|
||||
if (_isFlipping) return; // Already flipping
|
||||
if (_isFlipping) return true; // Already handling
|
||||
|
||||
// Start flip animation (data should be assigned by listeners by now)
|
||||
// IMPORTANT: Data must be assigned by event listeners (AlbumViewPage) BEFORE we flip
|
||||
// The event system guarantees this because events are synchronous
|
||||
if (context.CardData == null)
|
||||
{
|
||||
Logging.Warning("[CardPendingFaceDownState] OnCardDragStarted called but no CardData assigned yet!");
|
||||
return true; // Don't flip without data
|
||||
}
|
||||
|
||||
// Start flip animation (data is now guaranteed to be assigned)
|
||||
StartFlipAnimation();
|
||||
return true; // We handled it, prevent default DraggingState transition
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We don't handle drag end in face-down state
|
||||
/// </summary>
|
||||
public bool OnCardDragEnded(CardContext context)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private void StartFlipAnimation()
|
||||
|
||||
Reference in New Issue
Block a user