Stash half-assed work on testing scene
This commit is contained in:
committed by
Michal Pikulski
parent
39d5890db4
commit
4e7f774386
@@ -29,6 +29,7 @@ namespace UI.CardSystem.StateMachine
|
||||
// Runtime state
|
||||
public bool IsNewCard { get; set; }
|
||||
public int RepeatCardCount { get; set; }
|
||||
public bool IsClickable { get; set; } = true;
|
||||
|
||||
// Events for external coordination (BoosterOpeningPage, etc.)
|
||||
public event Action<CardContext> OnFlipComplete;
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace UI.CardSystem.StateMachine.States
|
||||
public class CardEnlargedRepeatState : AppleState, IPointerClickHandler
|
||||
{
|
||||
[Header("State-Owned Visuals")]
|
||||
[SerializeField] private GameObject progressBarContainer;
|
||||
[SerializeField] private ProgressBarController progressBar;
|
||||
|
||||
private CardContext _context;
|
||||
@@ -35,21 +34,11 @@ namespace UI.CardSystem.StateMachine.States
|
||||
_originalScale = _context.RootTransform.localScale;
|
||||
_waitingForTap = false;
|
||||
|
||||
// Show progress bar container
|
||||
if (progressBarContainer != null)
|
||||
{
|
||||
progressBarContainer.SetActive(true);
|
||||
}
|
||||
|
||||
// Enlarge the card
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayEnlarge(_settings.NewCardEnlargedScale);
|
||||
}
|
||||
|
||||
// Show progress with blink animation
|
||||
// Show progress bar
|
||||
if (progressBar != null)
|
||||
{
|
||||
progressBar.gameObject.SetActive(true);
|
||||
|
||||
int currentCount = _context.RepeatCardCount + 1; // +1 because we just got this card
|
||||
int maxCount = _settings.CardsToUpgrade;
|
||||
|
||||
@@ -60,6 +49,12 @@ namespace UI.CardSystem.StateMachine.States
|
||||
Logging.Warning("[CardEnlargedRepeatState] ProgressBar component not assigned!");
|
||||
OnProgressComplete();
|
||||
}
|
||||
|
||||
// Enlarge the card
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayEnlarge(_settings.NewCardEnlargedScale);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnProgressComplete()
|
||||
@@ -170,9 +165,9 @@ namespace UI.CardSystem.StateMachine.States
|
||||
_context.IsNewCard = true;
|
||||
|
||||
// Hide progress bar before transitioning
|
||||
if (progressBarContainer != null)
|
||||
if (progressBar != null)
|
||||
{
|
||||
progressBarContainer.SetActive(false);
|
||||
progressBar.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Transition to EnlargedNewState (card is already enlarged, will show NEW badge)
|
||||
@@ -205,9 +200,9 @@ namespace UI.CardSystem.StateMachine.States
|
||||
private void OnDisable()
|
||||
{
|
||||
// Hide progress bar when leaving state
|
||||
if (progressBarContainer != null)
|
||||
if (progressBar != null)
|
||||
{
|
||||
progressBarContainer.SetActive(false);
|
||||
progressBar.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
/// <summary>
|
||||
/// Flipping state - handles the card flip animation from back to front.
|
||||
/// Owns the CardBackVisual as a child GameObject.
|
||||
/// </summary>
|
||||
public class CardFlippingState : AppleState
|
||||
{
|
||||
[Header("State-Owned Visuals")]
|
||||
[SerializeField] private GameObject cardBackVisual;
|
||||
|
||||
private CardContext _context;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
{
|
||||
// Activate card back, hide card front
|
||||
if (cardBackVisual != null)
|
||||
{
|
||||
cardBackVisual.SetActive(true);
|
||||
}
|
||||
|
||||
if (_context.CardDisplay != null)
|
||||
{
|
||||
_context.CardDisplay.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Play flip animation + scale punch
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayFlip(
|
||||
cardBack: cardBackVisual.transform,
|
||||
cardFront: _context.CardDisplay.transform,
|
||||
onComplete: OnFlipComplete
|
||||
);
|
||||
|
||||
_context.Animator.PlayFlipScalePunch();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFlipComplete()
|
||||
{
|
||||
// Fire flip complete event
|
||||
_context.FireFlipComplete();
|
||||
|
||||
// Transition based on whether this is a new card or repeat
|
||||
if (_context.IsNewCard)
|
||||
{
|
||||
_context.StateMachine.ChangeState("EnlargedNewState");
|
||||
}
|
||||
else if (_context.CardData.Rarity == AppleHills.Data.CardSystem.CardRarity.Legendary)
|
||||
{
|
||||
// Legendary repeat - skip enlarge, they can't upgrade
|
||||
// Add to inventory and move to revealed state
|
||||
Data.CardSystem.CardSystemManager.Instance.AddCardToInventoryDelayed(_context.CardData);
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
else if (_context.RepeatCardCount > 0)
|
||||
{
|
||||
_context.StateMachine.ChangeState("EnlargedRepeatState");
|
||||
}
|
||||
else
|
||||
{
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Hide card back when leaving state
|
||||
if (cardBackVisual != null)
|
||||
{
|
||||
cardBackVisual.SetActive(false);
|
||||
}
|
||||
|
||||
// Ensure card front is visible
|
||||
if (_context?.CardDisplay != null)
|
||||
{
|
||||
_context.CardDisplay.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7223d6cab8d94f74b00a6a538291850a
|
||||
timeCreated: 1762884650
|
||||
@@ -82,13 +82,61 @@ namespace UI.CardSystem.StateMachine.States
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
// Click to flip - transition to flipping state
|
||||
_context.StateMachine.ChangeState("FlippingState");
|
||||
// Check if card is clickable (prevents multi-flip in booster opening)
|
||||
if (!_context.IsClickable)
|
||||
{
|
||||
Logging.Debug($"[CardIdleState] Card is not clickable, ignoring click");
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop idle hover and pointer interactions
|
||||
StopIdleHover();
|
||||
|
||||
// Play flip animation directly (no state transition yet)
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayFlip(
|
||||
cardBack: cardBackVisual != null ? cardBackVisual.transform : null,
|
||||
cardFront: _context.CardDisplay != null ? _context.CardDisplay.transform : null,
|
||||
onComplete: OnFlipComplete
|
||||
);
|
||||
|
||||
_context.Animator.PlayFlipScalePunch();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
private void OnFlipComplete()
|
||||
{
|
||||
// Fire flip complete event
|
||||
_context.FireFlipComplete();
|
||||
|
||||
// Transition based on whether this is a new card or repeat
|
||||
if (_context.IsNewCard)
|
||||
{
|
||||
_context.StateMachine.ChangeState("EnlargedNewState");
|
||||
}
|
||||
else if (_context.CardData != null && _context.CardData.Rarity == AppleHills.Data.CardSystem.CardRarity.Legendary)
|
||||
{
|
||||
// Legendary repeat - skip enlarge, they can't upgrade
|
||||
// Add to inventory and move to revealed state
|
||||
if (Data.CardSystem.CardSystemManager.Instance != null)
|
||||
{
|
||||
Data.CardSystem.CardSystemManager.Instance.AddCardToInventoryDelayed(_context.CardData);
|
||||
}
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
else if (_context.RepeatCardCount > 0)
|
||||
{
|
||||
_context.StateMachine.ChangeState("EnlargedRepeatState");
|
||||
}
|
||||
else
|
||||
{
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
}
|
||||
|
||||
private void StopIdleHover()
|
||||
{
|
||||
// Stop idle hover animation when leaving state
|
||||
if (_idleHoverTween != null)
|
||||
{
|
||||
_idleHoverTween.Stop();
|
||||
@@ -101,9 +149,15 @@ namespace UI.CardSystem.StateMachine.States
|
||||
_context.Animator.AnimateAnchoredPosition(_originalPosition, 0.3f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Stop idle hover animation when leaving state
|
||||
StopIdleHover();
|
||||
|
||||
// Reset scale
|
||||
if (_context.Animator != null)
|
||||
if (_context?.Animator != null)
|
||||
{
|
||||
_context.Animator.AnimateScale(Vector3.one, 0.2f);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
@@ -7,9 +8,14 @@ namespace UI.CardSystem.StateMachine.States
|
||||
/// This is the "waiting" state:
|
||||
/// - In booster flow: waiting for all cards to finish before animating to album
|
||||
/// - In album placement flow: waiting to be dragged to a slot
|
||||
/// Shows small idle badges for NEW or REPEAT cards.
|
||||
/// </summary>
|
||||
public class CardRevealedState : AppleState
|
||||
{
|
||||
[Header("State-Owned Visuals")]
|
||||
[SerializeField] private UnityEngine.GameObject newCardIdleBadge;
|
||||
[SerializeField] private UnityEngine.GameObject repeatCardIdleBadge;
|
||||
|
||||
private CardContext _context;
|
||||
|
||||
private void Awake()
|
||||
@@ -20,9 +26,43 @@ namespace UI.CardSystem.StateMachine.States
|
||||
public override void OnEnterState()
|
||||
{
|
||||
// Card is at normal size, fully revealed
|
||||
|
||||
// Show appropriate idle badge
|
||||
if (_context.IsNewCard)
|
||||
{
|
||||
if (newCardIdleBadge != null)
|
||||
newCardIdleBadge.SetActive(true);
|
||||
if (repeatCardIdleBadge != null)
|
||||
repeatCardIdleBadge.SetActive(false);
|
||||
}
|
||||
else if (_context.RepeatCardCount > 0)
|
||||
{
|
||||
if (newCardIdleBadge != null)
|
||||
newCardIdleBadge.SetActive(false);
|
||||
if (repeatCardIdleBadge != null)
|
||||
repeatCardIdleBadge.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither new nor repeat - hide both
|
||||
if (newCardIdleBadge != null)
|
||||
newCardIdleBadge.SetActive(false);
|
||||
if (repeatCardIdleBadge != null)
|
||||
repeatCardIdleBadge.SetActive(false);
|
||||
}
|
||||
|
||||
// Fire interaction complete event (for BoosterOpeningPage tracking)
|
||||
_context.FireCardInteractionComplete();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Hide badges when leaving state
|
||||
if (newCardIdleBadge != null)
|
||||
newCardIdleBadge.SetActive(false);
|
||||
if (repeatCardIdleBadge != null)
|
||||
repeatCardIdleBadge.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user