2026-01-08 16:50:20 +00:00
|
|
|
using UnityEngine;
|
2026-01-09 10:41:51 +00:00
|
|
|
using TMPro;
|
2026-01-08 16:50:20 +00:00
|
|
|
|
|
|
|
|
public class Scorer : MonoBehaviour
|
|
|
|
|
{
|
2026-01-09 10:41:51 +00:00
|
|
|
[SerializeField] TextMeshProUGUI scoreText;
|
|
|
|
|
[SerializeField] int maxHits;
|
2026-01-08 16:50:20 +00:00
|
|
|
int hits = 0;
|
2026-01-09 10:41:51 +00:00
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
hits = 0;
|
|
|
|
|
scoreText.text = "Hits: " + hits.ToString();
|
|
|
|
|
}
|
2026-01-08 16:50:20 +00:00
|
|
|
private void OnCollisionEnter(Collision other)
|
|
|
|
|
{
|
|
|
|
|
if (other.gameObject.tag != "Hit")
|
|
|
|
|
{
|
2026-01-09 10:41:51 +00:00
|
|
|
if (hits < maxHits)
|
|
|
|
|
{
|
2026-01-08 16:50:20 +00:00
|
|
|
hits++;
|
2026-01-09 10:41:51 +00:00
|
|
|
scoreText.text = "Hits: " + hits.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
2026-01-08 16:50:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|