add: Player script with hp

add: player death handling and OnLevelFailed event
This commit is contained in:
KOSMOGOR
2025-04-25 13:40:23 +03:00
parent 202cdb5702
commit dc6707f2a9
9 changed files with 75 additions and 7 deletions
+6 -3
View File
@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using Random = UnityEngine.Random;
public class LevelController : MonoBehaviour
{
public SceneAsset deployScene;
public List<SpawnPointInfo> spawnPoints;
List<Enemy> aliveEnemies;
@@ -33,10 +31,15 @@ public class LevelController : MonoBehaviour
public void Update() {
if (aliveEnemies.All(enemy => enemy == null)) {
GameController.i.OnLevelClear(SceneManager.GetActiveScene().name, timeSpent);
SceneManager.LoadScene(deployScene.name);
GameController.i.LoadDeployScene();
}
timeSpent += Time.deltaTime;
}
public void OnPlayerDie() {
GameController.i.OnLevelFailed(SceneManager.GetActiveScene().name, timeSpent);
GameController.i.LoadDeployScene();
}
}
[Serializable]