Almost working card state machine
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Core;
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using AppleHills.Core.Settings;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
@@ -10,7 +9,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
/// Album enlarged state - card is enlarged when clicked from album slot.
|
||||
/// Different from EnlargedNewState as it doesn't show "NEW" badge.
|
||||
/// </summary>
|
||||
public class CardAlbumEnlargedState : AppleState, IPointerClickHandler
|
||||
public class CardAlbumEnlargedState : AppleState, ICardClickHandler
|
||||
{
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
@@ -56,7 +55,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
Logging.Debug($"[CardAlbumEnlargedState] Card enlarged from album: {_context.CardData?.Name}");
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
public void OnCardClicked(CardContext context)
|
||||
{
|
||||
// Click to shrink back
|
||||
Logging.Debug($"[CardAlbumEnlargedState] Card clicked while enlarged, shrinking back");
|
||||
@@ -65,13 +64,17 @@ namespace UI.CardSystem.StateMachine.States
|
||||
OnShrinkRequested?.Invoke(this);
|
||||
|
||||
// Shrink animation, then transition back
|
||||
if (_context.Animator != null)
|
||||
if (context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayShrink(_originalScale, onComplete: () =>
|
||||
context.Animator.PlayShrink(_originalScale, onComplete: () =>
|
||||
{
|
||||
_context.StateMachine.ChangeState("PlacedInSlotState");
|
||||
context.StateMachine.ChangeState("PlacedInSlotState");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
context.StateMachine.ChangeState("PlacedInSlotState");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// filepath: Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedLegendaryRepeatState.cs
|
||||
using Core;
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using AppleHills.Core.Settings;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
/// <summary>
|
||||
/// Enlarged state specifically for Legendary rarity presentation after an upgrade.
|
||||
/// Shows the legendary card enlarged and awaits a click to shrink back to revealed state.
|
||||
/// </summary>
|
||||
public class CardEnlargedLegendaryRepeatState : AppleState, ICardClickHandler
|
||||
{
|
||||
private CardContext _context;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_context = GetComponentInParent<CardContext>();
|
||||
}
|
||||
|
||||
public override void OnEnterState()
|
||||
{
|
||||
// Ensure card front is visible and facing camera
|
||||
if (_context.CardDisplay != null)
|
||||
{
|
||||
_context.CardDisplay.gameObject.SetActive(true);
|
||||
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
// Card is already enlarged from EnlargedRepeatState, so no need to enlarge again
|
||||
// Just await click to dismiss
|
||||
|
||||
Logging.Debug($"[CardEnlargedLegendaryRepeatState] Legendary card enlarged: {_context.CardData?.Name}");
|
||||
}
|
||||
|
||||
public void OnCardClicked(CardContext context)
|
||||
{
|
||||
// Click to shrink to original scale and go to revealed state
|
||||
if (context.Animator != null)
|
||||
{
|
||||
context.Animator.PlayShrink(context.OriginalScale, onComplete: () =>
|
||||
{
|
||||
context.StateMachine.ChangeState("RevealedState");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 874e5574663a48b8a4feb3192821679a
|
||||
timeCreated: 1763319614
|
||||
@@ -1,6 +1,5 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using AppleHills.Core.Settings;
|
||||
using Core;
|
||||
|
||||
@@ -10,14 +9,13 @@ namespace UI.CardSystem.StateMachine.States
|
||||
/// Enlarged state for NEW cards - shows "NEW CARD" badge and waits for tap to dismiss.
|
||||
/// Owns the NewCardBadge as a child GameObject.
|
||||
/// </summary>
|
||||
public class CardEnlargedNewState : AppleState, IPointerClickHandler
|
||||
public class CardEnlargedNewState : AppleState, ICardClickHandler
|
||||
{
|
||||
[Header("State-Owned Visuals")]
|
||||
[SerializeField] private GameObject newCardBadge;
|
||||
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private Vector3 _originalScale;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -34,39 +32,39 @@ namespace UI.CardSystem.StateMachine.States
|
||||
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
// Store original scale
|
||||
_originalScale = _context.RootTransform.localScale;
|
||||
// Check if we're already enlarged (coming from upgrade flow)
|
||||
bool alreadyEnlarged = _context.RootTransform.localScale.x >= _settings.NewCardEnlargedScale * 0.9f;
|
||||
|
||||
if (!alreadyEnlarged)
|
||||
{
|
||||
// Normal flow - enlarge the card
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayEnlarge(_settings.NewCardEnlargedScale);
|
||||
}
|
||||
}
|
||||
|
||||
// Show NEW badge
|
||||
if (newCardBadge != null)
|
||||
{
|
||||
newCardBadge.SetActive(true);
|
||||
}
|
||||
|
||||
// Enlarge the card
|
||||
if (_context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayEnlarge(_settings.NewCardEnlargedScale);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
public void OnCardClicked(CardContext context)
|
||||
{
|
||||
// Fire dismissed event
|
||||
_context.FireCardDismissed();
|
||||
|
||||
// Tap to dismiss - shrink back and transition to revealed state
|
||||
if (_context.Animator != null)
|
||||
// Tap to dismiss - shrink back to original scale and transition to revealed state
|
||||
if (context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayShrink(_originalScale, onComplete: () =>
|
||||
context.Animator.PlayShrink(context.OriginalScale, onComplete: () =>
|
||||
{
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
context.StateMachine.ChangeState("RevealedState");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback if no animator
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +78,3 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using AppleHills.Core.Settings;
|
||||
using Core;
|
||||
using AppleHills.Data.CardSystem;
|
||||
@@ -12,14 +11,13 @@ namespace UI.CardSystem.StateMachine.States
|
||||
/// Uses ProgressBarController to animate progress filling.
|
||||
/// Auto-upgrades card when threshold is reached.
|
||||
/// </summary>
|
||||
public class CardEnlargedRepeatState : AppleState, IPointerClickHandler
|
||||
public class CardEnlargedRepeatState : AppleState, ICardClickHandler
|
||||
{
|
||||
[Header("State-Owned Visuals")]
|
||||
[SerializeField] private ProgressBarController progressBar;
|
||||
|
||||
private CardContext _context;
|
||||
private ICardSystemSettings _settings;
|
||||
private Vector3 _originalScale;
|
||||
private bool _waitingForTap = false;
|
||||
|
||||
private void Awake()
|
||||
@@ -37,16 +35,18 @@ namespace UI.CardSystem.StateMachine.States
|
||||
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
// Store original scale
|
||||
_originalScale = _context.RootTransform.localScale;
|
||||
_waitingForTap = false;
|
||||
|
||||
// Query current collection state for this card
|
||||
bool isNew = Data.CardSystem.CardSystemManager.Instance.IsCardNew(_context.CardData, out CardData existingCard);
|
||||
int currentOwnedCount = (existingCard != null) ? existingCard.CopiesOwned : 0;
|
||||
|
||||
// Show progress bar
|
||||
if (progressBar != null)
|
||||
{
|
||||
progressBar.gameObject.SetActive(true);
|
||||
|
||||
int currentCount = _context.RepeatCardCount + 1; // +1 because we just got this card
|
||||
int currentCount = currentOwnedCount + 1; // +1 because we just got this card
|
||||
int maxCount = _settings.CardsToUpgrade;
|
||||
|
||||
progressBar.ShowProgress(currentCount, maxCount, OnProgressComplete);
|
||||
@@ -66,111 +66,114 @@ namespace UI.CardSystem.StateMachine.States
|
||||
|
||||
private void OnProgressComplete()
|
||||
{
|
||||
// Check if this card triggers an upgrade
|
||||
if (ShouldTriggerUpgrade())
|
||||
// Query current state again to determine if upgrade is triggered
|
||||
Data.CardSystem.CardSystemManager.Instance.IsCardNew(_context.CardData, out CardData existingCard);
|
||||
int currentOwnedCount = (existingCard != null) ? existingCard.CopiesOwned : 0;
|
||||
int countWithThisCard = currentOwnedCount + 1;
|
||||
|
||||
bool willUpgrade = (_context.CardData.Rarity < AppleHills.Data.CardSystem.CardRarity.Legendary) &&
|
||||
(countWithThisCard >= _settings.CardsToUpgrade);
|
||||
|
||||
if (willUpgrade)
|
||||
{
|
||||
Logging.Debug($"[CardEnlargedRepeatState] Card will trigger upgrade! ({_context.RepeatCardCount + 1}/{_settings.CardsToUpgrade})");
|
||||
Logging.Debug($"[CardEnlargedRepeatState] Card will trigger upgrade! ({countWithThisCard}/{_settings.CardsToUpgrade})");
|
||||
TriggerUpgrade();
|
||||
}
|
||||
else
|
||||
{
|
||||
// No upgrade - just wait for tap to dismiss
|
||||
Logging.Debug($"[CardEnlargedRepeatState] Progress shown, waiting for tap to dismiss");
|
||||
Logging.Debug($"[CardEnlargedRepeatState] Progress shown ({countWithThisCard}/{_settings.CardsToUpgrade}), waiting for tap to dismiss");
|
||||
_waitingForTap = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShouldTriggerUpgrade()
|
||||
{
|
||||
int currentCount = _context.RepeatCardCount + 1; // +1 for the card we just got
|
||||
CardRarity currentRarity = _context.CardData.Rarity;
|
||||
|
||||
// Can't upgrade if already Legendary
|
||||
if (currentRarity == CardRarity.Legendary)
|
||||
return false;
|
||||
|
||||
// Check if we've hit the threshold
|
||||
return currentCount >= _settings.CardsToUpgrade;
|
||||
}
|
||||
|
||||
private void TriggerUpgrade()
|
||||
{
|
||||
_context.FireUpgradeTriggered();
|
||||
|
||||
CardData cardData = _context.CardData;
|
||||
CardRarity oldRarity = cardData.Rarity;
|
||||
CardRarity newRarity = oldRarity + 1;
|
||||
|
||||
|
||||
Logging.Debug($"[CardEnlargedRepeatState] Upgrading card from {oldRarity} to {newRarity}");
|
||||
|
||||
var inventory = Data.CardSystem.CardSystemManager.Instance.GetCardInventory();
|
||||
|
||||
// Get the existing card at lower rarity from inventory
|
||||
CardData existingLowerRarity = Data.CardSystem.CardSystemManager.Instance.GetCardInventory().GetCard(cardData.Name, oldRarity);
|
||||
|
||||
if (existingLowerRarity != null)
|
||||
// Remove lower rarity card counts (set to 1 per new rule instead of zeroing out)
|
||||
CardRarity clearRarity = cardData.Rarity;
|
||||
while (clearRarity < newRarity)
|
||||
{
|
||||
// Reset lower rarity count to 0
|
||||
existingLowerRarity.CopiesOwned = 0;
|
||||
var lower = inventory.GetCard(cardData.DefinitionId, clearRarity);
|
||||
if (lower != null) lower.CopiesOwned = 1; // changed from 0 to 1
|
||||
clearRarity += 1;
|
||||
}
|
||||
|
||||
// Create upgraded card data
|
||||
CardData upgradedCard = new CardData(cardData);
|
||||
upgradedCard.Rarity = newRarity;
|
||||
upgradedCard.CopiesOwned = 1;
|
||||
// Check if higher rarity already exists BEFORE adding
|
||||
CardData existingHigher = inventory.GetCard(cardData.DefinitionId, newRarity);
|
||||
bool higherExists = existingHigher != null;
|
||||
|
||||
// Check if this card is new at the higher rarity
|
||||
bool isNewAtHigherRarity = Data.CardSystem.CardSystemManager.Instance.IsCardNew(upgradedCard, out CardData existingHigherRarity);
|
||||
|
||||
// Add to inventory
|
||||
Data.CardSystem.CardSystemManager.Instance.GetCardInventory().AddCard(upgradedCard);
|
||||
|
||||
// Update our card data to show upgraded rarity
|
||||
cardData.Rarity = newRarity;
|
||||
|
||||
// Update the CardDisplay to show new rarity
|
||||
if (_context.CardDisplay != null)
|
||||
if (higherExists)
|
||||
{
|
||||
_context.CardDisplay.SetupCard(cardData);
|
||||
}
|
||||
|
||||
// Determine next transition
|
||||
if (isNewAtHigherRarity || newRarity == CardRarity.Legendary)
|
||||
{
|
||||
// Show as NEW at higher rarity
|
||||
Logging.Debug($"[CardEnlargedRepeatState] Card is NEW at {newRarity}, transitioning to EnlargedNewState");
|
||||
TransitionToNewCardView();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Already have copies at higher rarity - show progress there too
|
||||
int ownedAtHigherRarity = existingHigherRarity.CopiesOwned;
|
||||
Logging.Debug($"[CardEnlargedRepeatState] Card is REPEAT at {newRarity} ({ownedAtHigherRarity}/{_settings.CardsToUpgrade}), showing progress");
|
||||
|
||||
// Update context for higher rarity
|
||||
_context.IsNewCard = false;
|
||||
_context.RepeatCardCount = ownedAtHigherRarity;
|
||||
|
||||
// Re-enter this state with updated data (will show progress for higher rarity)
|
||||
// First hide current progress, then show new progress
|
||||
// Increment existing higher rarity copies
|
||||
existingHigher.CopiesOwned += 1;
|
||||
|
||||
// Update our displayed card to new rarity
|
||||
cardData.Rarity = newRarity;
|
||||
cardData.CopiesOwned = existingHigher.CopiesOwned; // reflect correct count
|
||||
|
||||
if (_context.CardDisplay != null)
|
||||
{
|
||||
_context.CardDisplay.SetupCard(cardData);
|
||||
}
|
||||
|
||||
// For repeat-at-higher-rarity: show a brief progress update at higher rarity while enlarged
|
||||
int ownedAtHigher = existingHigher.CopiesOwned;
|
||||
if (progressBar != null)
|
||||
{
|
||||
progressBar.ShowProgress(ownedAtHigherRarity + 1, _settings.CardsToUpgrade, () =>
|
||||
progressBar.ShowProgress(ownedAtHigher, _settings.CardsToUpgrade, () =>
|
||||
{
|
||||
// After showing progress at higher rarity, transition to NEW
|
||||
TransitionToNewCardView();
|
||||
// After showing higher-rarity progress, wait for tap to dismiss
|
||||
_waitingForTap = true;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
TransitionToNewCardView();
|
||||
_waitingForTap = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create upgraded card as new rarity
|
||||
CardData upgradedCard = new CardData(cardData);
|
||||
upgradedCard.Rarity = newRarity;
|
||||
upgradedCard.CopiesOwned = 1;
|
||||
|
||||
// Add to inventory
|
||||
inventory.AddCard(upgradedCard);
|
||||
|
||||
// Update current display card to new rarity
|
||||
cardData.Rarity = newRarity;
|
||||
cardData.CopiesOwned = upgradedCard.CopiesOwned;
|
||||
|
||||
if (_context.CardDisplay != null)
|
||||
{
|
||||
_context.CardDisplay.SetupCard(cardData);
|
||||
}
|
||||
|
||||
// Branch based on whether legendary or not
|
||||
if (newRarity == CardRarity.Legendary)
|
||||
{
|
||||
// Show special enlarged legendary presentation, await click to shrink to revealed
|
||||
_context.StateMachine.ChangeState("EnlargedLegendaryRepeatState");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Treat as NEW at higher rarity (enlarged with NEW visuals handled there)
|
||||
_context.StateMachine.ChangeState("EnlargedNewState");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TransitionToNewCardView()
|
||||
{
|
||||
// Update context to show as new card
|
||||
_context.IsNewCard = true;
|
||||
|
||||
// Hide progress bar before transitioning
|
||||
if (progressBar != null)
|
||||
{
|
||||
@@ -178,29 +181,27 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
|
||||
// Transition to EnlargedNewState (card is already enlarged, will show NEW badge)
|
||||
// State will query fresh collection data to determine if truly new
|
||||
_context.StateMachine.ChangeState("EnlargedNewState");
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
public void OnCardClicked(CardContext context)
|
||||
{
|
||||
// Only respond to clicks if waiting for tap
|
||||
if (!_waitingForTap)
|
||||
return;
|
||||
|
||||
// Fire dismissed event
|
||||
_context.FireCardDismissed();
|
||||
|
||||
// Tap to dismiss - shrink back and transition to revealed state
|
||||
if (_context.Animator != null)
|
||||
|
||||
// Tap to dismiss - shrink back to original scale and transition to revealed state
|
||||
if (context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayShrink(_originalScale, onComplete: () =>
|
||||
context.Animator.PlayShrink(context.OriginalScale, onComplete: () =>
|
||||
{
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
context.StateMachine.ChangeState("RevealedState");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,4 +215,3 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Pixelplacement.TweenSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using AppleHills.Core.Settings;
|
||||
using AppleHills.Data.CardSystem;
|
||||
using Core;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
@@ -12,7 +13,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
/// Waiting for click to flip and reveal.
|
||||
/// Based on FlippableCard's idle behavior.
|
||||
/// </summary>
|
||||
public class CardIdleState : AppleState, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
|
||||
public class CardIdleState : AppleState, ICardClickHandler, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||||
{
|
||||
[Header("State-Owned Visuals")]
|
||||
[SerializeField] private GameObject cardBackVisual;
|
||||
@@ -80,10 +81,10 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
public void OnCardClicked(CardContext context)
|
||||
{
|
||||
// Check if card is clickable (prevents multi-flip in booster opening)
|
||||
if (!_context.IsClickable)
|
||||
if (!context.IsClickable)
|
||||
{
|
||||
Logging.Debug($"[CardIdleState] Card is not clickable, ignoring click");
|
||||
return;
|
||||
@@ -92,27 +93,34 @@ namespace UI.CardSystem.StateMachine.States
|
||||
// Stop idle hover and pointer interactions
|
||||
StopIdleHover();
|
||||
|
||||
// Play flip animation directly (no state transition yet)
|
||||
if (_context.Animator != null)
|
||||
// Play flip animation directly
|
||||
if (context.Animator != null)
|
||||
{
|
||||
_context.Animator.PlayFlip(
|
||||
context.Animator.PlayFlip(
|
||||
cardBack: cardBackVisual != null ? cardBackVisual.transform : null,
|
||||
cardFront: _context.CardDisplay != null ? _context.CardDisplay.transform : null,
|
||||
cardFront: context.CardDisplay != null ? context.CardDisplay.transform : null,
|
||||
onComplete: OnFlipComplete
|
||||
);
|
||||
|
||||
_context.Animator.PlayFlipScalePunch();
|
||||
context.Animator.PlayFlipScalePunch();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
// Forward to same logic as routed click to keep behavior unified
|
||||
OnCardClicked(_context);
|
||||
}
|
||||
|
||||
private void OnFlipComplete()
|
||||
{
|
||||
// Fire flip complete event
|
||||
_context.FireFlipComplete();
|
||||
// Query current collection state from CardSystemManager (don't use cached values)
|
||||
bool isNew = Data.CardSystem.CardSystemManager.Instance.IsCardNew(_context.CardData, out CardData existingCard);
|
||||
|
||||
// Transition based on whether this is a new card or repeat
|
||||
if (_context.IsNewCard)
|
||||
if (isNew)
|
||||
{
|
||||
// New card - show "NEW" badge and enlarge
|
||||
_context.StateMachine.ChangeState("EnlargedNewState");
|
||||
}
|
||||
else if (_context.CardData != null && _context.CardData.Rarity == AppleHills.Data.CardSystem.CardRarity.Legendary)
|
||||
@@ -125,13 +133,10 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
}
|
||||
else if (_context.RepeatCardCount > 0)
|
||||
{
|
||||
_context.StateMachine.ChangeState("EnlargedRepeatState");
|
||||
}
|
||||
else
|
||||
{
|
||||
_context.StateMachine.ChangeState("RevealedState");
|
||||
// Repeat card - show progress toward upgrade
|
||||
_context.StateMachine.ChangeState("EnlargedRepeatState");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,4 +175,3 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Core;
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
{
|
||||
@@ -9,7 +8,7 @@ namespace UI.CardSystem.StateMachine.States
|
||||
/// Placed in slot state - card is in an album slot and can be clicked to enlarge.
|
||||
/// Manages the parent slot reference.
|
||||
/// </summary>
|
||||
public class CardPlacedInSlotState : AppleState, IPointerClickHandler
|
||||
public class CardPlacedInSlotState : AppleState, ICardClickHandler
|
||||
{
|
||||
private CardContext _context;
|
||||
private AlbumCardSlot _parentSlot;
|
||||
@@ -51,11 +50,11 @@ namespace UI.CardSystem.StateMachine.States
|
||||
return _parentSlot;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
public void OnCardClicked(CardContext context)
|
||||
{
|
||||
// Click to enlarge when in album
|
||||
Logging.Debug($"[CardPlacedInSlotState] Card clicked in slot, transitioning to enlarged state");
|
||||
_context.StateMachine.ChangeState("AlbumEnlargedState");
|
||||
context.StateMachine.ChangeState("AlbumEnlargedState");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Core.SaveLoad;
|
||||
using AppleHills.Data.CardSystem;
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.CardSystem.StateMachine.States
|
||||
@@ -32,34 +33,35 @@ namespace UI.CardSystem.StateMachine.States
|
||||
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
// Card is at normal size, fully revealed
|
||||
|
||||
// Show appropriate idle badge
|
||||
if (_context.IsNewCard)
|
||||
// Show appropriate idle badge unless suppressed
|
||||
if (_context.SuppressRevealBadges)
|
||||
{
|
||||
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);
|
||||
if (newCardIdleBadge != null) newCardIdleBadge.SetActive(false);
|
||||
if (repeatCardIdleBadge != null) repeatCardIdleBadge.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither new nor repeat - hide both
|
||||
if (newCardIdleBadge != null)
|
||||
newCardIdleBadge.SetActive(false);
|
||||
if (repeatCardIdleBadge != null)
|
||||
repeatCardIdleBadge.SetActive(false);
|
||||
bool isNew = Data.CardSystem.CardSystemManager.Instance.IsCardNew(_context.CardData, out CardData existingCard);
|
||||
int currentOwnedCount = (existingCard != null) ? existingCard.CopiesOwned : 0;
|
||||
if (isNew)
|
||||
{
|
||||
if (newCardIdleBadge != null) newCardIdleBadge.SetActive(true);
|
||||
if (repeatCardIdleBadge != null) repeatCardIdleBadge.SetActive(false);
|
||||
}
|
||||
else if (currentOwnedCount > 0)
|
||||
{
|
||||
if (newCardIdleBadge != null) newCardIdleBadge.SetActive(false);
|
||||
if (repeatCardIdleBadge != null) repeatCardIdleBadge.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newCardIdleBadge != null) newCardIdleBadge.SetActive(false);
|
||||
if (repeatCardIdleBadge != null) repeatCardIdleBadge.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Fire interaction complete event (for BoosterOpeningPage tracking)
|
||||
_context.FireCardInteractionComplete();
|
||||
// Fire reveal flow complete event (signals booster page that this card is done)
|
||||
_context.NotifyRevealComplete();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -72,4 +74,3 @@ namespace UI.CardSystem.StateMachine.States
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user