Skip to content
Snippets Groups Projects
Commit 358a47b5 authored by Akmal Mahardika Nurwahyu Pratama's avatar Akmal Mahardika Nurwahyu Pratama
Browse files

feat: difficulty setting

parent f29e84df
Branches
Tags
1 merge request!35feat: fix Game Data
......@@ -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;
}
}
......
......@@ -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;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment