Update the card kerfufle

This commit is contained in:
Michal Pikulski
2025-11-11 20:25:23 +01:00
parent 612ca7eae8
commit a42b0099bf
28 changed files with 1259 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
using Core.SaveLoad;
using UnityEngine;
using UnityEngine.EventSystems;
namespace UI.CardSystem.StateMachine.States
{
/// <summary>
/// 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
{
[Header("State-Owned Visuals")]
[SerializeField] private GameObject newCardBadge;
private CardContext _context;
private Vector3 _originalScale;
private void Awake()
{
_context = GetComponentInParent<CardContext>();
}
public override void OnEnterState()
{
// Store original scale
_originalScale = _context.RootTransform.localScale;
// Show NEW badge
if (newCardBadge != null)
{
newCardBadge.SetActive(true);
}
// Enlarge the card
if (_context.Animator != null)
{
_context.Animator.PlayEnlarge();
}
}
public void OnPointerClick(PointerEventData eventData)
{
// Tap to dismiss - shrink back and transition to revealed state
if (_context.Animator != null)
{
_context.Animator.PlayShrink(_originalScale, onComplete: () =>
{
_context.StateMachine.ChangeState("RevealedState");
});
}
}
private void OnDisable()
{
// Hide NEW badge when leaving state
if (newCardBadge != null)
{
newCardBadge.SetActive(false);
}
}
}
}