Hammer out some last flows of the booster opening page
This commit is contained in:
@@ -1359,6 +1359,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::UI.CardSystem.CardAlbumOpener
|
||||
openAlbumButton: {fileID: 1514617440643059794}
|
||||
albumViewPage: {fileID: 5982305211081251604}
|
||||
boosterOpeningPage: {fileID: 304904072851265091}
|
||||
--- !u!1 &9208173931017297427
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1506,10 +1507,6 @@ PrefabInstance:
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 245933177249891519, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
propertyPath: openingParticleSystem
|
||||
value:
|
||||
objectReference: {fileID: 6207392896650453636}
|
||||
- target: {fileID: 498445838423597154, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: BoosterOpeningPage
|
||||
@@ -1518,10 +1515,6 @@ PrefabInstance:
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1530993938104875321, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
propertyPath: openingParticleSystem
|
||||
value:
|
||||
objectReference: {fileID: 6207392896650453636}
|
||||
- target: {fileID: 1670660734182863341, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
@@ -1626,12 +1619,9 @@ PrefabInstance:
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6433114534737680452, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
propertyPath: openingParticleSystem
|
||||
value:
|
||||
objectReference: {fileID: 6207392896650453636}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_RemovedGameObjects:
|
||||
- {fileID: 6017052972121068920, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
@@ -1651,11 +1641,6 @@ RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 5228380266581535650, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
m_PrefabInstance: {fileID: 4691000134302573506}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!198 &6207392896650453636 stripped
|
||||
ParticleSystem:
|
||||
m_CorrespondingSourceObject: {fileID: 1674443196371304774, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||
m_PrefabInstance: {fileID: 4691000134302573506}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &5549612182461073321
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -21,7 +21,6 @@ namespace UI.CardSystem
|
||||
{
|
||||
[Header("UI References")]
|
||||
[SerializeField] private CanvasGroup canvasGroup;
|
||||
[SerializeField] private Button closeButton;
|
||||
|
||||
[Header("Booster Management")]
|
||||
[SerializeField] private GameObject boosterPackPrefab; // Prefab to instantiate new boosters
|
||||
@@ -58,23 +57,12 @@ namespace UI.CardSystem
|
||||
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);
|
||||
}
|
||||
|
||||
// Unsubscribe from slot events
|
||||
if (centerOpeningSlot != null)
|
||||
{
|
||||
@@ -86,14 +74,6 @@ namespace UI.CardSystem
|
||||
UnsubscribeFromAllBoosters();
|
||||
}
|
||||
|
||||
private void OnCloseButtonClicked()
|
||||
{
|
||||
if (UIPageController.Instance != null)
|
||||
{
|
||||
UIPageController.Instance.PopPage();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the number of available booster packs before showing the page
|
||||
/// </summary>
|
||||
@@ -165,16 +145,10 @@ namespace UI.CardSystem
|
||||
/// </summary>
|
||||
private void SpawnBoosterInSlot(int slotIndex)
|
||||
{
|
||||
if (slotIndex >= bottomRightSlots.SlotCount)
|
||||
{
|
||||
Debug.LogWarning($"[BoosterOpeningPage] Slot index {slotIndex} out of range!");
|
||||
return;
|
||||
}
|
||||
|
||||
DraggableSlot slot = bottomRightSlots.GetSlotAtIndex(slotIndex);
|
||||
DraggableSlot slot = FindSlotByIndex(slotIndex);
|
||||
if (slot == null)
|
||||
{
|
||||
Debug.LogWarning($"[BoosterOpeningPage] Slot {slotIndex} is null!");
|
||||
Debug.LogWarning($"[BoosterOpeningPage] Could not find slot with SlotIndex {slotIndex}!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -197,7 +171,7 @@ namespace UI.CardSystem
|
||||
// Track it
|
||||
_activeBoostersInSlots.Add(booster);
|
||||
|
||||
Debug.Log($"[BoosterOpeningPage] Spawned booster in slot {slotIndex}");
|
||||
Debug.Log($"[BoosterOpeningPage] Spawned booster in slot with SlotIndex {slotIndex}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -260,6 +234,58 @@ namespace UI.CardSystem
|
||||
Debug.Log($"[BoosterOpeningPage] Updated visible boosters: {_activeBoostersInSlots.Count}/{targetCount}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shuffle boosters so they always occupy the first available slots
|
||||
/// </summary>
|
||||
private void ShuffleBoostersToFront()
|
||||
{
|
||||
if (_activeBoostersInSlots.Count == 0) return;
|
||||
|
||||
Debug.Log($"[BoosterOpeningPage] Shuffling {_activeBoostersInSlots.Count} boosters to front slots");
|
||||
|
||||
// Unassign all boosters from their current slots
|
||||
foreach (var booster in _activeBoostersInSlots)
|
||||
{
|
||||
if (booster.CurrentSlot != null)
|
||||
{
|
||||
booster.CurrentSlot.Vacate();
|
||||
}
|
||||
}
|
||||
|
||||
// Reassign boosters to first N slots starting from slot with SlotIndex 0
|
||||
for (int i = 0; i < _activeBoostersInSlots.Count; i++)
|
||||
{
|
||||
// Find slot by its actual SlotIndex property
|
||||
DraggableSlot targetSlot = FindSlotByIndex(i);
|
||||
BoosterPackDraggable booster = _activeBoostersInSlots[i];
|
||||
|
||||
if (targetSlot != null)
|
||||
{
|
||||
Debug.Log($"[BoosterOpeningPage] Assigning booster to slot with SlotIndex {i} {targetSlot.name}");
|
||||
booster.AssignToSlot(targetSlot, true); // Animate the move
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[BoosterOpeningPage] Could not find slot with SlotIndex {i} {targetSlot.name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find a slot by its SlotIndex property (not list position)
|
||||
/// </summary>
|
||||
private DraggableSlot FindSlotByIndex(int slotIndex)
|
||||
{
|
||||
foreach (var slot in bottomRightSlots.Slots)
|
||||
{
|
||||
if (slot.SlotIndex == slotIndex)
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to spawn a new booster to maintain up to 3 visible
|
||||
/// Pass decrementCount=true when called after placing a booster in center slot
|
||||
@@ -278,14 +304,14 @@ namespace UI.CardSystem
|
||||
if (_activeBoostersInSlots.Count >= effectiveCount)
|
||||
return; // No more boosters available
|
||||
|
||||
// Find first available slot
|
||||
// Find first available slot by SlotIndex (0, 1, 2)
|
||||
for (int i = 0; i < MAX_VISIBLE_BOOSTERS; i++)
|
||||
{
|
||||
DraggableSlot slot = bottomRightSlots.GetSlotAtIndex(i);
|
||||
DraggableSlot slot = FindSlotByIndex(i);
|
||||
if (slot != null && !slot.IsOccupied)
|
||||
{
|
||||
SpawnBoosterInSlot(i);
|
||||
Debug.Log($"[BoosterOpeningPage] Spawned new booster in slot {i}");
|
||||
Debug.Log($"[BoosterOpeningPage] Spawned new booster in slot with SlotIndex {i}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -322,6 +348,9 @@ namespace UI.CardSystem
|
||||
// Use decrementCount=true because this booster will be consumed
|
||||
TrySpawnNewBooster(decrementCount: true);
|
||||
|
||||
// Shuffle remaining boosters to occupy the first slots
|
||||
ShuffleBoostersToFront();
|
||||
|
||||
Debug.Log($"[BoosterOpeningPage] Booster placed in center, ready for taps. Active boosters in slots: {_activeBoostersInSlots.Count}");
|
||||
}
|
||||
|
||||
@@ -442,12 +471,17 @@ namespace UI.CardSystem
|
||||
SpawnCardBacks(_currentCardData.Length);
|
||||
|
||||
// Wait for player to reveal all cards
|
||||
bool isLastBooster = _availableBoosterCount <= 0;
|
||||
yield return StartCoroutine(WaitForCardReveals());
|
||||
|
||||
if (_availableBoosterCount <= 0)
|
||||
// Check if this was the last booster pack
|
||||
if (isLastBooster)
|
||||
{
|
||||
// No more boosters, auto-close page
|
||||
yield return new WaitForSeconds(1f);
|
||||
// Wait for all card animations to complete before transitioning
|
||||
// WaitForCardReveals already includes: 0.5s wait + (cardCount * 0.5s stagger) + 0.5s animation + 0.5s final
|
||||
// Total is: 1.5s + (cardCount * 0.5s)
|
||||
// For 5 cards that's 4 seconds total, which should be enough
|
||||
Debug.Log("[BoosterOpeningPage] Last booster opened, auto-transitioning to album main page");
|
||||
if (UIPageController.Instance != null)
|
||||
{
|
||||
UIPageController.Instance.PopPage();
|
||||
@@ -753,9 +787,14 @@ namespace UI.CardSystem
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all animations to complete
|
||||
// Last card starts at: (cardCount - 1) * 0.5s delay
|
||||
// Last card finishes at: (cardCount - 1) * 0.5s + 0.5s animation duration = cardCount * 0.5s
|
||||
float totalAnimationTime = _currentCardData.Length * 0.5f;
|
||||
|
||||
_currentRevealedCards.Clear();
|
||||
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
yield return new WaitForSeconds(totalAnimationTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace UI.CardSystem
|
||||
[Header("References")]
|
||||
[SerializeField] private Button openAlbumButton;
|
||||
[SerializeField] private AlbumViewPage albumViewPage;
|
||||
[SerializeField] private BoosterOpeningPage boosterOpeningPage;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -48,24 +49,41 @@ namespace UI.CardSystem
|
||||
|
||||
private void OnOpenAlbumClicked()
|
||||
{
|
||||
if (openAlbumButton != null)
|
||||
{
|
||||
openAlbumButton.gameObject.SetActive(false);
|
||||
}
|
||||
if (UIPageController.Instance == null) return;
|
||||
|
||||
if (albumViewPage != null && UIPageController.Instance != null)
|
||||
// Check if we're currently on the booster opening page
|
||||
if (UIPageController.Instance.CurrentPage == boosterOpeningPage)
|
||||
{
|
||||
UIPageController.Instance.PushPage(albumViewPage);
|
||||
// We're in booster opening page, pop back to album main page
|
||||
UIPageController.Instance.PopPage();
|
||||
}
|
||||
else if (UIPageController.Instance.CurrentPage != albumViewPage)
|
||||
{
|
||||
// We're not in the album at all, open it
|
||||
if (openAlbumButton != null)
|
||||
{
|
||||
openAlbumButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (albumViewPage != null)
|
||||
{
|
||||
UIPageController.Instance.PushPage(albumViewPage);
|
||||
}
|
||||
}
|
||||
// If we're already on the album main page, do nothing
|
||||
}
|
||||
|
||||
private void OnPageChanged(UIPage currentPage)
|
||||
{
|
||||
// If the album page is no longer active, show the button again
|
||||
if (currentPage != albumViewPage && openAlbumButton != null)
|
||||
{
|
||||
openAlbumButton.gameObject.SetActive(true);
|
||||
}
|
||||
if (openAlbumButton == null) return;
|
||||
|
||||
// Show the button when:
|
||||
// 1. We're on the booster opening page (acts as "back to album" button)
|
||||
// 2. We're NOT on the album main page (acts as "open album" button)
|
||||
// Hide the button only when we're on the album main page
|
||||
|
||||
bool shouldShowButton = currentPage == boosterOpeningPage || currentPage != albumViewPage;
|
||||
openAlbumButton.gameObject.SetActive(shouldShowButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI.CardSystem
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace UI.DragAndDrop.Core
|
||||
}
|
||||
|
||||
[Header("Slot Settings")]
|
||||
[SerializeField] private int slotIndex;
|
||||
[SerializeField] private int slotIndex = -1;
|
||||
[SerializeField] private bool isLocked;
|
||||
[SerializeField] private bool hideImageOnPlay = false;
|
||||
|
||||
|
||||
@@ -69,7 +69,13 @@ namespace UI.DragAndDrop.Core
|
||||
return;
|
||||
|
||||
_slots.Add(slot);
|
||||
slot.SetSlotIndex(_slots.Count - 1);
|
||||
|
||||
// Only auto-assign index if slot's index is -1 (default/unset)
|
||||
// Otherwise keep the custom index set in the inspector
|
||||
if (slot.SlotIndex == -1)
|
||||
{
|
||||
slot.SetSlotIndex(_slots.Count - 1);
|
||||
}
|
||||
|
||||
OnSlotAdded?.Invoke(slot);
|
||||
UpdateLayout();
|
||||
@@ -86,11 +92,8 @@ namespace UI.DragAndDrop.Core
|
||||
_slots.Remove(slot);
|
||||
OnSlotRemoved?.Invoke(slot);
|
||||
|
||||
// Re-index remaining slots
|
||||
for (int i = 0; i < _slots.Count; i++)
|
||||
{
|
||||
_slots[i].SetSlotIndex(i);
|
||||
}
|
||||
// Note: We don't re-index remaining slots anymore to preserve custom indices
|
||||
// Slots with custom indices will keep them, slots with auto-assigned indices will also keep them
|
||||
|
||||
UpdateLayout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user