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

@@ -0,0 +1,22 @@
using UnityEngine;
public class AudioController:MonoBehaviour
{
public AudioSource SFXSource;
public AudioSource MusicSource;
//public AudioClip backgroundclip;
// public AudioClip deadClip;
//public AudioClip jumpClip;
private void Start()
{
///MusicSource.clip = backgroundclip;
// MusicSource.Play();
}
public void PlaySFX(AudioClip clip)
{
SFXSource.PlayOneShot(clip);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8e85ac425eb34fa41af76223e92aec68

View File

@@ -0,0 +1,8 @@
using UnityEngine;
public class AudioVIew : MonoBehaviour
{
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 63a465db551023e4899a8803730af5a0

View File

@@ -8,6 +8,8 @@ public class DeathScreenController
private DeathScreenView _view;
[Inject] private StartScreenController startScreenController;
[Inject] private GameScreenController gameScreenController;
[Inject] private InputReader _inputReader;
public DeathScreenController(DeathScreenView view)
{
_view = view;
@@ -22,18 +24,26 @@ public class DeathScreenController
private void OnReplayBtnClicked()
{
HideDeathScreen();
Time.timeScale = 1;
_inputReader.isBlocked = false;
SceneManager.LoadScene(0);
Debug.Log("Game Replayed");
}
private void OnBackBtnClicked()
{
HideDeathScreen();
Time.timeScale = 1;
_inputReader.isBlocked = false;
SceneManager.LoadScene(0);
}
public void ShowDeathScreen(int score, int highscore)
{
gameScreenController.HideGameScreen();
_view.Show(score,highscore);
}
}

View File

@@ -0,0 +1,38 @@
using System;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
using VContainer;
public class GameScreenController
{
private GameScreenView gameScreenView;
[Inject] private PauseScreenController pauseScreenController;
public GameScreenController (GameScreenView gameScreenView)
{
this.gameScreenView = gameScreenView;
this.gameScreenView.pauseBtn.onClick.AddListener(PauseBtnClicked);
}
public void ShowGameScreen()
{
gameScreenView.Show();
}
public void HideGameScreen()
{
gameScreenView.Hide();
}
private void PauseBtnClicked()
{
Time.timeScale = 0;
pauseScreenController.ShowPauseScreen();
}
public void UpdateScore(int score)
{
gameScreenView.SetScore(score);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0e9850b4745033047ad9293264a28101

View File

@@ -0,0 +1,33 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using VContainer;
public class GameScreenView : MonoBehaviour
{
public GameObject gameScreen;
public TextMeshProUGUI ScoreText;
public Button pauseBtn;
private void Start()
{
ScoreText.text = "0";
gameScreen.SetActive(false);
}
public void Show()
{
gameScreen.SetActive(true);
}
public void Hide()
{
gameScreen.SetActive(false);
}
public void SetScore(int score)
{
ScoreText.text = score.ToString();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: dca5ef66eb1c58a419af8a5c2b4b3886

View File

@@ -0,0 +1,38 @@
using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using VContainer;
public class PauseScreenController
{
private PauseScreenView _pauseScreenView;
[Inject]private InputReader _inputReader;
public PauseScreenController(PauseScreenView pauseScreenView)
{
this._pauseScreenView = pauseScreenView;
_pauseScreenView.resumeBtn.onClick.AddListener( ResumeBtnClicked);
_pauseScreenView.BackBtn.onClick.AddListener(BackBtnClicked);
}
public void ShowPauseScreen()
{
_inputReader.isBlocked = true;
_pauseScreenView.Show();
}
private void ResumeBtnClicked()
{
_inputReader.isBlocked = false;
Time.timeScale = 1.0f;
_pauseScreenView.Hide();
}
public void BackBtnClicked()
{
_inputReader.isBlocked = false;
_pauseScreenView.Hide();
Time.timeScale = 1.0f;
SceneManager.LoadScene(0);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e684a4de28d7cdc48994f59a24f98908

View File

@@ -0,0 +1,24 @@
using UnityEngine;
using UnityEngine.UI;
public class PauseScreenView : MonoBehaviour
{
public GameObject pauseScreen;
public Button resumeBtn;
public Button BackBtn;
private void Start()
{
pauseScreen.SetActive(false);
}
public void Show()
{
pauseScreen.SetActive(true);
}
public void Hide()
{
pauseScreen.SetActive(false);
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 00144c3e01b1f804cbf7b44181344295

View File

@@ -5,6 +5,7 @@ public class StartScreenController
{
private StartScreenView _view;
public bool hasGameStarted = false;
[Inject] GameScreenController gameScreenController;
public StartScreenController(StartScreenView view)
{
@@ -18,6 +19,7 @@ public class StartScreenController
{
_view.Hide();
hasGameStarted = true;
gameScreenController.ShowGameScreen();
}
public void ShowStartScreen()

View File

@@ -7,6 +7,11 @@ public class StartScreenView : MonoBehaviour
public GameObject startScreen;
public Button playBtn;
private void Start()
{
startScreen.SetActive(true);
}
public void Hide()
{
startScreen.SetActive(false);