added sound script and menu
This commit is contained in:
22
Assets/Scripts/UI/AudioController.cs
Normal file
22
Assets/Scripts/UI/AudioController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/AudioController.cs.meta
Normal file
2
Assets/Scripts/UI/AudioController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e85ac425eb34fa41af76223e92aec68
|
||||
8
Assets/Scripts/UI/AudioVIew.cs
Normal file
8
Assets/Scripts/UI/AudioVIew.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioVIew : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
2
Assets/Scripts/UI/AudioVIew.cs.meta
Normal file
2
Assets/Scripts/UI/AudioVIew.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63a465db551023e4899a8803730af5a0
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
38
Assets/Scripts/UI/GameScreenController.cs
Normal file
38
Assets/Scripts/UI/GameScreenController.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
2
Assets/Scripts/UI/GameScreenController.cs.meta
Normal file
2
Assets/Scripts/UI/GameScreenController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e9850b4745033047ad9293264a28101
|
||||
33
Assets/Scripts/UI/GameScreenView.cs
Normal file
33
Assets/Scripts/UI/GameScreenView.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/GameScreenView.cs.meta
Normal file
2
Assets/Scripts/UI/GameScreenView.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dca5ef66eb1c58a419af8a5c2b4b3886
|
||||
38
Assets/Scripts/UI/PauseScreenController.cs
Normal file
38
Assets/Scripts/UI/PauseScreenController.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/PauseScreenController.cs.meta
Normal file
2
Assets/Scripts/UI/PauseScreenController.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e684a4de28d7cdc48994f59a24f98908
|
||||
24
Assets/Scripts/UI/PauseScreenView.cs
Normal file
24
Assets/Scripts/UI/PauseScreenView.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/PauseScreenView.cs.meta
Normal file
2
Assets/Scripts/UI/PauseScreenView.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00144c3e01b1f804cbf7b44181344295
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user