Update the card kerfufle

This commit is contained in:
Michal Pikulski
2025-11-11 20:25:23 +01:00
parent 06cc3bde3b
commit 1fdff3450b
28 changed files with 1259 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
using Core.SaveLoad;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
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;
[SerializeField] private int cardsToUpgrade = 5;
private CardContext _context;
private Vector3 _originalScale;
private void Awake()
{
_context = GetComponentInParent<CardContext>();
}
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)
{
_context.Animator.PlayEnlarge();
}
}
private void UpdateProgressBar()
{
int currentCount = _context.RepeatCardCount;
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);
}
}
}
}