Implement sound effects

This commit is contained in:
RochesterX
2025-04-12 17:24:51 -04:00
parent e122129196
commit 274d87241f
20 changed files with 1829 additions and 4 deletions

View File

@@ -217,6 +217,7 @@ public class GameManager : MonoBehaviour
while (!winner.GetComponent<UseItem>().IsHoldingItem())
{
hatObject.transform.position = winner.transform.position + Vector3.up * 3/2;
winner.GetComponent<UseItem>().PickUpItem(hatObject);
yield return null;
}
}

View File

@@ -17,6 +17,7 @@ public class HatRespawn : MonoBehaviour
void Update() // Checks if the hat has been inactive for too long
{
if (GameManager.Instance.gameOver) GetComponent<BoxCollider2D>().enabled = false;
if (isDropped && Time.time - lastInteractionTime > respawnTime)
{
RespawnHat();

View File

@@ -52,16 +52,19 @@ public class Damageable : MonoBehaviour
if (blockComponent.IsParrying()) // Player receives damage if punching a parrying player
{
damageSource.GetComponent<Damageable>().SuccessfulParry(gameObject, actualForce);
AudioManager.Instance.PlaySound("Parry");
return;
}
else // Player does less damage if punching a blocking player
{
AudioManager.Instance.PlaySound("Punch");
actualForce /= 4;
GetComponent<Rigidbody2D>().AddForce(((transform.position - damageSource.transform.position).normalized + Vector3.up * 2) * actualForce, ForceMode2D.Force);
}
}
else // Player does full damage to a non-blocking player
{
AudioManager.Instance.PlaySound("Punch");
GetComponent<Rigidbody2D>().AddForce(((transform.position - damageSource.transform.position).normalized + Vector3.up * 2) * actualForce * (1 + (damage / maxDamage) * 3), ForceMode2D.Force);
}
damage += actualForce;
@@ -88,6 +91,7 @@ public class Damageable : MonoBehaviour
GetComponent<Rigidbody2D>().AddForce(((transform.position - damageSource.transform.position).normalized + Vector3.up * 2) * force, ForceMode2D.Force);
damage += force;
damage = Mathf.Clamp(damage, 0f, maxDamage);
if (damage >= maxDamage)
{
Die();
@@ -105,6 +109,8 @@ public class Damageable : MonoBehaviour
}
animator.SetBool("die", true);
dying = true;
AudioManager.Instance.PlaySound("Death Simple");
}
}

View File

@@ -132,6 +132,7 @@ public class PlayerMovement : MonoBehaviour
if ((virtualButtonJumpLastFrame == 1f && isBasicallyGrounded && jumping == false) // Coyote Jump: Must have jump pressed this frame and be grounded in last time frame and not be actually jumping.
|| (jumpInputStillValid && Time.time - lastTimeJumpPressed <= jumpLenience && IsPhysicallyGrounded())) // Buffered Jump: Must have pressed jump in the last time frame and be jumping
{
AudioManager.Instance.PlaySound("Jump");
jumpPhysics = true;
jumping = true;
jumpInputStillValid = false;

View File

@@ -40,7 +40,7 @@ public class UseItem : MonoBehaviour
}
}
private void PickUpItem(GameObject item) // Player picks up hat and starts hold counter
public void PickUpItem(GameObject item) // Player picks up hat and starts hold counter
{
if (damageable.dying) return; // Prevent picking up items if the player is dying
if (HatRespawn.canBePickedUp == false) return; // Prevent picking up items if they are not interactable
@@ -58,6 +58,7 @@ public class UseItem : MonoBehaviour
{
GameManager.playerHoldTimes[gameObject] = 0f;
}
AudioManager.Instance.PlaySound("Pickup Hat");
GameManager.Instance.StopCoroutine("MoveHatToWinner");
}