added sound script and menu

This commit is contained in:
Mausham
2025-12-12 16:16:37 -08:00
parent 2118bb7c36
commit 06ca472bb3
33 changed files with 1842 additions and 181 deletions

View File

@@ -1,3 +1,4 @@
using System.Collections;
using UnityEngine;
using VContainer;
@@ -7,12 +8,15 @@ public class Player : MonoBehaviour, IPlayer
public Rigidbody BallRb;
public bool isDead { get; private set; }
public GameObject splashObject;
[Inject] ScoreService scoreService;
[Inject] InputReader inputReader;
[Inject] DeathScreenController deathScreenController;
void Start()
{
if (BallRb == null)
{
BallRb = GetComponent<Rigidbody>();
@@ -23,7 +27,11 @@ public class Player : MonoBehaviour, IPlayer
{
if (collision.collider.CompareTag("Platform") && !isDead)
{
ContactPoint contact = collision.contacts[0];
Vector3 contactOffset = new Vector3(0, 0.1f, 0);
GameObject currentSplash = Instantiate(splashObject, contact.point+contactOffset,splashObject.transform.rotation);
BallRb.linearVelocity = new Vector3(0, jumpforce, 0);
Destroy(currentSplash,0.2f);
}
else if (collision.collider.CompareTag("Death"))
{
@@ -35,7 +43,15 @@ public class Player : MonoBehaviour, IPlayer
{
Debug.Log("Player is Dead");
isDead = true;
deathScreenController.ShowDeathScreen(scoreService.score,scoreService.GetHighscore());
StartCoroutine(DieRoutine());
}
IEnumerator DieRoutine()
{
inputReader.isBlocked = true;
yield return new WaitForSeconds(1f);
Time.timeScale = 0;
deathScreenController.ShowDeathScreen(scoreService.score, scoreService.GetHighscore());
}