using System.Collections; using System.Collections.Generic; using System.Linq; using AppleHills.Data.CardSystem; using Core; using Data.CardSystem; using Pixelplacement; using UI.Core; using UI.CardSystem.DragDrop; using UI.DragAndDrop.Core; using Unity.Cinemachine; using UnityEngine; using UnityEngine.UI; namespace UI.CardSystem { /// /// UI page for opening booster packs and displaying the cards received. /// Manages the entire booster opening flow with drag-and-drop interaction. /// public class BoosterOpeningPage : UIPage { [Header("UI References")] [SerializeField] private CanvasGroup canvasGroup; [Header("Booster Management")] [SerializeField] private GameObject boosterPackPrefab; // Prefab to instantiate new boosters [SerializeField] private SlotContainer bottomRightSlots; // Holds waiting boosters (max 3) [SerializeField] private DraggableSlot centerOpeningSlot; // Where booster goes to open [Header("Card Display")] [SerializeField] private Transform cardDisplayContainer; [SerializeField] private GameObject flippableCardPrefab; // Placeholder for card backs [SerializeField] private float cardSpacing = 150f; [Header("Settings")] [SerializeField] private float boosterDisappearDuration = 0.5f; [SerializeField] private CinemachineImpulseSource impulseSource; [SerializeField] private ParticleSystem openingParticleSystem; [SerializeField] private GameObject albumIcon; // Target for card fly-away animation and dismiss button private Button _dismissButton; // Button to close/dismiss the booster opening page private int _availableBoosterCount; private BoosterPackDraggable _currentBoosterInCenter; private List _activeBoostersInSlots = new List(); private List _currentRevealedCards = new List(); private CardData[] _currentCardData; private int _revealedCardCount; private int _cardsCompletedInteraction; // Track how many cards finished their new/repeat interaction private bool _isProcessingOpening; private const int MAX_VISIBLE_BOOSTERS = 3; private FlippableCard _currentActiveCard; // The card currently awaiting interaction private void Awake() { // Make sure we have a CanvasGroup for transitions if (canvasGroup == null) canvasGroup = GetComponent(); if (canvasGroup == null) canvasGroup = gameObject.AddComponent(); // Get dismiss button from albumIcon GameObject if (albumIcon != null) { _dismissButton = albumIcon.GetComponent