Implemented mouse centering and hiding in game #384

Merged
mushgunAX merged 9 commits from SP3-10-input-management into main 2023-03-03 18:29:54 +08:00
4 changed files with 18 additions and 0 deletions
Showing only changes of commit a04eee0a2f - Show all commits

View File

@ -90,11 +90,16 @@ public class GameManager : Script
{ {
if (GamePause) if (GamePause)
{ {
Input.SetMouseCentering(false);
Application.IsCursorVisible = true;
return; return;
} }
if (currGameState == GameState.START) if (currGameState == GameState.START)
{ {
Input.SetMouseCentering(true);
Application.IsCursorVisible = false;
timer -= Time.DeltaTimeF; timer -= Time.DeltaTimeF;
if(scoreText) if(scoreText)
scoreText.GetComponent<TextRenderable>().Text = $"Score: {Score}"; scoreText.GetComponent<TextRenderable>().Text = $"Score: {Score}";

View File

@ -12,6 +12,13 @@ public class EndScene : Script
AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element"); AudioHandler.audioClipHandlers["SFXMouseDownElement"] = Audio.CreateAudioClip("event:/UI/mouse_down_element");
AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success"); AudioHandler.audioClipHandlers["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
} }
protected override void start()
{
Input.SetMouseCentering(false);
Application.IsCursorVisible = true;
}
protected override void update() protected override void update()
{ {
if (Input.GetKeyDown(Input.KeyCode.R)) if (Input.GetKeyDown(Input.KeyCode.R))

View File

@ -23,6 +23,8 @@ public class MainMenu : Script
protected override void start() protected override void start()
{ {
Input.SetMouseCentering(false);
Application.IsCursorVisible = true;
} }
protected override void update() protected override void update()
{ {

View File

@ -39,6 +39,8 @@ public class PauseMenu : Script
if (GameManager.Instance.GamePause) if (GameManager.Instance.GamePause)
{ {
GameManager.Instance.GamePause = false; GameManager.Instance.GamePause = false;
Input.SetMouseCentering(true);
Application.IsCursorVisible = false;
AudioHandler.PauseAllSounds(false); AudioHandler.PauseAllSounds(false);
if (gamePauseText) if (gamePauseText)
gamePauseText.GetComponent<TextRenderable>().Enabled = false; gamePauseText.GetComponent<TextRenderable>().Enabled = false;
@ -89,6 +91,8 @@ public class PauseMenu : Script
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause) if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause)
{ {
GameManager.Instance.GamePause = true; GameManager.Instance.GamePause = true;
Input.SetMouseCentering(false);
Application.IsCursorVisible = true;
AudioHandler.PauseAllSounds(true); AudioHandler.PauseAllSounds(true);
if (gamePauseText) if (gamePauseText)
gamePauseText.GetComponent<TextRenderable>().Enabled = true; gamePauseText.GetComponent<TextRenderable>().Enabled = true;