Level complete allows loading next scene
This commit is contained in:
parent
1d75fe4a51
commit
75615259f0
1 changed files with 13 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue