95 lines
3.0 KiB
C#
95 lines
3.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using AppleHills.Data.CardSystem;
|
|
using Data.CardSystem;
|
|
using Pixelplacement;
|
|
using UI.Core;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace UI.CardSystem
|
|
{
|
|
/// <summary>
|
|
/// UI page for opening booster packs and displaying the cards received.
|
|
/// Automatically triggers the opening when the page is shown.
|
|
/// </summary>
|
|
public class BoosterOpeningPage : UIPage
|
|
{
|
|
[Header("UI References")]
|
|
[SerializeField] private CanvasGroup canvasGroup;
|
|
[SerializeField] private Button closeButton;
|
|
|
|
[Header("Card Display")]
|
|
[SerializeField] private Transform cardDisplayContainer;
|
|
[SerializeField] private CardDisplay cardDisplayPrefab;
|
|
|
|
[Header("Settings")]
|
|
[SerializeField] private float cardRevealDelay = 0.5f;
|
|
[SerializeField] private float cardSpacing = 50f;
|
|
|
|
private void Awake()
|
|
{
|
|
// Make sure we have a CanvasGroup for transitions
|
|
if (canvasGroup == null)
|
|
canvasGroup = GetComponent<CanvasGroup>();
|
|
if (canvasGroup == null)
|
|
canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
|
|
|
// Set up close button
|
|
if (closeButton != null)
|
|
{
|
|
closeButton.onClick.AddListener(OnCloseButtonClicked);
|
|
}
|
|
|
|
// UI pages should start disabled
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (closeButton != null)
|
|
{
|
|
closeButton.onClick.RemoveListener(OnCloseButtonClicked);
|
|
}
|
|
}
|
|
|
|
private void OnCloseButtonClicked()
|
|
{
|
|
if (UIPageController.Instance != null)
|
|
{
|
|
UIPageController.Instance.PopPage();
|
|
}
|
|
}
|
|
|
|
protected override void DoTransitionIn(System.Action onComplete)
|
|
{
|
|
// Simple fade in animation
|
|
if (canvasGroup != null)
|
|
{
|
|
canvasGroup.alpha = 0f;
|
|
Tween.Value(0f, 1f, (value) => canvasGroup.alpha = value, transitionDuration, 0f, Tween.EaseInOut, Tween.LoopType.None, null, onComplete, obeyTimescale: false);
|
|
}
|
|
else
|
|
{
|
|
// Fallback if no CanvasGroup
|
|
onComplete?.Invoke();
|
|
}
|
|
}
|
|
|
|
protected override void DoTransitionOut(System.Action onComplete)
|
|
{
|
|
// Simple fade out animation
|
|
if (canvasGroup != null)
|
|
{
|
|
Tween.Value(canvasGroup.alpha, 0f, (value) => canvasGroup.alpha = value, transitionDuration, 0f, Tween.EaseInOut, Tween.LoopType.None, null, onComplete, obeyTimescale: false);
|
|
}
|
|
else
|
|
{
|
|
// Fallback if no CanvasGroup
|
|
onComplete?.Invoke();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|