MiniGames/Assets/Scripts/BalloonFloat/BalloonGameManager.cs

43 lines
1.1 KiB
C#
Raw Normal View History

2025-07-14 19:30:52 +05:00
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class BalloonGameManager : MonoBehaviour
{
public CameraScroller cameraScroller;
public GameObject gameOverPanel;
public TextMeshProUGUI scoreTextInGame;
public TextMeshProUGUI scoreTextGameOver;
public GameObject balloon; // Assign your Balloon object here
private float score = 0f;
private bool gameOver = false;
public static bool IsGameOver { get; private set; } = false;
void Update()
{
if (BalloonGameManager.IsGameOver) return;
// Score increases with time
score += Time.deltaTime;
if (scoreTextInGame != null)
scoreTextInGame.text = "Score: "+Mathf.FloorToInt(score).ToString();
}
public void TriggerGameOver()
{
if (IsGameOver) return;
IsGameOver = true;
if (cameraScroller != null)
cameraScroller.enabled = false;
if (gameOverPanel != null)
gameOverPanel.SetActive(true);
if (scoreTextGameOver != null)
scoreTextGameOver.text = "Score: " + Mathf.FloorToInt(score).ToString();
}
}