Создал скрипт вращения колёс машин, может ещё что в него добавлю, создал префабы окружения и машин
50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using TMPro;
|
||
using UnityEngine;
|
||
|
||
/// <summary>
|
||
/// менеджер очков и всего, что с этим связанно
|
||
/// </summary>
|
||
public class ScoreManagerScript : MonoBehaviour
|
||
{
|
||
// to do
|
||
// добавить коментарии ко всему
|
||
private TileManagerScript _tileManagerScript;
|
||
|
||
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 Start()
|
||
{
|
||
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|