using TMPro; using UnityEngine; /// /// менеджер очков и всего, что с этим связанно /// public class ScoreManagerScript : MonoBehaviour { // to do // добавить коментарии ко всему private TileManagerScript _TileManagerScript; [SerializeField] private Transform _PlayerTransform; [SerializeField] private float _Distance = 0f; private int _CurrentScore = 0; public int CurrentScore { get { return _CurrentScore; } } [SerializeField] private TextMeshPro _ScoreText; private void Awake() { _TileManagerScript = GameObject.FindGameObjectWithTag("Tile Manager").GetComponent(); if (_TileManagerScript != null) { _TileManagerScript.scoreManager = this; } } private void Update() { UpdatePos(); } public void Increase() { _CurrentScore += 1; UppdateScore(_ScoreText); } private void UppdateScore(TextMeshPro text) { text.text = $"Счёт - {_CurrentScore}"; } //public void UpdatePos() //{ // Vector3 newVector = new Vector3(_ScoreText.gameObject.transform.position.x, _ScoreText.gameObject.transform.position.y, _ScoreText.gameObject.transform.position.z + _TileManagerScript.DistanceTiles); // _ScoreText.gameObject.transform.position = newVector; //} public void UpdatePos() { Vector3 newVector = new Vector3(_ScoreText.gameObject.transform.position.x, _ScoreText.gameObject.transform.position.y, _PlayerTransform.position.z + _Distance); _ScoreText.gameObject.transform.position = newVector; } }