bubble_shooter_2d/Assets/Scripts/ScoreManager.cs
2022-12-30 23:30:32 +05:00

54 lines
781 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreManager
{
private int score = 0;
private int throws = 0;
public static ScoreManager instance;
public static ScoreManager GetInstance()
{
if (instance == null)
instance = new ScoreManager();
return instance;
}
public void UpdateScoreUI()
{
Text _score = GameObject.FindWithTag("Score").GetComponent<Text>();
_score.text = $"Score: {score}";
}
public void AddScore(int score)
{
this.score += score;
UpdateScoreUI();
}
public int GetScore()
{
return score;
}
public void AddThrows()
{
throws++;
}
public int GetThrows()
{
return throws;
}
public void Reset()
{
score = 0;
throws = 0;
UpdateScoreUI();
}
}