Commit to complete merge.

This commit is contained in:
Sweet Tini
2020-02-02 16:03:10 -05:00
10 changed files with 1989 additions and 894 deletions

View File

@@ -15,9 +15,10 @@ public class Player : MonoBehaviour
[SerializeField] private float runErrorThreshold = 0.05f;
[SerializeField] private int startHealth = 3;
[SerializeField] private int startStamina = 100;
[SerializeField] private int coffeValuePercent = 10;
[SerializeField] private int coffeValuePercent = 18;
[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()
@@ -76,18 +77,18 @@ public class Player : MonoBehaviour
}
void OnCollisionEnter2D(Collision2D coll)
public void OnConsumable(Collider2D collision)
{
if (coll.gameObject.tag == "Pizza")
if (collision.gameObject.tag == "Pizza")
{
SoundManagerScript.PlaySound("eat");
Destroy(coll.gameObject);
Destroy(collision.gameObject);
currentHealth += currentHealth < startHealth ? 1 : 0;
healthBar.size = new Vector2(1.5f * currentHealth, this.healthBar.size.y);
}
else if (coll.gameObject.tag == "Coffee")
else if (collision.gameObject.tag == "Coffee")
{
Destroy(coll.gameObject);
Destroy(collision.gameObject);
DrinkCoffee();
}
}
@@ -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);
}
}