Что я сдал
This commit is contained in:
1 parent
24b1157026
commit
a5665f0101
2838 files changed
+129953
-1304
No files matched your search
@@ -1,3 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.UI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -5,10 +7,21 @@ namespace Code.GameplayServices
|
||||
{
|
||||
public class PlayerScoreService : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
|
||||
private int _score;
|
||||
[SerializeField] private ScoreTable scoreTable;
|
||||
|
||||
public void ShowScoreTable()
|
||||
{
|
||||
scoreTable.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
[SerializeField] private TMP_Text playerNameText;
|
||||
|
||||
private List<ScoreData> _scores = new();
|
||||
public List<ScoreData> Scores => _scores;
|
||||
private int _score;
|
||||
private string _playerName;
|
||||
|
||||
public static PlayerScoreService Instance { get; private set; }
|
||||
public int Score => _score;
|
||||
|
||||
@@ -19,7 +32,7 @@ namespace Code.GameplayServices
|
||||
|
||||
public void AddScore(int score)
|
||||
{
|
||||
_score += score;
|
||||
_score += BonusService.Instance.CoinBoost ? score * 2 : score;
|
||||
UpdateScoreTextWithScoreValue();
|
||||
}
|
||||
|
||||
@@ -30,8 +43,30 @@ namespace Code.GameplayServices
|
||||
|
||||
public void ResetScore()
|
||||
{
|
||||
_scores.Add(new ScoreData(_playerName, _score));
|
||||
|
||||
_score = 0;
|
||||
// _playerName = string.Empty;
|
||||
|
||||
scoreText.text = _score.ToString();
|
||||
}
|
||||
|
||||
public void SetPlayerName(string playerName)
|
||||
{
|
||||
_playerName = playerName;
|
||||
playerNameText.text = _playerName;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ScoreData
|
||||
{
|
||||
public string name;
|
||||
public int score;
|
||||
|
||||
public ScoreData(string name, int score)
|
||||
{
|
||||
this.name = name;
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user