|
@@ -1,6 +1,7 @@
|
|
|
-using UnityEngine;
|
|
|
|
|
-using TMPro;
|
|
|
|
|
using System.Collections;
|
|
using System.Collections;
|
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
|
+using TMPro;
|
|
|
|
|
+using UnityEngine;
|
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
public class GameManager : MonoBehaviour
|
|
public class GameManager : MonoBehaviour
|
|
@@ -13,6 +14,9 @@ public class GameManager : MonoBehaviour
|
|
|
public int totalOrbs = 20;
|
|
public int totalOrbs = 20;
|
|
|
private int collectedOrbs = 0;
|
|
private int collectedOrbs = 0;
|
|
|
|
|
|
|
|
|
|
+ // CHANGED: From Array to List to allow dynamic adding
|
|
|
|
|
+ public List<EnergyOrb> allOrbs = new List<EnergyOrb>();
|
|
|
|
|
+
|
|
|
[Header("UI")]
|
|
[Header("UI")]
|
|
|
public TMP_Text orbsCounter;
|
|
public TMP_Text orbsCounter;
|
|
|
public TMP_Text timertext;
|
|
public TMP_Text timertext;
|
|
@@ -21,7 +25,7 @@ public class GameManager : MonoBehaviour
|
|
|
public float timeRemaining = 60f;
|
|
public float timeRemaining = 60f;
|
|
|
private bool gameOver = false;
|
|
private bool gameOver = false;
|
|
|
|
|
|
|
|
- public EnergyOrb[] allOrbs;
|
|
|
|
|
|
|
+ //public EnergyOrb[] allOrbs;
|
|
|
|
|
|
|
|
|
|
|
|
|
[Header("References")]
|
|
[Header("References")]
|
|
@@ -46,7 +50,7 @@ public class GameManager : MonoBehaviour
|
|
|
|
|
|
|
|
void Start()
|
|
void Start()
|
|
|
{
|
|
{
|
|
|
- allOrbs = FindObjectsOfType<EnergyOrb>();
|
|
|
|
|
|
|
+ //allOrbs = FindObjectsOfType<EnergyOrb>();
|
|
|
UpdateOrbUI();
|
|
UpdateOrbUI();
|
|
|
UpdateTimerUI();
|
|
UpdateTimerUI();
|
|
|
}
|
|
}
|
|
@@ -132,15 +136,19 @@ public class GameManager : MonoBehaviour
|
|
|
Debug.Log("YOU LOSE!");
|
|
Debug.Log("YOU LOSE!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void RegisterOrbs(List<EnergyOrb> newOrbs)
|
|
|
|
|
+ {
|
|
|
|
|
+ allOrbs.AddRange(newOrbs);
|
|
|
|
|
+ totalOrbs = allOrbs.Count; // Sync the total count
|
|
|
|
|
+ UpdateOrbUI();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void StartNewGame()
|
|
public void StartNewGame()
|
|
|
{
|
|
{
|
|
|
gameOver = false;
|
|
gameOver = false;
|
|
|
-
|
|
|
|
|
- // Reseting the timer
|
|
|
|
|
timeRemaining = 60f;
|
|
timeRemaining = 60f;
|
|
|
UpdateTimerUI();
|
|
UpdateTimerUI();
|
|
|
|
|
|
|
|
- // Reseting all of the orbs
|
|
|
|
|
foreach (var orb in allOrbs)
|
|
foreach (var orb in allOrbs)
|
|
|
{
|
|
{
|
|
|
orb.Collected = false;
|
|
orb.Collected = false;
|
|
@@ -149,13 +157,10 @@ public class GameManager : MonoBehaviour
|
|
|
collectedOrbs = 0;
|
|
collectedOrbs = 0;
|
|
|
UpdateOrbUI();
|
|
UpdateOrbUI();
|
|
|
|
|
|
|
|
- // Reset the player position and rotation
|
|
|
|
|
if (player != null)
|
|
if (player != null)
|
|
|
{
|
|
{
|
|
|
player.transform.position = Vector3.zero;
|
|
player.transform.position = Vector3.zero;
|
|
|
player.transform.rotation = Quaternion.identity;
|
|
player.transform.rotation = Quaternion.identity;
|
|
|
-
|
|
|
|
|
- // Reset stamina
|
|
|
|
|
player.Stamina = player.maxStamina;
|
|
player.Stamina = player.maxStamina;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -223,12 +228,12 @@ public class GameManager : MonoBehaviour
|
|
|
UpdateTimerUI();
|
|
UpdateTimerUI();
|
|
|
|
|
|
|
|
// Restore all of the orbs
|
|
// Restore all of the orbs
|
|
|
- for (int i = 0; i < allOrbs.Length; i++)
|
|
|
|
|
|
|
+ for (int i = 0; i < allOrbs.Count; i++)
|
|
|
{
|
|
{
|
|
|
allOrbs[i].Collected = data.orbs[i].collected;
|
|
allOrbs[i].Collected = data.orbs[i].collected;
|
|
|
allOrbs[i].gameObject.SetActive(!data.orbs[i].collected);
|
|
allOrbs[i].gameObject.SetActive(!data.orbs[i].collected);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
collectedOrbs = data.orbsCollected;
|
|
collectedOrbs = data.orbsCollected;
|
|
|
UpdateOrbUI();
|
|
UpdateOrbUI();
|
|
|
}
|
|
}
|