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