Add booster scoring to card sorting

This commit is contained in:
Michal Pikulski
2025-12-15 12:29:06 +01:00
parent bb332933ec
commit a45ab2f543
3 changed files with 1558 additions and 82 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,10 @@
using System;
using System.Collections;
using Core;
using Core.Lifecycle;
using Core.Settings;
using Data.CardSystem;
using Input;
using Minigames.CardSorting.Controllers;
using Minigames.CardSorting.Core;
using Unity.Cinemachine;
using UnityEngine;
@@ -244,20 +243,47 @@ namespace Minigames.CardSorting.Core
// Stop the conveyor and disable all items
Conveyor.StopConveyor();
// Start the end game sequence (show boosters, then results)
StartCoroutine(EndGameSequence());
}
private IEnumerator EndGameSequence()
{
// Calculate rewards
int boosterReward = Score.CalculateBoosterReward();
Logging.Debug($"[SortingGameManager] Game ended! Score: {Score.TotalScore}, Boosters: {boosterReward}");
// Grant boosters
if (CardSystemManager.Instance != null)
// Show booster pack reward UI and wait for completion
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;
}
// 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");
}
// Now show results screen (via event)
OnGameEnded?.Invoke();
// Show results screen (handled by UI controller)
}
/// <summary>