Implemented mouse centering and hiding in game #384
|
@ -1,6 +1,6 @@
|
||||||
- VertexShader: 46580970
|
- VertexShader: 46580970
|
||||||
FragmentShader: 50110174
|
FragmentShader: 50110174
|
||||||
SubPass: UI
|
SubPass: UI Translucent
|
||||||
Properties:
|
Properties:
|
||||||
data.color: {x: 0, y: 0, z: 0, w: 1}
|
data.color: {x: 0, y: 0, z: 0, w: 1}
|
||||||
data.textureIndex: 0
|
data.textureIndex: 0
|
||||||
|
|
|
@ -95,18 +95,24 @@ public class GameManager : Script
|
||||||
AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
|
AudioHandler.audioClipHandlers["SFXHumming"].SetVolume(0.15f);
|
||||||
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
AudioHandler.audioClipHandlers["SFXHumming"].Play();
|
||||||
|
|
||||||
|
if (SceneFadeInOut.Instance != null)
|
||||||
SceneFadeInOut.Instance.CallFadeOut();
|
SceneFadeInOut.Instance.CallFadeOut();
|
||||||
|
Application.IsCursorVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
if (GamePause || !stealFoodPopUpDone)
|
if (GamePause || !stealFoodPopUpDone)
|
||||||
{
|
{
|
||||||
|
Input.SetMouseCentering(false);
|
||||||
|
//Application.IsCursorVisible = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currGameState == GameState.START)
|
if (currGameState == GameState.START)
|
||||||
{
|
{
|
||||||
|
Input.SetMouseCentering(true);
|
||||||
|
|
||||||
timer -= Time.DeltaTimeF;
|
timer -= Time.DeltaTimeF;
|
||||||
if(scoreText)
|
if(scoreText)
|
||||||
scoreText.GetComponent<TextRenderable>().Text = $"{Score}";
|
scoreText.GetComponent<TextRenderable>().Text = $"{Score}";
|
||||||
|
@ -138,6 +144,7 @@ public class GameManager : Script
|
||||||
AudioHandler.StopAllSounds(false);
|
AudioHandler.StopAllSounds(false);
|
||||||
AudioHandler.audioClipHandlers["BGMWin"].Play();
|
AudioHandler.audioClipHandlers["BGMWin"].Play();
|
||||||
goingToWin = true;
|
goingToWin = true;
|
||||||
|
if (SceneFadeInOut.Instance != null)
|
||||||
SceneFadeInOut.Instance.CallFadeIn();
|
SceneFadeInOut.Instance.CallFadeIn();
|
||||||
}
|
}
|
||||||
else if(!goingToWin && (timer < 0 || Input.GetKeyDown(Input.KeyCode.F2)))
|
else if(!goingToWin && (timer < 0 || Input.GetKeyDown(Input.KeyCode.F2)))
|
||||||
|
@ -146,11 +153,14 @@ public class GameManager : Script
|
||||||
AudioHandler.StopAllSounds(false);
|
AudioHandler.StopAllSounds(false);
|
||||||
AudioHandler.audioClipHandlers["BGMLose"].Play();
|
AudioHandler.audioClipHandlers["BGMLose"].Play();
|
||||||
goingToLose = true;
|
goingToLose = true;
|
||||||
|
if (SceneFadeInOut.Instance != null)
|
||||||
SceneFadeInOut.Instance.CallFadeIn();
|
SceneFadeInOut.Instance.CallFadeIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handling transitions
|
//Handling transitions
|
||||||
|
if (SceneFadeInOut.Instance != null)
|
||||||
|
{
|
||||||
if (SceneFadeInOut.Instance.FadeInFinished())
|
if (SceneFadeInOut.Instance.FadeInFinished())
|
||||||
{
|
{
|
||||||
if (goingToWin)
|
if (goingToWin)
|
||||||
|
@ -163,6 +173,18 @@ public class GameManager : Script
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (goingToWin)
|
||||||
|
{
|
||||||
|
SceneManager.ChangeScene(winScene);
|
||||||
|
}
|
||||||
|
if (goingToLose)
|
||||||
|
{
|
||||||
|
SceneManager.ChangeScene(loseScene);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void onDestroy()
|
protected override void onDestroy()
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,13 +22,11 @@ public class ChangeSceneButton : Script
|
||||||
{
|
{
|
||||||
ui.OnRelease.RegisterAction(() =>
|
ui.OnRelease.RegisterAction(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
if (sceneID != 0)
|
if (sceneID != 0)
|
||||||
{
|
{
|
||||||
Audio.PlaySFXOnce2D("event:/UI/success");
|
Audio.PlaySFXOnce2D("event:/UI/success");
|
||||||
|
|
||||||
Audio.StopAllSounds();
|
Audio.StopAllSounds();
|
||||||
|
if (SceneFadeInOut.Instance != null)
|
||||||
SceneFadeInOut.Instance.CallFadeIn();
|
SceneFadeInOut.Instance.CallFadeIn();
|
||||||
clickedFlag = true;
|
clickedFlag = true;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +35,6 @@ public class ChangeSceneButton : Script
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogError("Failed to register button action for ChangeSceneButton.");
|
Debug.LogError("Failed to register button action for ChangeSceneButton.");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void update()
|
protected override void update()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using SHADE;
|
using SHADE;
|
||||||
using SHADE_Scripting.Audio;
|
using SHADE_Scripting.Audio;
|
||||||
|
using SHADE_Scripting.UI;
|
||||||
|
|
||||||
public class EndScene : Script
|
public class EndScene : Script
|
||||||
{
|
{
|
||||||
|
@ -12,6 +13,15 @@ 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);
|
||||||
|
Debug.Log("EndScene::Start():");
|
||||||
|
Application.IsCursorVisible = true;
|
||||||
|
SceneFadeInOut.Instance.CallFadeOut();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
if (Input.GetKeyDown(Input.KeyCode.R))
|
if (Input.GetKeyDown(Input.KeyCode.R))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using SHADE;
|
using SHADE;
|
||||||
using SHADE_Scripting.Audio;
|
using SHADE_Scripting.Audio;
|
||||||
|
using SHADE_Scripting.UI;
|
||||||
|
|
||||||
public class MainMenu : Script
|
public class MainMenu : Script
|
||||||
{
|
{
|
||||||
|
@ -23,6 +24,9 @@ public class MainMenu : Script
|
||||||
|
|
||||||
protected override void start()
|
protected override void start()
|
||||||
{
|
{
|
||||||
|
Input.SetMouseCentering(false);
|
||||||
|
Application.IsCursorVisible = true;
|
||||||
|
SceneFadeInOut.Instance.CallFadeOut();
|
||||||
}
|
}
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@ public class PauseMenu : Script
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
|
if (GameManager.Instance != null)
|
||||||
GameManager.Instance.GamePause = false;
|
GameManager.Instance.GamePause = false;
|
||||||
|
|
||||||
if (canvas)
|
if (canvas)
|
||||||
|
@ -41,6 +42,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.Enabled = false;
|
gamePauseText.Enabled = false;
|
||||||
|
@ -91,6 +94,8 @@ public class PauseMenu : Script
|
||||||
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause && GameManager.Instance.stealFoodPopUpDone)
|
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause && GameManager.Instance.stealFoodPopUpDone)
|
||||||
{
|
{
|
||||||
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.Enabled = true;
|
gamePauseText.Enabled = true;
|
||||||
|
|
|
@ -43,7 +43,6 @@ namespace SHADE_Scripting.UI
|
||||||
|
|
||||||
protected override void start()
|
protected override void start()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void update()
|
protected override void update()
|
||||||
|
@ -56,7 +55,6 @@ namespace SHADE_Scripting.UI
|
||||||
if (fadeInTime == 0.0f)
|
if (fadeInTime == 0.0f)
|
||||||
{
|
{
|
||||||
alphaValue = 1.0f;
|
alphaValue = 1.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -65,6 +63,7 @@ namespace SHADE_Scripting.UI
|
||||||
if (alphaValue >= 1.0f)
|
if (alphaValue >= 1.0f)
|
||||||
{
|
{
|
||||||
alphaValue = 1.0f;
|
alphaValue = 1.0f;
|
||||||
|
//GameObject.Parent.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +82,8 @@ namespace SHADE_Scripting.UI
|
||||||
if (alphaValue <= 0.0f)
|
if (alphaValue <= 0.0f)
|
||||||
{
|
{
|
||||||
alphaValue = 0.0f;
|
alphaValue = 0.0f;
|
||||||
|
//This line is to be added so that (because the fade in and out item is usually the front-most UI element)
|
||||||
|
//the fade in and out UI element does not block functionality of other UI elements
|
||||||
GameObject.Parent.SetActive(false);
|
GameObject.Parent.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,7 @@ namespace SHADE
|
||||||
|
|
||||||
void SHWindow::SetMouseVisible(bool show)
|
void SHWindow::SetMouseVisible(bool show)
|
||||||
{
|
{
|
||||||
|
while(GetMouseVisible() != show)
|
||||||
ShowCursor(show);
|
ShowCursor(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue