smart-interactive-display/Assets/GadGame/Scripts/Manager/GameManager.cs

40 lines
820 B
C#
Raw Normal View History

2024-04-23 02:44:22 -07:00
using TMPro;
2024-04-11 01:55:35 -07:00
using System;
2024-04-15 04:10:00 -07:00
using UnityEngine;
2024-04-23 20:04:04 -07:00
using UnityEngine.UI;
2024-04-11 01:55:35 -07:00
namespace GadGame.Manager
{
2024-04-15 04:10:00 -07:00
2024-04-11 01:55:35 -07:00
public class GameManager : Singleton.Singleton<GameManager>
{
2024-04-15 04:10:00 -07:00
private int _score;
public int Score => _score;
2024-04-11 01:55:35 -07:00
public event Action OnEnd;
2024-04-15 04:10:00 -07:00
public event Action OnPause;
public event Action OnResume;
public event Action<int> OnScoreUpdate;
public void UpdateScore(int value)
{
_score += value;
2024-04-15 22:03:46 -07:00
if (_score <= 0) _score = 0;
2024-04-15 04:10:00 -07:00
OnScoreUpdate?.Invoke(_score);
}
2024-04-23 02:44:22 -07:00
2024-04-15 04:10:00 -07:00
public void EndGame()
2024-04-11 01:55:35 -07:00
{
OnEnd?.Invoke();
}
2024-04-15 04:10:00 -07:00
public void Pause()
{
OnPause?.Invoke();
}
public void Resume()
{
OnResume?.Invoke();
}
2024-04-11 01:55:35 -07:00
}
}