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
+15
View File
@@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using Random = UnityEngine.Random;
public class GameController : MonoBehaviour
{
public static GameController i;
public SceneAsset deployScene;
public List<LevelInfo> levels;
public List<EnemyInfo> enemies;
@@ -47,6 +49,10 @@ public class GameController : MonoBehaviour
}
public void OnLevelFailed(string sceneName, float timeSpent) {
}
EnemyInfo SelectEnemyWeighted() {
float sumWeights = enemies.Sum(enemy => enemy.weight);
float r = Random.Range(0, sumWeights);
@@ -57,6 +63,15 @@ public class GameController : MonoBehaviour
}
return enemies[^1];
}
public void LoadDeployScene() {
SceneManager.LoadScene(deployScene.name);
}
public static void SetCursorState(bool locked) {
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !locked;
}
}
[Serializable]