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();
|
||||||
|
|
||||||
SceneFadeInOut.Instance.CallFadeOut();
|
if (SceneFadeInOut.Instance != null)
|
||||||
|
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,7 +144,8 @@ public class GameManager : Script
|
||||||
AudioHandler.StopAllSounds(false);
|
AudioHandler.StopAllSounds(false);
|
||||||
AudioHandler.audioClipHandlers["BGMWin"].Play();
|
AudioHandler.audioClipHandlers["BGMWin"].Play();
|
||||||
goingToWin = true;
|
goingToWin = true;
|
||||||
SceneFadeInOut.Instance.CallFadeIn();
|
if (SceneFadeInOut.Instance != null)
|
||||||
|
SceneFadeInOut.Instance.CallFadeIn();
|
||||||
}
|
}
|
||||||
else if(!goingToWin && (timer < 0 || Input.GetKeyDown(Input.KeyCode.F2)))
|
else if(!goingToWin && (timer < 0 || Input.GetKeyDown(Input.KeyCode.F2)))
|
||||||
{
|
{
|
||||||
|
@ -146,12 +153,27 @@ public class GameManager : Script
|
||||||
AudioHandler.StopAllSounds(false);
|
AudioHandler.StopAllSounds(false);
|
||||||
AudioHandler.audioClipHandlers["BGMLose"].Play();
|
AudioHandler.audioClipHandlers["BGMLose"].Play();
|
||||||
goingToLose = true;
|
goingToLose = true;
|
||||||
SceneFadeInOut.Instance.CallFadeIn();
|
if (SceneFadeInOut.Instance != null)
|
||||||
|
SceneFadeInOut.Instance.CallFadeIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handling transitions
|
//Handling transitions
|
||||||
if (SceneFadeInOut.Instance.FadeInFinished())
|
if (SceneFadeInOut.Instance != null)
|
||||||
|
{
|
||||||
|
if (SceneFadeInOut.Instance.FadeInFinished())
|
||||||
|
{
|
||||||
|
if (goingToWin)
|
||||||
|
{
|
||||||
|
SceneManager.ChangeScene(winScene);
|
||||||
|
}
|
||||||
|
if (goingToLose)
|
||||||
|
{
|
||||||
|
SceneManager.ChangeScene(loseScene);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (goingToWin)
|
if (goingToWin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,22 +22,19 @@ 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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
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,7 +13,8 @@ public class PauseMenu : Script
|
||||||
|
|
||||||
protected override void awake()
|
protected override void awake()
|
||||||
{
|
{
|
||||||
GameManager.Instance.GamePause = false;
|
if (GameManager.Instance != null)
|
||||||
|
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
|
||||||
{
|
{
|
||||||
|
@ -64,7 +62,8 @@ namespace SHADE_Scripting.UI
|
||||||
}
|
}
|
||||||
if (alphaValue >= 1.0f)
|
if (alphaValue >= 1.0f)
|
||||||
{
|
{
|
||||||
alphaValue = 1.0f;
|
alphaValue = 1.0f;
|
||||||
|
//GameObject.Parent.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +81,10 @@ namespace SHADE_Scripting.UI
|
||||||
}
|
}
|
||||||
if (alphaValue <= 0.0f)
|
if (alphaValue <= 0.0f)
|
||||||
{
|
{
|
||||||
alphaValue = 0.0f;
|
alphaValue = 0.0f;
|
||||||
GameObject.Parent.SetActive(false);
|
//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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,8 @@ namespace SHADE
|
||||||
|
|
||||||
void SHWindow::SetMouseVisible(bool show)
|
void SHWindow::SetMouseVisible(bool show)
|
||||||
{
|
{
|
||||||
ShowCursor(show);
|
while(GetMouseVisible() != show)
|
||||||
|
ShowCursor(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHWindow::SetMousePosition(int x, int y)
|
void SHWindow::SetMousePosition(int x, int y)
|
||||||
|
|
Loading…
Reference in New Issue