stamina and health fix
This commit is contained in:
@@ -47979,7 +47979,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1671840916}
|
m_GameObject: {fileID: 1671840916}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
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_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1008122163}
|
m_Father: {fileID: 1008122163}
|
||||||
@@ -48096,6 +48096,7 @@ MonoBehaviour:
|
|||||||
coffeValuePercent: 10
|
coffeValuePercent: 10
|
||||||
bugStaminaDamagePercent: 15
|
bugStaminaDamagePercent: 15
|
||||||
hurtVelocity: 20
|
hurtVelocity: 20
|
||||||
|
fightSoundLength: 5
|
||||||
healthBar: {fileID: 367096170}
|
healthBar: {fileID: 367096170}
|
||||||
staminaBar: {fileID: 1895829831}
|
staminaBar: {fileID: 1895829831}
|
||||||
--- !u!95 &1671840923
|
--- !u!95 &1671840923
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class Player : MonoBehaviour
|
|||||||
[SerializeField] private int coffeValuePercent = 10;
|
[SerializeField] private int coffeValuePercent = 10;
|
||||||
[SerializeField] private int bugStaminaDamagePercent = 15;
|
[SerializeField] private int bugStaminaDamagePercent = 15;
|
||||||
[SerializeField] private float hurtVelocity = 15f;
|
[SerializeField] private float hurtVelocity = 15f;
|
||||||
|
[SerializeField] private int fightSoundLength = 5;
|
||||||
|
|
||||||
private int currentHealth;
|
private int currentHealth;
|
||||||
private int currentStamina;
|
private int currentStamina;
|
||||||
@@ -32,7 +33,7 @@ public class Player : MonoBehaviour
|
|||||||
private bool isMovementEnabled = true;
|
private bool isMovementEnabled = true;
|
||||||
private bool isFighting = false;
|
private bool isFighting = false;
|
||||||
private bool isHurt = false;
|
private bool isHurt = false;
|
||||||
|
private int fightSoundAccumalator = 0;
|
||||||
private bool isPlayerHurt = false;
|
private bool isPlayerHurt = false;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
@@ -116,7 +117,6 @@ public class Player : MonoBehaviour
|
|||||||
|
|
||||||
private void Hurt()
|
private void Hurt()
|
||||||
{
|
{
|
||||||
currentHealth = 3; // TODO: REMOVE!
|
|
||||||
currentHealth -= currentHealth > 0 ? 1 : 0;
|
currentHealth -= currentHealth > 0 ? 1 : 0;
|
||||||
healthBar.size = new Vector2(1.5f * currentHealth, this.healthBar.size.y);
|
healthBar.size = new Vector2(1.5f * currentHealth, this.healthBar.size.y);
|
||||||
|
|
||||||
@@ -143,7 +143,6 @@ public class Player : MonoBehaviour
|
|||||||
isHurt = false;
|
isHurt = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PlayFightSound();
|
PlayFightSound();
|
||||||
HandleAnimations();
|
HandleAnimations();
|
||||||
}
|
}
|
||||||
@@ -264,7 +263,15 @@ public class Player : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (isFighting && !isPlayerHurt)
|
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()
|
public float GetStaminaDifficultyFactor()
|
||||||
{
|
{
|
||||||
return currentStamina / (startStamina * 1f);
|
return Mathf.Clamp(currentStamina / (startStamina * 1f), 0.27f, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user