Merge branch 'master' of https://github.com/SweetTini/GlobalGameJam2020
This commit is contained in:
@@ -32,6 +32,8 @@ public class Player : MonoBehaviour
|
||||
private bool isMovementEnabled = true;
|
||||
private bool isFighting = false;
|
||||
|
||||
private bool isPlayerHurt = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rigidBody = GetComponent<Rigidbody2D>();
|
||||
@@ -129,7 +131,7 @@ public class Player : MonoBehaviour
|
||||
Run();
|
||||
FlipSprite();
|
||||
}
|
||||
|
||||
PlayFightSound();
|
||||
HandleAnimations();
|
||||
}
|
||||
|
||||
@@ -234,20 +236,38 @@ public class Player : MonoBehaviour
|
||||
animator.SetBool("IsFighting", isFighting);
|
||||
}
|
||||
|
||||
private void PlayFightSound()
|
||||
{
|
||||
if (isFighting && !isPlayerHurt)
|
||||
{
|
||||
SoundManagerScript.PlaySound(GetRandomFightClipName());
|
||||
}
|
||||
}
|
||||
|
||||
private string GetRandomFightClipName()
|
||||
{
|
||||
var fightClipNames = new List<string> { "punch", "hard punch", "slap", "hard slap" };
|
||||
var randomNumber = UnityEngine.Random.Range(0, fightClipNames.Count);
|
||||
return fightClipNames[randomNumber];
|
||||
}
|
||||
|
||||
public void StartEncounter()
|
||||
{
|
||||
isPlayerHurt = false;
|
||||
isFighting = true;
|
||||
isMovementEnabled = false;
|
||||
}
|
||||
|
||||
public void EndEncounter()
|
||||
{
|
||||
isPlayerHurt = false;
|
||||
isFighting = false;
|
||||
isMovementEnabled = true;
|
||||
}
|
||||
|
||||
public void ThrowUserInTheAirHurt()
|
||||
{
|
||||
{
|
||||
isPlayerHurt = true;
|
||||
GetComponent<Rigidbody2D>().velocity += new Vector2(Mathf.Sign(transform.localScale.x) * -1 * hurtVelocity, hurtVelocity);
|
||||
isFighting = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user