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)
{
Input.SetMouseCentering(false);
Application.IsCursorVisible = true;
return;
}
if (currGameState == GameState.START)
{
Input.SetMouseCentering(true);
Application.IsCursorVisible = false;
timer -= Time.DeltaTimeF;
if(scoreText)
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["SFXUISuccess"] = Audio.CreateAudioClip("event:/UI/success");
}
protected override void start()
{
Input.SetMouseCentering(false);
Application.IsCursorVisible = true;
}
protected override void update()
{
if (Input.GetKeyDown(Input.KeyCode.R))

View File

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

View File

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