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
|
m_EditorClassIdentifier: AppleHillsScripts::UI.CardSystem.CardAlbumOpener
|
||||||
openAlbumButton: {fileID: 1514617440643059794}
|
openAlbumButton: {fileID: 1514617440643059794}
|
||||||
albumViewPage: {fileID: 5982305211081251604}
|
albumViewPage: {fileID: 5982305211081251604}
|
||||||
|
boosterOpeningPage: {fileID: 304904072851265091}
|
||||||
--- !u!1 &9208173931017297427
|
--- !u!1 &9208173931017297427
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1506,10 +1507,6 @@ PrefabInstance:
|
|||||||
propertyPath: m_SizeDelta.x
|
propertyPath: m_SizeDelta.x
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 245933177249891519, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
|
||||||
propertyPath: openingParticleSystem
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 6207392896650453636}
|
|
||||||
- target: {fileID: 498445838423597154, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
- target: {fileID: 498445838423597154, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: BoosterOpeningPage
|
value: BoosterOpeningPage
|
||||||
@@ -1518,10 +1515,6 @@ PrefabInstance:
|
|||||||
propertyPath: m_SizeDelta.x
|
propertyPath: m_SizeDelta.x
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1530993938104875321, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
|
||||||
propertyPath: openingParticleSystem
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 6207392896650453636}
|
|
||||||
- target: {fileID: 1670660734182863341, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
- target: {fileID: 1670660734182863341, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||||
propertyPath: m_SizeDelta.x
|
propertyPath: m_SizeDelta.x
|
||||||
value: 0
|
value: 0
|
||||||
@@ -1626,12 +1619,9 @@ PrefabInstance:
|
|||||||
propertyPath: m_SizeDelta.x
|
propertyPath: m_SizeDelta.x
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6433114534737680452, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
|
||||||
propertyPath: openingParticleSystem
|
|
||||||
value:
|
|
||||||
objectReference: {fileID: 6207392896650453636}
|
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects:
|
||||||
|
- {fileID: 6017052972121068920, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
m_AddedComponents: []
|
m_AddedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||||
@@ -1651,11 +1641,6 @@ RectTransform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 5228380266581535650, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
m_CorrespondingSourceObject: {fileID: 5228380266581535650, guid: 8ebde0b07986e69419b050433d30ccd2, type: 3}
|
||||||
m_PrefabInstance: {fileID: 4691000134302573506}
|
m_PrefabInstance: {fileID: 4691000134302573506}
|
||||||
m_PrefabAsset: {fileID: 0}
|
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
|
--- !u!1001 &5549612182461073321
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -21,7 +21,6 @@ namespace UI.CardSystem
|
|||||||
{
|
{
|
||||||
[Header("UI References")]
|
[Header("UI References")]
|
||||||
[SerializeField] private CanvasGroup canvasGroup;
|
[SerializeField] private CanvasGroup canvasGroup;
|
||||||
[SerializeField] private Button closeButton;
|
|
||||||
|
|
||||||
[Header("Booster Management")]
|
[Header("Booster Management")]
|
||||||
[SerializeField] private GameObject boosterPackPrefab; // Prefab to instantiate new boosters
|
[SerializeField] private GameObject boosterPackPrefab; // Prefab to instantiate new boosters
|
||||||
@@ -58,23 +57,12 @@ namespace UI.CardSystem
|
|||||||
if (canvasGroup == null)
|
if (canvasGroup == null)
|
||||||
canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
||||||
|
|
||||||
// Set up close button
|
|
||||||
if (closeButton != null)
|
|
||||||
{
|
|
||||||
closeButton.onClick.AddListener(OnCloseButtonClicked);
|
|
||||||
}
|
|
||||||
|
|
||||||
// UI pages should start disabled
|
// UI pages should start disabled
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
if (closeButton != null)
|
|
||||||
{
|
|
||||||
closeButton.onClick.RemoveListener(OnCloseButtonClicked);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unsubscribe from slot events
|
// Unsubscribe from slot events
|
||||||
if (centerOpeningSlot != null)
|
if (centerOpeningSlot != null)
|
||||||
{
|
{
|
||||||
@@ -86,14 +74,6 @@ namespace UI.CardSystem
|
|||||||
UnsubscribeFromAllBoosters();
|
UnsubscribeFromAllBoosters();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCloseButtonClicked()
|
|
||||||
{
|
|
||||||
if (UIPageController.Instance != null)
|
|
||||||
{
|
|
||||||
UIPageController.Instance.PopPage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the number of available booster packs before showing the page
|
/// Set the number of available booster packs before showing the page
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -165,16 +145,10 @@ namespace UI.CardSystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void SpawnBoosterInSlot(int slotIndex)
|
private void SpawnBoosterInSlot(int slotIndex)
|
||||||
{
|
{
|
||||||
if (slotIndex >= bottomRightSlots.SlotCount)
|
DraggableSlot slot = FindSlotByIndex(slotIndex);
|
||||||
{
|
|
||||||
Debug.LogWarning($"[BoosterOpeningPage] Slot index {slotIndex} out of range!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DraggableSlot slot = bottomRightSlots.GetSlotAtIndex(slotIndex);
|
|
||||||
if (slot == null)
|
if (slot == null)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"[BoosterOpeningPage] Slot {slotIndex} is null!");
|
Debug.LogWarning($"[BoosterOpeningPage] Could not find slot with SlotIndex {slotIndex}!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +171,7 @@ namespace UI.CardSystem
|
|||||||
// Track it
|
// Track it
|
||||||
_activeBoostersInSlots.Add(booster);
|
_activeBoostersInSlots.Add(booster);
|
||||||
|
|
||||||
Debug.Log($"[BoosterOpeningPage] Spawned booster in slot {slotIndex}");
|
Debug.Log($"[BoosterOpeningPage] Spawned booster in slot with SlotIndex {slotIndex}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -260,6 +234,58 @@ namespace UI.CardSystem
|
|||||||
Debug.Log($"[BoosterOpeningPage] Updated visible boosters: {_activeBoostersInSlots.Count}/{targetCount}");
|
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>
|
/// <summary>
|
||||||
/// Try to spawn a new booster to maintain up to 3 visible
|
/// Try to spawn a new booster to maintain up to 3 visible
|
||||||
/// Pass decrementCount=true when called after placing a booster in center slot
|
/// Pass decrementCount=true when called after placing a booster in center slot
|
||||||
@@ -278,14 +304,14 @@ namespace UI.CardSystem
|
|||||||
if (_activeBoostersInSlots.Count >= effectiveCount)
|
if (_activeBoostersInSlots.Count >= effectiveCount)
|
||||||
return; // No more boosters available
|
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++)
|
for (int i = 0; i < MAX_VISIBLE_BOOSTERS; i++)
|
||||||
{
|
{
|
||||||
DraggableSlot slot = bottomRightSlots.GetSlotAtIndex(i);
|
DraggableSlot slot = FindSlotByIndex(i);
|
||||||
if (slot != null && !slot.IsOccupied)
|
if (slot != null && !slot.IsOccupied)
|
||||||
{
|
{
|
||||||
SpawnBoosterInSlot(i);
|
SpawnBoosterInSlot(i);
|
||||||
Debug.Log($"[BoosterOpeningPage] Spawned new booster in slot {i}");
|
Debug.Log($"[BoosterOpeningPage] Spawned new booster in slot with SlotIndex {i}");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,6 +348,9 @@ namespace UI.CardSystem
|
|||||||
// Use decrementCount=true because this booster will be consumed
|
// Use decrementCount=true because this booster will be consumed
|
||||||
TrySpawnNewBooster(decrementCount: true);
|
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}");
|
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);
|
SpawnCardBacks(_currentCardData.Length);
|
||||||
|
|
||||||
// Wait for player to reveal all cards
|
// Wait for player to reveal all cards
|
||||||
|
bool isLastBooster = _availableBoosterCount <= 0;
|
||||||
yield return StartCoroutine(WaitForCardReveals());
|
yield return StartCoroutine(WaitForCardReveals());
|
||||||
|
|
||||||
if (_availableBoosterCount <= 0)
|
// Check if this was the last booster pack
|
||||||
|
if (isLastBooster)
|
||||||
{
|
{
|
||||||
// No more boosters, auto-close page
|
// Wait for all card animations to complete before transitioning
|
||||||
yield return new WaitForSeconds(1f);
|
// 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)
|
if (UIPageController.Instance != null)
|
||||||
{
|
{
|
||||||
UIPageController.Instance.PopPage();
|
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();
|
_currentRevealedCards.Clear();
|
||||||
|
|
||||||
yield return new WaitForSeconds(0.5f);
|
yield return new WaitForSeconds(totalAnimationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace UI.CardSystem
|
|||||||
[Header("References")]
|
[Header("References")]
|
||||||
[SerializeField] private Button openAlbumButton;
|
[SerializeField] private Button openAlbumButton;
|
||||||
[SerializeField] private AlbumViewPage albumViewPage;
|
[SerializeField] private AlbumViewPage albumViewPage;
|
||||||
|
[SerializeField] private BoosterOpeningPage boosterOpeningPage;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@@ -48,24 +49,41 @@ namespace UI.CardSystem
|
|||||||
|
|
||||||
private void OnOpenAlbumClicked()
|
private void OnOpenAlbumClicked()
|
||||||
{
|
{
|
||||||
if (openAlbumButton != null)
|
if (UIPageController.Instance == null) return;
|
||||||
|
|
||||||
|
// Check if we're currently on the booster opening page
|
||||||
|
if (UIPageController.Instance.CurrentPage == boosterOpeningPage)
|
||||||
{
|
{
|
||||||
openAlbumButton.gameObject.SetActive(false);
|
// 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 != null)
|
if (albumViewPage != null)
|
||||||
{
|
{
|
||||||
UIPageController.Instance.PushPage(albumViewPage);
|
UIPageController.Instance.PushPage(albumViewPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// If we're already on the album main page, do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPageChanged(UIPage currentPage)
|
private void OnPageChanged(UIPage currentPage)
|
||||||
{
|
{
|
||||||
// If the album page is no longer active, show the button again
|
if (openAlbumButton == null) return;
|
||||||
if (currentPage != albumViewPage && openAlbumButton != null)
|
|
||||||
{
|
// Show the button when:
|
||||||
openAlbumButton.gameObject.SetActive(true);
|
// 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 Pixelplacement.TweenSystem;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace UI.CardSystem
|
namespace UI.CardSystem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace UI.DragAndDrop.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Header("Slot Settings")]
|
[Header("Slot Settings")]
|
||||||
[SerializeField] private int slotIndex;
|
[SerializeField] private int slotIndex = -1;
|
||||||
[SerializeField] private bool isLocked;
|
[SerializeField] private bool isLocked;
|
||||||
[SerializeField] private bool hideImageOnPlay = false;
|
[SerializeField] private bool hideImageOnPlay = false;
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,13 @@ namespace UI.DragAndDrop.Core
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_slots.Add(slot);
|
_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);
|
OnSlotAdded?.Invoke(slot);
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
@@ -86,11 +92,8 @@ namespace UI.DragAndDrop.Core
|
|||||||
_slots.Remove(slot);
|
_slots.Remove(slot);
|
||||||
OnSlotRemoved?.Invoke(slot);
|
OnSlotRemoved?.Invoke(slot);
|
||||||
|
|
||||||
// Re-index remaining slots
|
// Note: We don't re-index remaining slots anymore to preserve custom indices
|
||||||
for (int i = 0; i < _slots.Count; i++)
|
// Slots with custom indices will keep them, slots with auto-assigned indices will also keep them
|
||||||
{
|
|
||||||
_slots[i].SetSlotIndex(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user