Merge branch 'main' into DamianBranch

This commit is contained in:
2025-12-19 17:01:08 +01:00
13 changed files with 257 additions and 205 deletions

View File

@@ -55,7 +55,7 @@ MonoBehaviour:
- {fileID: 5158233508174186704}
- {fileID: 7317268573047108242}
glowImage: {fileID: 4006246129058447062}
continueButton: {fileID: 2988510625873934392}
continueButton: {fileID: 0}
hoverAmount: 20
hoverDuration: 1.5
glowPulseMax: 1.1
@@ -173,131 +173,11 @@ RectTransform:
- {fileID: 3680365639323743419}
m_Father: {fileID: 2499229096808986326}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -300}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 750, y: 760}
m_Pivot: {x: 0.5, y: 1}
--- !u!1 &4323719263405703996
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6841858894429745291}
- component: {fileID: 1590188508543769496}
- component: {fileID: 4489841151491567959}
- component: {fileID: 2988510625873934392}
m_Layer: 0
m_Name: Button
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6841858894429745291
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4323719263405703996}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2499229096808986326}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 160}
m_SizeDelta: {x: 250, y: 250}
m_Pivot: {x: 0.5, y: 0}
--- !u!222 &1590188508543769496
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4323719263405703996}
m_CullTransparentMesh: 1
--- !u!114 &4489841151491567959
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4323719263405703996}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 2636902231072113825, guid: ee014bd71cac2bc4ab845f435726f383, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &2988510625873934392
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4323719263405703996}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 4489841151491567959}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &5931931042366245593
GameObject:
m_ObjectHideFlags: 0
@@ -402,7 +282,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1338508664922812659}
- {fileID: 6841858894429745291}
- {fileID: 5109945643968698326}
m_Father: {fileID: 1966378914653314124}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@@ -1691,7 +1691,7 @@ GameObject:
- component: {fileID: 1536057437}
m_Layer: 5
m_Name: MainCanvas
m_TagString: Untagged
m_TagString: MainCanvas
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0

View File

@@ -939,7 +939,7 @@ GameObject:
- component: {fileID: 818930088}
m_Layer: 5
m_Name: MainCanvas
m_TagString: Untagged
m_TagString: MainCanvas
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0

View File

@@ -5529,7 +5529,7 @@ GameObject:
- component: {fileID: 1156219949}
m_Layer: 5
m_Name: MainCanvas
m_TagString: Untagged
m_TagString: MainCanvas
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -5613,7 +5613,7 @@ RectTransform:
- {fileID: 1585033672}
- {fileID: 805585728}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -0.079}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
@@ -8511,7 +8511,7 @@ Camera:
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 20
orthographic size: 35
m_Depth: -1
m_CullingMask:
serializedVersion: 2
@@ -8536,7 +8536,7 @@ Transform:
m_GameObject: {fileID: 1810521056}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalPosition: {x: 0, y: 13.5999975, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []

View File

@@ -4,7 +4,6 @@ using Core;
using Data.CardSystem;
using Pixelplacement;
using UnityEngine;
using UnityEngine.UI;
namespace UI.CardSystem
{
@@ -21,7 +20,6 @@ namespace UI.CardSystem
[SerializeField] private GameObject visualContainer;
[SerializeField] private RectTransform[] boosterImages; // Up to 3 booster pack visuals
[SerializeField] private RectTransform glowImage; // Single glow effect for all boosters
[SerializeField] private Button continueButton;
[Header("Animation Settings")]
[SerializeField] private float hoverAmount = 20f;
@@ -34,6 +32,10 @@ namespace UI.CardSystem
[SerializeField] private float tweenDuration = 0.8f;
[SerializeField] private float delayBetweenTweens = 0.2f;
[SerializeField] private float disappearScale = 0.2f;
[Header("Auto-Proceed Settings")]
[Tooltip("Time in seconds to display boosters before automatically proceeding with animation")]
[SerializeField] private float autoProceedDelay = 1f;
private Vector3[] _boosterInitialPositions;
private Vector3[] _boosterInitialScales;
@@ -75,12 +77,6 @@ namespace UI.CardSystem
_glowInitialScale = glowImage.localScale;
}
// Setup button listener
if (continueButton != null)
{
continueButton.onClick.AddListener(OnContinueClicked);
}
// Start hidden
if (visualContainer != null)
{
@@ -118,11 +114,6 @@ namespace UI.CardSystem
{
Instance = null;
}
if (continueButton != null)
{
continueButton.onClick.RemoveListener(OnContinueClicked);
}
}
/// <summary>
@@ -167,12 +158,6 @@ namespace UI.CardSystem
glowImage.localScale = _glowInitialScale;
}
// Enable the continue button
if (continueButton != null)
{
continueButton.interactable = true;
}
// Start idle hovering animation on all visible boosters (ping-pong)
for (int i = 0; i < visualCount; i++)
{
@@ -190,26 +175,13 @@ namespace UI.CardSystem
Tween.LocalScale(glowImage, glowPulseScale, glowPulseDuration, 0f, Tween.EaseOut, Tween.LoopType.PingPong);
}
// Wait for button click (handled by OnContinueClicked)
yield return null;
}
// Wait for configured delay before auto-proceeding
Logging.Debug($"[MinigameBoosterGiver] Displaying boosters for {autoProceedDelay} seconds");
yield return new WaitForSeconds(autoProceedDelay);
private void OnContinueClicked()
{
if (_currentSequence == null)
{
return; // Not in a sequence
}
// Disable and hide button to prevent double-clicks
if (continueButton != null)
{
continueButton.interactable = false;
continueButton.gameObject.SetActive(false);
}
// Start moving all boosters to backpack
StartCoroutine(MoveAllBoostersToBackpack());
// Auto-proceed with animation
Logging.Debug("[MinigameBoosterGiver] Auto-proceeding with booster animation");
yield return StartCoroutine(MoveAllBoostersToBackpack());
}
private IEnumerator MoveAllBoostersToBackpack()
@@ -301,12 +273,7 @@ namespace UI.CardSystem
{
visualContainer.SetActive(false);
}
// Show button again for next use
if (continueButton != null)
{
continueButton.gameObject.SetActive(true);
}
// Invoke completion callback
_onCompleteCallback?.Invoke();

View File

@@ -186,7 +186,7 @@ namespace Minigames.BirdPooper
/// <summary>
/// Called when player takes damage/dies.
/// Shows game over screen.
/// Pauses all game entities and starts end game sequence.
/// </summary>
private void HandlePlayerDamaged()
{
@@ -210,7 +210,65 @@ namespace Minigames.BirdPooper
targetSpawner.StopSpawning();
}
// Show game over screen
// Pause all existing scrolling entities (obstacles and targets)
PauseAllScrollingEntities();
// Start the end game sequence (show boosters, then game over screen)
StartCoroutine(EndGameSequence());
}
/// <summary>
/// Pause all existing scrolling entities in the scene.
/// </summary>
private void PauseAllScrollingEntities()
{
ScrollingEntity[] entities = FindObjectsByType<ScrollingEntity>(FindObjectsSortMode.None);
foreach (ScrollingEntity entity in entities)
{
entity.Pause();
}
Debug.Log($"[BirdPooperGameManager] Paused {entities.Length} scrolling entities");
}
/// <summary>
/// End game sequence: award boosters, wait for completion, then show game over screen.
/// </summary>
private System.Collections.IEnumerator EndGameSequence()
{
// Calculate booster reward
int boosterReward = CalculateBoosterReward(_targetsHit);
Debug.Log($"[BirdPooperGameManager] Targets hit: {_targetsHit}, awarding {boosterReward} booster pack(s)");
// Show booster pack reward UI and wait for completion
if (boosterReward > 0)
{
Debug.Log("[BirdPooperGameManager] Starting booster giver sequence via GameManager");
var task = Core.GameManager.Instance.GiveBoosterPacksAsync(boosterReward);
// Wait for the task to complete
while (!task.IsCompleted)
{
yield return null;
}
// Check for exceptions
if (task.IsFaulted)
{
Debug.LogWarning($"[BirdPooperGameManager] Booster pack reward failed: {task.Exception?.GetBaseException().Message}");
}
else
{
Debug.Log("[BirdPooperGameManager] Booster giver sequence finished, proceeding to game over screen");
}
}
else
{
Debug.Log("[BirdPooperGameManager] No boosters to award, proceeding directly to game over screen");
}
// Now show game over screen
if (gameOverScreen != null)
{
gameOverScreen.Show();
@@ -221,6 +279,23 @@ namespace Minigames.BirdPooper
}
}
/// <summary>
/// Calculate booster pack reward based on targets hit.
/// Rules:
/// - First booster pack is given for simply playing the game (participation reward)
/// - Every 3 hit targets gives 1 additional booster pack
/// </summary>
private int CalculateBoosterReward(int targetsHit)
{
// Base reward: 1 booster for participation
int reward = 1;
// Additional reward: 1 booster per 3 targets hit
reward += targetsHit / 3;
return reward;
}
/// <summary>
/// Spawns a poop projectile at the player's current position.
/// Called by UI button OnClick event.

View File

@@ -2,14 +2,12 @@
using UnityEngine;
using UnityEngine.UI;
using Core;
using UI;
namespace Minigames.BirdPooper
{
/// <summary>
/// Game over screen for Bird Pooper minigame.
/// Displays when the player dies and allows restarting the level.
/// Uses unscaled time for UI updates (works when Time.timeScale = 0).
/// </summary>
public class GameOverScreen : MonoBehaviour
{
@@ -53,7 +51,7 @@ namespace Minigames.BirdPooper
}
/// <summary>
/// Show the game over screen and pause the game.
/// Show the game over screen.
/// </summary>
public void Show()
{
@@ -67,11 +65,7 @@ namespace Minigames.BirdPooper
canvasGroup.blocksRaycasts = true;
}
// Pause the game (set timescale to 0)
// PauseMenu uses unscaled time for tweens, so it will still work
Time.timeScale = 0f;
Debug.Log("[GameOverScreen] Game Over - Time.timeScale set to 0");
Debug.Log("[GameOverScreen] Game Over screen shown");
}
/// <summary>
@@ -89,8 +83,6 @@ namespace Minigames.BirdPooper
}
gameObject.SetActive(false);
// Reset time scale BEFORE reloading
Time.timeScale = 1f;
var progress = new Progress<float>(p => Logging.Debug($"Loading progress: {p * 100:F0}%"));
await SceneManagerService.Instance.ReloadCurrentScene(progress);
}

View File

@@ -21,6 +21,7 @@ namespace Minigames.BirdPooper
protected IBirdPooperSettings settings;
protected float despawnXPosition;
protected bool isInitialized;
protected bool isPaused;
protected EdgeAnchor edgeAnchor;
/// <summary>
@@ -191,12 +192,33 @@ namespace Minigames.BirdPooper
protected virtual void Update()
{
if (!isInitialized || settings == null) return;
if (!isInitialized || settings == null || isPaused) return;
MoveLeft();
CheckBounds();
}
/// <summary>
/// Pause the scrolling movement of this entity.
/// </summary>
public void Pause()
{
isPaused = true;
}
/// <summary>
/// Resume the scrolling movement of this entity.
/// </summary>
public void Resume()
{
isPaused = false;
}
/// <summary>
/// Check if this entity is currently paused.
/// </summary>
public bool IsPaused => isPaused;
/// <summary>
/// Move entity left at constant speed (manual movement, no physics).
/// Override GetMoveSpeed() to customize speed per entity type.

View File

@@ -66,11 +66,12 @@ namespace Minigames.CardSorting.Controllers
/// <summary>
/// Calculate booster pack reward based on performance.
/// Formula: Number of correctly sorted cards divided by 10, rounded down.
/// </summary>
public int CalculateBoosterReward()
{
// Simple: 1 booster per correct sort (or use settings multiplier)
return correctSorts * settings.BoosterPacksPerCorrectItem;
// Award 1 booster pack per 10 correctly sorted cards
return (correctSorts / 10) + 1;
}
/// <summary>

View File

@@ -325,10 +325,11 @@ namespace Minigames.CardSorting.Core
private IEnumerator EndGameSequence()
{
// Calculate rewards
// Calculate rewards based on correctly sorted cards
int boosterReward = Score.CalculateBoosterReward();
int sortedCards = Score.CorrectSorts;
Logging.Debug($"[SortingGameManager] Game ended! Score: {Score.TotalScore}, Boosters: {boosterReward}");
Logging.Debug($"[SortingGameManager] Game ended! Score: {Score.TotalScore}, Cards sorted: {sortedCards}, Boosters: {boosterReward}");
// Show booster pack reward UI and wait for completion
if (boosterReward > 0)

View File

@@ -62,6 +62,7 @@ namespace Minigames.FortFight.Core
private PlayerData playerTwo;
private bool isGameActive = false;
private float gameStartTime = 0f;
private float completionTime = 0f; // Store completion time when game ends
public FortFightGameMode CurrentGameMode => currentGameMode;
public bool IsGameActive => isGameActive;
@@ -73,6 +74,11 @@ namespace Minigames.FortFight.Core
{
get
{
if (!isGameActive && completionTime > 0f)
{
// Game ended, return the stored completion time
return completionTime;
}
if (!isGameActive) return 0f;
return Time.time - gameStartTime;
}
@@ -333,6 +339,8 @@ namespace Minigames.FortFight.Core
return;
}
// Store completion time before setting isGameActive to false
completionTime = Time.time - gameStartTime;
isGameActive = false;
// Stop turn manager
@@ -341,12 +349,123 @@ namespace Minigames.FortFight.Core
TurnManager.Instance.SetGameOver();
}
// Manage UI transitions
ShowGameOver();
// Start the end game sequence (show boosters, then game over screen)
StartCoroutine(EndGameSequence());
OnGameEnded?.Invoke();
Logging.Debug("[FortFightGameManager] Game ended");
Logging.Debug($"[FortFightGameManager] Game ended - Duration: {completionTime:F2}s");
}
/// <summary>
/// End game sequence: award boosters, wait for completion, then show game over screen
/// </summary>
private System.Collections.IEnumerator EndGameSequence()
{
// Determine if player won
bool playerWon = DidPlayerWin();
// Calculate booster reward based on completion time and win/loss
int boosterReward = CalculateBoosterReward(completionTime, playerWon);
string resultText = playerWon ? "WON" : "LOST";
Logging.Debug($"[FortFightGameManager] Game completed in {completionTime:F2}s - Player {resultText}, awarding {boosterReward} booster pack(s)");
// Show booster pack reward UI and wait for completion
if (boosterReward > 0)
{
Logging.Debug("[FortFightGameManager] 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($"[FortFightGameManager] Booster pack reward failed: {task.Exception?.GetBaseException().Message}");
}
else
{
Logging.Debug("[FortFightGameManager] Booster giver sequence finished, proceeding to game over screen");
}
}
else
{
Logging.Debug("[FortFightGameManager] No boosters to award, proceeding directly to game over screen");
}
// Now show game over screen
ShowGameOver();
}
/// <summary>
/// Determine if the player won the game
/// </summary>
private bool DidPlayerWin()
{
var fortManager = FortManager.Instance;
if (fortManager == null)
{
Logging.Warning("[FortFightGameManager] Cannot determine winner - FortManager not found");
return false;
}
bool playerDefeated = fortManager.PlayerFort?.IsDefeated ?? false;
bool enemyDefeated = fortManager.EnemyFort?.IsDefeated ?? false;
// Player wins if enemy fort is defeated and player fort is not
return enemyDefeated && !playerDefeated;
}
/// <summary>
/// Calculate booster pack reward based on completion time and game result.
///
/// If player WON:
/// &lt; 1min: 5 Booster Packs
/// &lt; 3min: 4 Booster Packs
/// &lt; 5min: 3 Booster Packs
/// &lt; 7min: 2 Booster Packs
/// &gt;= 7min: 1 Booster Pack
///
/// If player LOST:
/// 1 Booster Pack (participation reward)
/// </summary>
private int CalculateBoosterReward(float timeInSeconds, bool playerWon)
{
// If player lost, give participation reward
if (!playerWon)
{
return 1;
}
// If player won, calculate reward based on completion time
float minutes = timeInSeconds / 60f;
if (minutes < 1f)
{
return 5;
}
else if (minutes < 3f)
{
return 4;
}
else if (minutes < 5f)
{
return 3;
}
else if (minutes < 7f)
{
return 2;
}
else
{
return 1;
}
}
/// <summary>

View File

@@ -1,4 +1,5 @@
using Core;
using System;
using Core;
using Core.Lifecycle;
using TMPro;
using UnityEngine;
@@ -220,12 +221,10 @@ namespace Minigames.FortFight.UI
/// <summary>
/// Restart the game by reloading the current scene
/// </summary>
private void RestartGame()
private async void RestartGame()
{
// Use Unity's SceneManager to reload current scene
string currentScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
Logging.Debug($"[GameOverUI] Reloading scene: {currentScene}");
UnityEngine.SceneManagement.SceneManager.LoadScene(currentScene);
var progress = new Progress<float>(p => Logging.Debug($"Loading progress: {p * 100:F0}%"));
await SceneManagerService.Instance.ReloadCurrentScene(progress);
}
#endregion

View File

@@ -1,9 +1,6 @@
using AudioSourceEvents;
using Levels;
using MoreMountains.Feedbacks;
using System;
using System.Diagnostics.Tracing;
using UnityEditor.Animations;
using UnityEngine;
using UnityEngine.Audio;