Project
This commit is contained in:
1 parent
e1a474d4ac
commit
24b1157026
164 files changed
+68527
No files matched your search
@@ -0,0 +1,37 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.GameplayServices
|
||||
{
|
||||
public class PlayerScoreService : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
|
||||
private int _score;
|
||||
|
||||
public static PlayerScoreService Instance { get; private set; }
|
||||
public int Score => _score;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void AddScore(int score)
|
||||
{
|
||||
_score += score;
|
||||
UpdateScoreTextWithScoreValue();
|
||||
}
|
||||
|
||||
private void UpdateScoreTextWithScoreValue()
|
||||
{
|
||||
scoreText.text = _score.ToString();
|
||||
}
|
||||
|
||||
public void ResetScore()
|
||||
{
|
||||
_score = 0;
|
||||
scoreText.text = _score.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user