Add booster scoring to card sorting
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,11 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using Core;
|
using Core;
|
||||||
using Core.Lifecycle;
|
using Core.Lifecycle;
|
||||||
using Core.Settings;
|
using Core.Settings;
|
||||||
using Data.CardSystem;
|
|
||||||
using Input;
|
using Input;
|
||||||
using Minigames.CardSorting.Controllers;
|
using Minigames.CardSorting.Controllers;
|
||||||
using Minigames.CardSorting.Core;
|
|
||||||
using Unity.Cinemachine;
|
using Unity.Cinemachine;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -244,20 +243,47 @@ namespace Minigames.CardSorting.Core
|
|||||||
// Stop the conveyor and disable all items
|
// Stop the conveyor and disable all items
|
||||||
Conveyor.StopConveyor();
|
Conveyor.StopConveyor();
|
||||||
|
|
||||||
|
// Start the end game sequence (show boosters, then results)
|
||||||
|
StartCoroutine(EndGameSequence());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator EndGameSequence()
|
||||||
|
{
|
||||||
// Calculate rewards
|
// Calculate rewards
|
||||||
int boosterReward = Score.CalculateBoosterReward();
|
int boosterReward = Score.CalculateBoosterReward();
|
||||||
|
|
||||||
Logging.Debug($"[SortingGameManager] Game ended! Score: {Score.TotalScore}, Boosters: {boosterReward}");
|
Logging.Debug($"[SortingGameManager] Game ended! Score: {Score.TotalScore}, Boosters: {boosterReward}");
|
||||||
|
|
||||||
// Grant boosters
|
// Show booster pack reward UI and wait for completion
|
||||||
if (CardSystemManager.Instance != null)
|
if (boosterReward > 0)
|
||||||
{
|
{
|
||||||
CardSystemManager.Instance.AddBoosterPack(boosterReward);
|
Logging.Debug("[SortingGameManager] Starting booster giver sequence via GameManager");
|
||||||
|
|
||||||
|
var task = GameManager.Instance.GiveBoosterPacksAsync(boosterReward);
|
||||||
|
|
||||||
|
// Wait for the task to complete
|
||||||
|
while (!task.IsCompleted)
|
||||||
|
{
|
||||||
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnGameEnded?.Invoke();
|
// Check for exceptions
|
||||||
|
if (task.IsFaulted)
|
||||||
|
{
|
||||||
|
Logging.Warning($"[SortingGameManager] Booster pack reward failed: {task.Exception?.GetBaseException().Message}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logging.Debug("[SortingGameManager] Booster giver sequence finished, proceeding to results screen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logging.Debug("[SortingGameManager] No boosters to award, proceeding directly to results screen");
|
||||||
|
}
|
||||||
|
|
||||||
// Show results screen (handled by UI controller)
|
// Now show results screen (via event)
|
||||||
|
OnGameEnded?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user