minihra_dira
spawnuje itemy a uprostred je dira. cilem je nahazet x veci do diry. desing a smysl motivu je na vas
This commit is contained in:
41
Assets/Scripts/hod_veci_do_diry/LevelManager.cs
Normal file
41
Assets/Scripts/hod_veci_do_diry/LevelManager.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user