Stash work
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using Core;
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles flipping a pending face-down card after data assignment.
|
||||
/// Transitions to DraggingRevealedState when flip completes.
|
||||
/// </summary>
|
||||
public class CardFlippingPendingState : AppleState
|
||||
{
|
||||
private CardContext context;
|
||||
private GameObject cardBack;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
context = GetComponentInParent<CardContext>();
|
||||
if (context != null)
|
||||
{
|
||||
var backTransform = context.RootTransform.Find("CardBack");
|
||||
if (backTransform != null) cardBack = backTransform.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
{
|
||||
if (context == null) return;
|
||||
// Ensure card back visible and front hidden at start
|
||||
if (cardBack != null) cardBack.SetActive(true);
|
||||
if (context.CardDisplay != null) context.CardDisplay.gameObject.SetActive(false);
|
||||
|
||||
// Optional: album navigation
|
||||
var albumPage = Object.FindObjectOfType<AlbumViewPage>();
|
||||
if (albumPage != null && context.CardData != null)
|
||||
{
|
||||
int targetPage = albumPage.FindPageForCard(context.CardData); // placeholder; method may be private
|
||||
}
|
||||
|
||||
if (context.Animator != null)
|
||||
{
|
||||
Transform back = cardBack != null ? cardBack.transform : null;
|
||||
Transform front = context.CardDisplay != null ? context.CardDisplay.transform : null;
|
||||
context.Animator.PlayFlip(back, front, onComplete: () =>
|
||||
{
|
||||
context.StateMachine.ChangeState("DraggingRevealedState");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cardBack != null) cardBack.SetActive(false);
|
||||
if (context.CardDisplay != null) context.CardDisplay.gameObject.SetActive(true);
|
||||
context.StateMachine.ChangeState("DraggingRevealedState");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user