32 lines
827 B
C#
32 lines
827 B
C#
using UnityEngine;
|
|
|
|
public class GoalZone : MonoBehaviour
|
|
{
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (!other.CompareTag("Player"))
|
|
{
|
|
return;
|
|
}
|
|
|
|
UIManager uiManager = FindObjectOfType<UIManager>();
|
|
if (uiManager == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int requiredScore = uiManager.TargetScore;
|
|
|
|
if (uiManager.CurrentScore >= requiredScore)
|
|
{
|
|
uiManager.SetStatus("Цель достигнута");
|
|
Debug.Log("Goal reached with enough collectibles.");
|
|
}
|
|
else
|
|
{
|
|
uiManager.SetStatus($"Нужно собрать больше сфер: {uiManager.CurrentScore}/{requiredScore}.");
|
|
Debug.Log("Goal reached, but not enough collectibles yet.");
|
|
}
|
|
}
|
|
}
|