Files
AppleHillsProduction/Assets/Scripts/UI/CardSystem/StateMachine/States/CardEnlargedNewState.cs
2025-11-11 20:25:23 +01:00

65 lines
1.8 KiB
C#

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);
}
}
}
}