diff --git a/Assets/_CompletedAssets/Scripts/Managers/EnemyManager.cs b/Assets/_CompletedAssets/Scripts/Managers/EnemyManager.cs index 5e617c69d5fb95ee5ccaef88830493b6f62e7347..e8cb71b33508a3182247ea56d10cb011ec309663 100644 --- a/Assets/_CompletedAssets/Scripts/Managers/EnemyManager.cs +++ b/Assets/_CompletedAssets/Scripts/Managers/EnemyManager.cs @@ -13,6 +13,25 @@ namespace CompleteProject { // Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time. InvokeRepeating("Spawn", spawnTime, spawnTime); + + // set spawn time based on difficulty level mudah = 5, normal = 3, sulit = 2 + + switch (PlayerPrefs.GetString("Difficulty", "mudah")) + { + case "mudah": + spawnTime = 5f; + break; + case "normal": + spawnTime = 3f; + break; + case "sulit": + spawnTime = 2f; + break; + default: + spawnTime = 5f; + break; + } + } diff --git a/Assets/_CompletedAssets/Scripts/Player/PlayerHealth.cs b/Assets/_CompletedAssets/Scripts/Player/PlayerHealth.cs index 6bbd76b216c07b37a9a19899c9c292ba0785a127..ae0ae1574fbbadb0216e9cc6fc4ab06d9432a838 100644 --- a/Assets/_CompletedAssets/Scripts/Player/PlayerHealth.cs +++ b/Assets/_CompletedAssets/Scripts/Player/PlayerHealth.cs @@ -7,7 +7,7 @@ namespace CompleteProject { public class PlayerHealth : MonoBehaviour { - public float startingHealth = 100f; // The amount of health the player starts the game with. + public float startingHealth = 125f; // The amount of health the player starts the game with. public float currentHealth; // The current health the player has. public Slider healthSlider; // Reference to the UI's health bar. public Image effectImage; // Reference to an image to flash on the screen on being hurt. @@ -33,8 +33,28 @@ namespace CompleteProject playerMovement = GetComponent<PlayerMovement>(); riffle = GetComponentInChildren<Riffle>(); + // set starting health based on difficulty level mudah = 100, normal = 50, sulit = 25 + + switch (PlayerPrefs.GetString("Difficulty", "mudah")) + { + case "mudah": + startingHealth = 125f; + break; + case "normal": + startingHealth = 100f; + break; + case "sulit": + startingHealth = 50f; + break; + default: + startingHealth = 125f; + break; + } + // Set the initial health of the player. currentHealth = startingHealth; + + }