36 lines
656 B
C#
36 lines
656 B
C#
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public static GameManager Instance { get; private set; }
|
|
|
|
public float MaxScore = 100f;
|
|
public UnityAction OnScoreChanged;
|
|
public UnityAction OnWin;
|
|
public UnityAction OnLose;
|
|
|
|
public bool IsWinScore
|
|
{
|
|
get => Score >= MaxScore;
|
|
}
|
|
|
|
public float Score { get; private set; } = 0;
|
|
|
|
void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
public void AddScore(int score)
|
|
{
|
|
Score += score;
|
|
OnScoreChanged?.Invoke();
|
|
|
|
if (IsWinScore)
|
|
{
|
|
OnWin?.Invoke();
|
|
}
|
|
}
|
|
}
|