diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index fd86356937e5161ca6a3710ba75081e57044d560..d55b1096030bc1d0a2a6b402401763c276383050 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -1634,7 +1634,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 0, b: 0, a: 0} + m_Color: {r: 1, g: 1, b: 1, a: 0} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 diff --git a/Assets/Scripts/Player/PlayerHealth.cs b/Assets/Scripts/Player/PlayerHealth.cs index 2838f95694843b5b1eeb7b33b716ed9c884e1828..d3c36505d5da70427a844ba37df31da2d5076e99 100644 --- a/Assets/Scripts/Player/PlayerHealth.cs +++ b/Assets/Scripts/Player/PlayerHealth.cs @@ -13,7 +13,8 @@ namespace Nightmare public Image damageImage; public AudioClip deathClip; public float flashSpeed = 5f; - public Color flashColour = new Color(1f, 0f, 0f, 0.1f); + public Color redColour = new Color(1f, 0f, 0f, 0.1f); + public Color greenColour = new Color(0f, 1f, 0f, 0.1f); Animator anim; AudioSource playerAudio; @@ -21,6 +22,7 @@ namespace Nightmare PlayerShooting playerShooting; bool isDead; bool damaged; + int damageAmount = 0; // Cheat No Damage public bool isCheatNoDamage = false; @@ -54,7 +56,14 @@ namespace Nightmare if (damaged) { // ... set the colour of the damageImage to the flash colour. - damageImage.color = flashColour; + if (damageAmount > 0) // Take Damage + { + damageImage.color = redColour; + } + else if (damageAmount < 0) // Restore Health + { + damageImage.color = greenColour; + } } // Otherwise... else @@ -76,6 +85,9 @@ namespace Nightmare // Set the damaged flag so the screen will flash. damaged = true; + // Set damage amount to get the right color effect + damageAmount = amount; + // Reduce the current health by the damage amount. currentHealth -= amount;