stamina and health fix

This commit is contained in:
2020-02-02 15:26:50 -05:00
parent fca0c2ad75
commit 91d53ac010
2 changed files with 14 additions and 6 deletions

View File

@@ -47979,7 +47979,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1671840916}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 14.5, y: -10.5, z: 0}
m_LocalPosition: {x: -9, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1008122163}
@@ -48096,6 +48096,7 @@ MonoBehaviour:
coffeValuePercent: 10
bugStaminaDamagePercent: 15
hurtVelocity: 20
fightSoundLength: 5
healthBar: {fileID: 367096170}
staminaBar: {fileID: 1895829831}
--- !u!95 &1671840923

View File

@@ -18,6 +18,7 @@ public class Player : MonoBehaviour
[SerializeField] private int coffeValuePercent = 10;
[SerializeField] private int bugStaminaDamagePercent = 15;
[SerializeField] private float hurtVelocity = 15f;
[SerializeField] private int fightSoundLength = 5;
private int currentHealth;
private int currentStamina;
@@ -32,7 +33,7 @@ public class Player : MonoBehaviour
private bool isMovementEnabled = true;
private bool isFighting = false;
private bool isHurt = false;
private int fightSoundAccumalator = 0;
private bool isPlayerHurt = false;
private void Start()
@@ -116,7 +117,6 @@ public class Player : MonoBehaviour
private void Hurt()
{
currentHealth = 3; // TODO: REMOVE!
currentHealth -= currentHealth > 0 ? 1 : 0;
healthBar.size = new Vector2(1.5f * currentHealth, this.healthBar.size.y);
@@ -143,7 +143,6 @@ public class Player : MonoBehaviour
isHurt = false;
};
PlayFightSound();
HandleAnimations();
}
@@ -264,7 +263,15 @@ public class Player : MonoBehaviour
{
if (isFighting && !isPlayerHurt)
{
SoundManagerScript.PlaySound(GetRandomFightClipName());
if (fightSoundAccumalator >= fightSoundLength)
{
SoundManagerScript.PlaySound(GetRandomFightClipName());
fightSoundAccumalator = 0;
}
else
{
fightSoundAccumalator++;
}
}
}
@@ -304,6 +311,6 @@ public class Player : MonoBehaviour
public float GetStaminaDifficultyFactor()
{
return currentStamina / (startStamina * 1f);
return Mathf.Clamp(currentStamina / (startStamina * 1f), 0.27f, 1);
}
}