Added functional defense points

This commit is contained in:
Alicja 2022-11-14 23:04:29 +01:00
parent 2e2aae16f8
commit fbe444689f
3 changed files with 28 additions and 9 deletions

View File

@ -39566,7 +39566,7 @@ MonoBehaviour:
m_Calls: m_Calls:
- m_Target: {fileID: 1177353681} - m_Target: {fileID: 1177353681}
m_TargetAssemblyTypeName: Player, Assembly-CSharp m_TargetAssemblyTypeName: Player, Assembly-CSharp
m_MethodName: AddHealthPoint m_MethodName: AddDefensePoint
m_Mode: 1 m_Mode: 1
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}

View File

@ -128,6 +128,21 @@ public class Player : MonoBehaviour
public void TakeDamage(float damage, bool isPanelEnabled = true) public void TakeDamage(float damage, bool isPanelEnabled = true)
{ {
defensePoints = PlayerPrefs.GetInt("defensePoints");
if(defensePoints == 1)
{
damage = damage * 0.95f;
}
else if(defensePoints == 2)
{
damage = damage * 0.9f;
}
else if(defensePoints == 3)
{
damage = damage * 0.85f;
}
currentHealth = PlayerPrefs.GetFloat("health"); currentHealth = PlayerPrefs.GetFloat("health");
currentHealth = currentHealth - damage; currentHealth = currentHealth - damage;
PlayerPrefs.SetFloat("health", currentHealth); PlayerPrefs.SetFloat("health", currentHealth);
@ -258,6 +273,10 @@ public class Player : MonoBehaviour
if (currentHealth < maxHealth) if (currentHealth < maxHealth)
{ {
currentHealth = currentHealth + 1; currentHealth = currentHealth + 1;
if (currentHealth > maxHealth)
{
currentHealth = maxHealth;
}
PlayerPrefs.SetFloat("health", currentHealth); PlayerPrefs.SetFloat("health", currentHealth);
timerTick = 0f; timerTick = 0f;
} }
@ -353,7 +372,7 @@ public class Player : MonoBehaviour
{ {
defensePoints = PlayerPrefs.GetInt("defensePoints"); defensePoints = PlayerPrefs.GetInt("defensePoints");
defensePoints = defensePoints + 1; defensePoints = defensePoints + 1;
PlayerPrefs.SetInt("defensePoitns", defensePoints); PlayerPrefs.SetInt("defensePoints", defensePoints);
} }
public void ManageIntelligence() public void ManageIntelligence()

View File

@ -9,17 +9,17 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021 value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
flags: 0 flags: 0
RecentlyUsedScenePath-1: RecentlyUsedScenePath-1:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d value: 22424703114646680e0b0227036c68190c160a2e042733232867083debf42d
flags: 0 flags: 0
RecentlyUsedScenePath-4: RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c70050204112e291f2f2a2c3b1920caef212be7a923e7ee2e26 value: 22424703114646680e0b0227036c70050204112e291f2f2a2c3b1920caef212be7a923e7ee2e26
flags: 0 flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
vcSharedLogLevel: vcSharedLogLevel:
value: 0d5e400f0650 value: 0d5e400f0650
flags: 0 flags: 0