Level complete allows loading next scene

This commit is contained in:
Ava Gaiety Wroten 2020-06-16 20:22:07 -05:00
parent 1d75fe4a51
commit 75615259f0

View file

@ -1,5 +1,6 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine; using UnityEngine;
public class ChargeCounter : MonoBehaviour public class ChargeCounter : MonoBehaviour
@ -7,12 +8,19 @@ public class ChargeCounter : MonoBehaviour
bool levelComplete = false; bool levelComplete = false;
GameObject[] chargePoints; GameObject[] chargePoints;
List<GameObject> chargedPoints = new List<GameObject>(); List<GameObject> chargedPoints = new List<GameObject>();
Scene currentScene;
void Start() void Start()
{ {
currentScene = SceneManager.GetActiveScene();
if (chargePoints == null) chargePoints = GameObject.FindGameObjectsWithTag("Charge Point"); if (chargePoints == null) chargePoints = GameObject.FindGameObjectsWithTag("Charge Point");
} }
void Update()
{
if (levelComplete && Input.anyKey) LoadNextLevel();
}
public void AddChargedPoint(GameObject chargePoint) public void AddChargedPoint(GameObject chargePoint)
{ {
chargedPoints.Add(chargePoint); chargedPoints.Add(chargePoint);
@ -41,4 +49,9 @@ public class ChargeCounter : MonoBehaviour
transform.GetChild(0).gameObject.SetActive(true); transform.GetChild(0).gameObject.SetActive(true);
levelComplete = true; levelComplete = true;
} }
void LoadNextLevel()
{
SceneManager.LoadScene(currentScene.buildIndex + 1);
}
} }