add: OnLevelClear event
This commit is contained in:
@@ -30,6 +30,10 @@ public class GameController : MonoBehaviour
|
|||||||
public LevelInfo GetLevel(string sceneName) {
|
public LevelInfo GetLevel(string sceneName) {
|
||||||
return levels.Find(x => x.scene.name == sceneName);
|
return levels.Find(x => x.scene.name == sceneName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnLevelClear(string sceneName, float timeSpent) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
public class LevelController : MonoBehaviour
|
public class LevelController : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public SceneAsset deployScene;
|
||||||
public List<SpawnPointInfo> spawnPoints;
|
public List<SpawnPointInfo> spawnPoints;
|
||||||
|
|
||||||
List<Enemy> aliveEnemies;
|
List<Enemy> aliveEnemies;
|
||||||
|
float timeSpent = 0;
|
||||||
|
|
||||||
public void Start() {
|
public void Start() {
|
||||||
aliveEnemies = new List<Enemy>();
|
aliveEnemies = new List<Enemy>();
|
||||||
@@ -26,6 +29,14 @@ public class LevelController : MonoBehaviour
|
|||||||
aliveEnemies.Add(spawnedEnemy);
|
aliveEnemies.Add(spawnedEnemy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update() {
|
||||||
|
if (aliveEnemies.All(enemy => enemy == null)) {
|
||||||
|
GameController.i.OnLevelClear(SceneManager.GetActiveScene().name, timeSpent);
|
||||||
|
SceneManager.LoadScene(deployScene.name);
|
||||||
|
}
|
||||||
|
timeSpent += Time.deltaTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|||||||
Reference in New Issue
Block a user