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 GadGame.MiniGame;
|
|
|
|
using UnityEngine;
|
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;
|
2024-04-17 20:53:46 -07:00
|
|
|
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;
|
|
|
|
|
2024-04-23 02:44:22 -07:00
|
|
|
public UnityEngine.UI.Image CircleImgEndGame;
|
|
|
|
public TextMeshProUGUI txtProgressEndGame;
|
|
|
|
|
|
|
|
private float left_time = 5f;
|
|
|
|
private float countdown_time;
|
|
|
|
|
2024-04-15 04:10:00 -07:00
|
|
|
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
|
|
|
|
|
|
|
public void CountDownEndGame(){
|
|
|
|
while(left_time >= 0){
|
|
|
|
countdown_time = left_time / 5;
|
|
|
|
CircleImgEndGame.fillAmount = countdown_time;
|
|
|
|
txtProgressEndGame.text = Mathf.Floor(countdown_time * 5).ToString();
|
|
|
|
left_time -= Time.deltaTime;
|
|
|
|
}
|
|
|
|
}
|
2024-04-11 01:55:35 -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
|
|
|
}
|
|
|
|
}
|