2025-01-31 11:49:49 +03:00

64 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using TMPro;
using UnityEngine;
/// <summary>
/// менеджер очков и всего, что с этим связанно
/// </summary>
public class ScoreManagerScript : MonoBehaviour
{
// to do
// добавить коментарии ко всему
private TileManagerScript _TileManagerScript;
[SerializeField]
private Transform _PlayerTransform;
[SerializeField]
private float _Distance = 0f;
private int _CurrentScore = 0;
[SerializeField]
private TextMeshPro _ScoreText;
private void Awake()
{
_TileManagerScript = GameObject.FindGameObjectWithTag("Tile Manager").GetComponent<TileManagerScript>();
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;
}
}