Move buttons to HUD Manager

This commit is contained in:
Michal Pikulski
2025-11-09 13:23:03 +01:00
parent a80aed8eb7
commit 0c9a388433
18 changed files with 2326 additions and 3998 deletions

View File

@@ -37,8 +37,9 @@ namespace UI.CardSystem
[SerializeField] private float boosterDisappearDuration = 0.5f;
[SerializeField] private CinemachineImpulseSource impulseSource;
[SerializeField] private ParticleSystem openingParticleSystem;
[SerializeField] private Transform albumIcon; // Target for card fly-away animation
[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<BoosterPackDraggable> _activeBoostersInSlots = new List<BoosterPackDraggable>();
@@ -57,12 +58,32 @@ namespace UI.CardSystem
if (canvasGroup == null)
canvasGroup = gameObject.AddComponent<CanvasGroup>();
// Get dismiss button from albumIcon GameObject
if (albumIcon != null)
{
_dismissButton = albumIcon.GetComponent<Button>();
if (_dismissButton != null)
{
_dismissButton.onClick.AddListener(OnDismissButtonClicked);
}
else
{
Debug.LogWarning("[BoosterOpeningPage] albumIcon does not have a Button component!");
}
}
// UI pages should start disabled
gameObject.SetActive(false);
}
private void OnDestroy()
{
// Unsubscribe from dismiss button
if (_dismissButton != null)
{
_dismissButton.onClick.RemoveListener(OnDismissButtonClicked);
}
// Unsubscribe from slot events
if (centerOpeningSlot != null)
{
@@ -81,6 +102,18 @@ namespace UI.CardSystem
{
_availableBoosterCount = count;
}
/// <summary>
/// Called when the dismiss button (albumIcon) is clicked
/// </summary>
private void OnDismissButtonClicked()
{
if (UIPageController.Instance != null)
{
UIPageController.Instance.PopPage();
Debug.Log("[BoosterOpeningPage] Dismiss button clicked, popping page from stack");
}
}
public override void TransitionIn()
{
@@ -768,7 +801,7 @@ namespace UI.CardSystem
yield return new WaitForSeconds(0.5f);
// Animate cards to album icon (or center if no icon assigned) with staggered delays
Vector3 targetPosition = albumIcon != null ? albumIcon.position : Vector3.zero;
Vector3 targetPosition = albumIcon != null ? albumIcon.transform.position : Vector3.zero;
int cardIndex = 0;
foreach (GameObject cardObj in _currentRevealedCards)