Pause is done

This commit is contained in:
Glence 2023-02-21 00:47:20 +08:00
parent 09d88b5a70
commit d7725f4e26
4 changed files with 170 additions and 35 deletions

View File

@ -9563,11 +9563,17 @@
timer: 200 timer: 200
scoreText: 237 scoreText: 237
timeText: 206 timeText: 206
gamePauseText: 11
multiplierText: 139 multiplierText: 139
maxMultiplierDuration: 5 maxMultiplierDuration: 5
maxMultiplierCombo: 10 maxMultiplierCombo: 10
multiplierFont: 60 multiplierFont: 60
- Type: PauseMenu
Enabled: true
resumeBtn: 8
retryBtn: 461
quitBtn: 0
gamePauseText: 11
canvas: 10
- EID: 199 - EID: 199
Name: =====Text==== Name: =====Text====
IsActive: true IsActive: true
@ -9625,14 +9631,14 @@
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: -145, y: 200, z: 0} Translate: {x: -250, y: 300, z: 0}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60, z: 60} Scale: {x: 100, y: 100, z: 100}
IsActive: true IsActive: true
Text Renderer Component: Text Renderer Component:
Text: Game Pause Text: Game Pause
Font: 176667660 Font: 176667660
IsActive: true IsActive: false
Scripts: ~ Scripts: ~
- EID: 198 - EID: 198
Name: ====Raccoon==== Name: ====Raccoon====
@ -9733,8 +9739,8 @@
Pitch: 0 Pitch: 0
Yaw: 360 Yaw: 360
Roll: 1.28065994e-06 Roll: 1.28065994e-06
Width: 1055 Width: 2560
Height: 604 Height: 1369
Near: 0.00999999978 Near: 0.00999999978
Far: 10000 Far: 10000
Perspective: true Perspective: true
@ -10627,7 +10633,7 @@
- EID: 10 - EID: 10
Name: Canvas Name: Canvas
IsActive: false IsActive: false
NumberOfChildren: 1 NumberOfChildren: 3
Components: Components:
Canvas Component: Canvas Component:
Canvas Width: 1920 Canvas Width: 1920
@ -10635,12 +10641,12 @@
IsActive: false IsActive: false
Scripts: ~ Scripts: ~
- EID: 8 - EID: 8
Name: Default Name: ResumeButton
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: 0, z: 0} Translate: {x: 0, y: 100, z: 0}
Rotate: {x: 0, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 300, y: 200, z: 500} Scale: {x: 300, y: 200, z: 500}
IsActive: true IsActive: true
@ -10657,3 +10663,49 @@
Canvas ID: 10 Canvas ID: 10
IsActive: true IsActive: true
Scripts: ~ Scripts: ~
- EID: 0
Name: QuitButton
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -300, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 300, y: 200, z: 500}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 66477839
Hovered Texture: 65045286
Clicked Texture: 58607560
IsActive: true
UI Component:
Canvas ID: 10
IsActive: true
Scripts: ~
- EID: 461
Name: RetryButton
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -100, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 300, y: 200, z: 500}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Button Component:
Default Texture: 55782622
Hovered Texture: 58972174
Clicked Texture: 55224464
IsActive: true
UI Component:
Canvas ID: 10
IsActive: true
Scripts: ~

View File

@ -26,7 +26,6 @@ public class GameManager : Script
public GameObject scoreText; public GameObject scoreText;
public GameObject timeText; public GameObject timeText;
public GameObject gamePauseText;
//mulitpler info //mulitpler info
public GameObject multiplierText; public GameObject multiplierText;
@ -80,7 +79,6 @@ public class GameManager : Script
currMultiplierCombo = 1; currMultiplierCombo = 1;
currMultiplierDuration = 0; currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration); fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
GamePause = false;
AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win"); AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win");
AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose"); AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose");
@ -90,24 +88,9 @@ public class GameManager : Script
{ {
if (GamePause) if (GamePause)
{ {
if (Input.GetKeyDown(Input.KeyCode.Escape) && GamePause)
{
GamePause = false;
AudioHandler.pauseAllSounds(false);
gamePauseText.GetComponent<TextRenderable>().Enabled = false;
}
return; return;
} }
//Cheats();
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GamePause)
{
GamePause = true;
AudioHandler.pauseAllSounds(true);
gamePauseText.GetComponent<TextRenderable>().Enabled = true;
}
if (currGameState == GameState.START) if (currGameState == GameState.START)
{ {
timer -= Time.DeltaTimeF; timer -= Time.DeltaTimeF;
@ -164,15 +147,6 @@ public class GameManager : Script
Instance = null; Instance = null;
} }
private void Cheats()
{
if (Input.GetKeyDown(Input.KeyCode.Escape))
{
Audio.StopAllSounds();
SceneManager.ChangeScene(97158628);
}
}
public void ItemScored() public void ItemScored()
{ {
totalItemCount -= 1; totalItemCount -= 1;

View File

@ -0,0 +1,106 @@
using System;
using SHADE;
using SHADE_Scripting.Audio;
public class PauseMenu : Script
{
public GameObject resumeBtn;
public GameObject retryBtn;
public GameObject quitBtn;
public GameObject gamePauseText;
public GameObject canvas;
protected override void awake()
{
GameManager.Instance.GamePause = false;
if (gamePauseText)
gamePauseText.GetComponent<TextRenderable>().Enabled = false;
if (canvas)
canvas.SetActive(false);
if (!resumeBtn)
Debug.LogError("Resume Btn missing");
if (!retryBtn)
Debug.LogError("Retry Btn missing");
if (!quitBtn)
Debug.LogError("Quit Btn missing");
}
protected override void start()
{
//resume
UIElement resume = resumeBtn.GetComponent<UIElement>();
if (resume != null)
{
resume.OnClick.RegisterAction(() =>
{
if (GameManager.Instance.GamePause)
{
GameManager.Instance.GamePause = false;
AudioHandler.pauseAllSounds(false);
if (gamePauseText)
gamePauseText.GetComponent<TextRenderable>().Enabled = false;
if (canvas)
canvas.SetActive(false);
}
});
}
else
{
Debug.LogError("Failed to register resume button.");
}
//retry
UIElement retry = retryBtn.GetComponent<UIElement>();
if (retry != null)
{
retry.OnClick.RegisterAction(() =>
{
Audio.StopAllSounds();
//get curr scene
//SceneManager.ChangeScene();
});
}
else
{
Debug.LogError("Failed to register retry button.");
}
UIElement quit = quitBtn.GetComponent<UIElement>();
if (quit != null)
{
quit.OnClick.RegisterAction(() =>
{
Audio.StopAllSounds();
//go to main menu
SceneManager.ChangeScene(97158628);
});
}
else
{
Debug.LogError("Failed to register quit button.");
}
}
protected override void update()
{
if (GameManager.Instance.GamePause)
{
return;
}
if (Input.GetKeyDown(Input.KeyCode.Escape) && !GameManager.Instance.GamePause)
{
GameManager.Instance.GamePause = true;
AudioHandler.pauseAllSounds(true);
if (gamePauseText)
gamePauseText.GetComponent<TextRenderable>().Enabled = true;
if (canvas)
canvas.SetActive(true);
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_PauseMenu
ID: 151952680
Type: 9