42 lines
919 B
C#
42 lines
919 B
C#
using UnityEngine;
|
||
using UnityEngine.Events;
|
||
|
||
public class LevelManager : MonoBehaviour
|
||
{
|
||
public static LevelManager Instance;
|
||
|
||
[Header("Nastavení levelu")]
|
||
[Tooltip("Kolik itemů musí hráč trefit pro splnění levelu")]
|
||
public int itemsToScore = 3;
|
||
|
||
[Header("Event – vyvolá se po trefení všech itemů")]
|
||
public UnityEvent OnAllItemsScored;
|
||
|
||
private int scoredCount = 0;
|
||
|
||
void Awake()
|
||
{
|
||
if (Instance == null) Instance = this;
|
||
else Destroy(gameObject);
|
||
}
|
||
|
||
public void RegisterItem()
|
||
{
|
||
scoredCount++;
|
||
Debug.Log($"Trefeno: {scoredCount} / {itemsToScore}");
|
||
|
||
if (scoredCount >= itemsToScore)
|
||
{
|
||
OnAllItemsScored?.Invoke();
|
||
}
|
||
}
|
||
|
||
public void ResetCounter()
|
||
{
|
||
scoredCount = 0;
|
||
}
|
||
|
||
public int GetScoredCount() => scoredCount;
|
||
public int GetTotalCount() => itemsToScore;
|
||
}
|