69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
using Core.SaveLoad;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using AppleHills.Core.Settings;
|
|
using Core;
|
|
|
|
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 ICardSystemSettings _settings;
|
|
private Vector3 _originalScale;
|
|
|
|
private void Awake()
|
|
{
|
|
_context = GetComponentInParent<CardContext>();
|
|
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
|
}
|
|
|
|
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(_settings.NewCardEnlargedScale);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|