add: Player script with hp
add: player death handling and OnLevelFailed event
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user