using SHADE; using System; using System.Collections.Generic; public class GameManager : Script { public enum GameState { START, WIN, LOSE } public GameObject itemPool; public GameObject zonePool; public uint winScene = 92009475; public uint loseScene = 91685359; [NonSerialized] public GameState currGameState; [NonSerialized] public int totalItemCount; [NonSerialized] public int Score; [NonSerialized] public float timer; private IEnumerable listOfItems; private IEnumerable listOfZone; protected override void awake() { totalItemCount = 0; Score = 0; currGameState = GameState.START; if (itemPool) { listOfItems = itemPool.GetScriptsInChildren(); if (listOfItems != null) foreach (Item i in listOfItems) totalItemCount += 1; } if (zonePool) { listOfZone = zonePool.GetScriptsInChildren(); if (listOfZone != null) foreach (ScoringZone sz in listOfZone) sz.gameManger = Owner.GetScript(); } } protected override void update() { if (timer > 0 && currGameState == GameState.START) { timer -= Time.DeltaTimeF; if (totalItemCount <= 0) { currGameState = GameState.WIN; SceneManager.ChangeScene(winScene); } } else { currGameState = GameState.LOSE; SceneManager.ChangeScene(loseScene); } } }