10 lives, game over for Valentines

This commit is contained in:
Michal Pikulski
2025-12-19 17:10:48 +01:00
parent e550d5ce92
commit 8e889d5df0
5 changed files with 1070 additions and 358 deletions

View File

@@ -0,0 +1,91 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using Core;
namespace Minigames.Airplane.UI
{
/// <summary>
/// Game over screen for Airplane minigame.
/// Displays when the game ends (out of lives or all targets hit) and allows restarting the level.
/// </summary>
public class GameOverScreen : MonoBehaviour
{
[Header("UI References")]
[SerializeField] private Button dismissButton;
[SerializeField] private CanvasGroup canvasGroup;
private void Awake()
{
// Subscribe to button click
if (dismissButton != null)
{
dismissButton.onClick.AddListener(OnDismissClicked);
}
else
{
Logging.Error("[GameOverScreen] Dismiss button not assigned!");
}
// Get or add CanvasGroup for fade effects
if (canvasGroup == null)
{
canvasGroup = GetComponent<CanvasGroup>();
if (canvasGroup == null)
{
canvasGroup = gameObject.AddComponent<CanvasGroup>();
}
}
// Hide by default
gameObject.SetActive(false);
}
private void OnDestroy()
{
// Unsubscribe from button
if (dismissButton != null)
{
dismissButton.onClick.RemoveListener(OnDismissClicked);
}
}
/// <summary>
/// Show the game over screen.
/// </summary>
public void Show()
{
gameObject.SetActive(true);
// Set canvas group for interaction
if (canvasGroup != null)
{
canvasGroup.alpha = 1f;
canvasGroup.interactable = true;
canvasGroup.blocksRaycasts = true;
}
Logging.Debug("[GameOverScreen] Game Over screen shown");
}
/// <summary>
/// Called when dismiss button is clicked. Reloads the level.
/// </summary>
private async void OnDismissClicked()
{
Logging.Debug("[GameOverScreen] Dismiss button clicked - Reloading level");
// Hide this screen first
if (canvasGroup != null)
{
canvasGroup.interactable = false;
canvasGroup.blocksRaycasts = false;
}
gameObject.SetActive(false);
var progress = new Progress<float>(p => Logging.Debug($"Loading progress: {p * 100:F0}%"));
await SceneManagerService.Instance.ReloadCurrentScene(progress);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c8bd5b50856a416cb64619d99b26061f
timeCreated: 1766159655