69 lines
1.7 KiB
C#
69 lines
1.7 KiB
C#
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;
|
||
|
||
public int CurrentScore
|
||
{
|
||
get { return _CurrentScore; }
|
||
}
|
||
|
||
[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;
|
||
}
|
||
}
|