2025-11-11 20:25:23 +01:00
|
|
|
|
using Core.SaveLoad;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
using UnityEngine.UI;
|
2025-11-12 09:24:27 +01:00
|
|
|
|
using AppleHills.Core.Settings;
|
|
|
|
|
|
using Core;
|
2025-11-11 20:25:23 +01:00
|
|
|
|
|
|
|
|
|
|
namespace UI.CardSystem.StateMachine.States
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Enlarged state for REPEAT cards - shows progress bar toward next rarity upgrade.
|
|
|
|
|
|
/// Owns the ProgressBarUI as a child GameObject.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class CardEnlargedRepeatState : AppleState, IPointerClickHandler
|
|
|
|
|
|
{
|
|
|
|
|
|
[Header("State-Owned Visuals")]
|
|
|
|
|
|
[SerializeField] private GameObject progressBarContainer;
|
|
|
|
|
|
[SerializeField] private Image progressBarFill;
|
|
|
|
|
|
[SerializeField] private TextMeshProUGUI progressText;
|
|
|
|
|
|
|
|
|
|
|
|
private CardContext _context;
|
2025-11-12 09:24:27 +01:00
|
|
|
|
private ICardSystemSettings _settings;
|
2025-11-11 20:25:23 +01:00
|
|
|
|
private Vector3 _originalScale;
|
|
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
_context = GetComponentInParent<CardContext>();
|
2025-11-12 09:24:27 +01:00
|
|
|
|
_settings = GameManager.GetSettingsObject<ICardSystemSettings>();
|
2025-11-11 20:25:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnEnterState()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Store original scale
|
|
|
|
|
|
_originalScale = _context.RootTransform.localScale;
|
|
|
|
|
|
|
|
|
|
|
|
// Show progress bar
|
|
|
|
|
|
if (progressBarContainer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
progressBarContainer.SetActive(true);
|
|
|
|
|
|
UpdateProgressBar();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Enlarge the card
|
|
|
|
|
|
if (_context.Animator != null)
|
|
|
|
|
|
{
|
2025-11-12 09:24:27 +01:00
|
|
|
|
_context.Animator.PlayEnlarge(_settings.NewCardEnlargedScale);
|
2025-11-11 20:25:23 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateProgressBar()
|
|
|
|
|
|
{
|
|
|
|
|
|
int currentCount = _context.RepeatCardCount;
|
2025-11-12 09:24:27 +01:00
|
|
|
|
int cardsToUpgrade = _settings.CardsToUpgrade;
|
2025-11-11 20:25:23 +01:00
|
|
|
|
float progress = (float)currentCount / cardsToUpgrade;
|
|
|
|
|
|
|
|
|
|
|
|
if (progressBarFill != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
progressBarFill.fillAmount = progress;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (progressText != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
progressText.text = $"{currentCount}/{cardsToUpgrade}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 progress bar when leaving state
|
|
|
|
|
|
if (progressBarContainer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
progressBarContainer.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|