From dfe4d047e91405069c7e1df3b83fdb057be8791f Mon Sep 17 00:00:00 2001 From: Glence Date: Sat, 18 Feb 2023 22:21:23 +0800 Subject: [PATCH 1/4] added a jumppad to the game --- Assets/Scenes/MainGame.shade | 37 ++++++++++++++++--- .../Gameplay/Player/SC_PlayerController.cs | 14 ++++++- Assets/Scripts/SC_JumpPad.cs | 22 +++++++++++ Assets/Scripts/SC_JumpPad.cs.shmeta | 3 ++ 4 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 Assets/Scripts/SC_JumpPad.cs create mode 100644 Assets/Scripts/SC_JumpPad.cs.shmeta diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 87343839..53b5a0a0 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -9671,6 +9671,7 @@ maxJumpHeight: 2 maxJumpTime: 0.75 fallMultipler: 3 + jumpPadMultiplayer: 1.20000005 lightMultiper: 0.75 mediumMultiper: 0.5 heavyMultiper: 0.25 @@ -9682,6 +9683,7 @@ aimingLength: 1 throwItem: false rayDistance: 0.75 + rayHeight: 0.100000001 - EID: 3 Name: HoldingPoint IsActive: true @@ -10483,11 +10485,11 @@ Translate: {x: 2.70000005, y: 0.100000001, z: -2} Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} - IsActive: true + IsActive: false Renderable Component: Mesh: 140697366 Material: 129495479 - IsActive: true + IsActive: false RigidBody Component: Type: Dynamic Drag: 0.00999999978 @@ -10501,7 +10503,7 @@ Freeze Rotation X: true Freeze Rotation Y: false Freeze Rotation Z: true - IsActive: true + IsActive: false Collider Component: Colliders: - Is Trigger: false @@ -10513,7 +10515,7 @@ Density: 1 Position Offset: {x: 0, y: 0.899999976, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} - IsActive: true + IsActive: false Scripts: - Type: Homeowner1 Enabled: true @@ -10525,4 +10527,29 @@ eyeOffset: [0, 1.64999998, 0] distanceToCapture: 0.5 captureTime: 0.5 - footstepSFXIntervalMultiplier: 0.5 \ No newline at end of file + footstepSFXIntervalMultiplier: 0.5 +- EID: 16 + Name: Default + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 3.43332767, y: 0.149463654, z: 6.84711409} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Collider Component: + Colliders: + - Is Trigger: false + Collision Tag: 0 + Type: Box + Half Extents: {x: 1, y: 0.25, z: 1} + Friction: 0.400000006 + Bounciness: 0 + Density: 1 + Position Offset: {x: 0, y: 0, z: 0} + Rotation Offset: {x: 0, y: 0, z: 0} + IsActive: true + Scripts: + - Type: JumpPad + Enabled: true \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs index d66e7e30..202e587e 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -65,7 +65,7 @@ public class PlayerController : Script //Jumping vars================================================================== [Tooltip("max height of the jump")] public float maxJumpHeight = 1.0f; - [Tooltip("max amt of time it will take for the jump")] + [Tooltip("max amount of time it will take for the jump")] public float maxJumpTime = 0.5f; [Tooltip("increase gravity when falling")] public float fallMultipler = 3.0f; @@ -73,6 +73,9 @@ public class PlayerController : Script private bool isGrounded = true; private float gravity = -9.8f; private float groundGravity = -0.5f; + public bool landedOnJumpPad { get; set; } + [Tooltip("multiply height on Jump Pad ")] + public float jumpPadMultiplayer = 2.0f; //ItemMultipler================================================================== [Tooltip("How light item will affect player jump")] @@ -88,6 +91,7 @@ public class PlayerController : Script isMoveKeyPress = false; holdItem = false; isAiming = false; + landedOnJumpPad = false; //Jump setup float timeToApex = maxJumpTime / 2; @@ -287,7 +291,7 @@ public class PlayerController : Script { if (currentState == RaccoonStates.WALKING || currentState == RaccoonStates.RUNNING || currentState == RaccoonStates.IDLE) { - if (Input.GetKeyDown(Input.KeyCode.Space) && isGrounded && rb != null) + if ( (Input.GetKeyDown(Input.KeyCode.Space) || landedOnJumpPad ) && isGrounded && rb != null) { currentState = RaccoonStates.JUMP; Vector3 v = rb.LinearVelocity; @@ -302,6 +306,12 @@ public class PlayerController : Script if (item != null && item.currCategory == ItemCategory.HEAVY) v.y *= heavyMultiper; } + + if (landedOnJumpPad) + { + v.y *= jumpPadMultiplayer; + landedOnJumpPad = false; + } rb.LinearVelocity = v; } } diff --git a/Assets/Scripts/SC_JumpPad.cs b/Assets/Scripts/SC_JumpPad.cs new file mode 100644 index 00000000..0e331f8c --- /dev/null +++ b/Assets/Scripts/SC_JumpPad.cs @@ -0,0 +1,22 @@ +using SHADE; +using System; + +public class JumpPad : Script +{ + protected override void awake() + { + } + + protected override void update() + { + } + + protected override void onCollisionEnter(CollisionInfo info) + { + if (info.GameObject.GetScript() && info.GameObject.GetScript().currentState == PlayerController.RaccoonStates.FALLING) + { + info.GameObject.GetScript().landedOnJumpPad = true; + } + } + +} diff --git a/Assets/Scripts/SC_JumpPad.cs.shmeta b/Assets/Scripts/SC_JumpPad.cs.shmeta new file mode 100644 index 00000000..62a99f19 --- /dev/null +++ b/Assets/Scripts/SC_JumpPad.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_JumpPad +ID: 167326885 +Type: 9 -- 2.40.1 From d754a0b5c3836c7a236a7b15f57c5affc48c976d Mon Sep 17 00:00:00 2001 From: Glence Date: Sat, 18 Feb 2023 23:43:43 +0800 Subject: [PATCH 2/4] added targetOffSet to camera position --- SHADE_Engine/src/Camera/SHCameraSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SHADE_Engine/src/Camera/SHCameraSystem.cpp b/SHADE_Engine/src/Camera/SHCameraSystem.cpp index 6ebbd078..d508fc09 100644 --- a/SHADE_Engine/src/Camera/SHCameraSystem.cpp +++ b/SHADE_Engine/src/Camera/SHCameraSystem.cpp @@ -265,7 +265,7 @@ namespace SHADE { camera.offset = arm->GetOffset(); if (arm->lookAtCameraOrigin) - CameraLookAt(camera, camera.position); + CameraLookAt(camera, camera.position + arm->GetTargetOffset()); } -- 2.40.1 From 09d88b5a70d75974ae64265867daa119a20f8579 Mon Sep 17 00:00:00 2001 From: Glence Date: Mon, 20 Feb 2023 19:53:22 +0800 Subject: [PATCH 3/4] small bug fixes for text and serialization and added game pause --- Assets/Scenes/MainGame.shade | 137 +++++++++++++++--- Assets/Scripts/Audio/AudioHandler.cs | 8 + .../Gameplay/Player/SC_PickAndThrow.cs | 15 +- .../Gameplay/Player/SC_ThirdPersonCamera.cs | 16 +- Assets/Scripts/Gameplay/SC_GameManager.cs | 26 +++- .../SHTextRenderingSubSystem.cpp | 4 + .../src/Serialization/SHSerialization.cpp | 7 + 7 files changed, 183 insertions(+), 30 deletions(-) diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index f1b16c1b..5e30379e 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -9563,6 +9563,7 @@ timer: 200 scoreText: 237 timeText: 206 + gamePauseText: 11 multiplierText: 139 maxMultiplierDuration: 5 maxMultiplierCombo: 10 @@ -9570,7 +9571,7 @@ - EID: 199 Name: =====Text==== IsActive: true - NumberOfChildren: 3 + NumberOfChildren: 4 Components: ~ Scripts: ~ - EID: 237 @@ -9618,6 +9619,21 @@ Font: 176667660 IsActive: true Scripts: ~ +- EID: 11 + Name: GamePause + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: -145, y: 200, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 60, y: 60, z: 60} + IsActive: true + Text Renderer Component: + Text: Game Pause + Font: 176667660 + IsActive: true + Scripts: ~ - EID: 198 Name: ====Raccoon==== IsActive: true @@ -9677,18 +9693,20 @@ maxJumpTime: 0.75 fallMultipler: 3 jumpPadMultiplayer: 1.20000005 - lightMultiper: 0.75 - mediumMultiper: 0.5 - heavyMultiper: 0.25 + lightMultiper: 0.899999976 + mediumMultiper: 0.699999988 + heavyMultiper: 0.5 - Type: PickAndThrow Enabled: true throwForce: [10, 8, 10] - cameraArmOffSet: [0, 0.25, 0] + cameraArmOffSet: [0.25, 0.600000024, 0.200000003] delayTimer: 1 aimingLength: 1 throwItem: false rayDistance: 0.75 rayHeight: 0.100000001 + aimingFOV: 50 + defaultFOV: 45 - EID: 3 Name: HoldingPoint IsActive: true @@ -9715,30 +9733,31 @@ Pitch: 0 Yaw: 360 Roll: 1.28065994e-06 - Width: 1920 - Height: 1080 + Width: 1055 + Height: 604 Near: 0.00999999978 Far: 10000 Perspective: true + FOV: 45 IsActive: true Camera Arm Component: Arm Pitch: 0 Arm Yaw: 0 Arm Length: 3 Look At Camera Origin: true - Target Offset: {x: 0, y: 0, z: 0} + Target Offset: {x: 0, y: 0.75, z: 0} Camera Collision: true IsActive: true Scripts: - Type: SHADE_Scripting.ThirdPersonCamera Enabled: true armLength: 3 - turnSpeedPitch: 0.300000012 - turnSpeedYaw: 0.5 - pitchClamp: 45 + turnSpeedPitch: 0.200000003 + turnSpeedYaw: 0.400000006 inverseXControls: false - inverseYControls: true - lowerClamp: 5 + inverseYControls: false + pitchUpperClamp: 45 + pitchLowerClamp: 5 - EID: 9 Name: PlayerBag IsActive: true @@ -10533,28 +10552,108 @@ distanceToCapture: 0.5 captureTime: 0.5 footstepSFXIntervalMultiplier: 0.5 -- EID: 16 - Name: Default +- EID: 12 + Name: Mesh_Meat IsActive: true NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 3.43332767, y: 0.149463654, z: 6.84711409} + Translate: {x: 2.30459714, y: 0.209537908, z: 6.371418} Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} IsActive: true + Renderable Component: + Mesh: 136892700 + Material: 131956078 + IsActive: true + RigidBody Component: + Type: Dynamic + Drag: 0.00999999978 + Angular Drag: 0.100000001 + Use Gravity: true + Interpolate: false + Sleeping Enabled: true + Freeze Position X: false + Freeze Position Y: false + Freeze Position Z: false + Freeze Rotation X: false + Freeze Rotation Y: false + Freeze Rotation Z: false + IsActive: true Collider Component: Colliders: - Is Trigger: false - Collision Tag: 0 + Collision Tag: 2 Type: Box - Half Extents: {x: 1, y: 0.25, z: 1} + Half Extents: {x: 0.300000012, y: 0.300000012, z: 0.300000012} Friction: 0.400000006 Bounciness: 0 Density: 1 Position Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} IsActive: true + Scripts: + - Type: Item + Enabled: true + Score: 50 + currCategory: 1 + density: 1 + dontReturn: false +- EID: 16 + Name: JumpPad + IsActive: false + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 3.43332767, y: 0.149463654, z: 6.84711409} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: false + Collider Component: + Colliders: + - Is Trigger: false + Collision Tag: 1 + Type: Box + Half Extents: {x: 1, y: 0.25, z: 1} + Friction: 0.400000006 + Bounciness: 0 + Density: 1 + Position Offset: {x: 0, y: 0, z: 0} + Rotation Offset: {x: 0, y: 0, z: 0} + IsActive: false Scripts: - Type: JumpPad - Enabled: true \ No newline at end of file + Enabled: true +- EID: 10 + Name: Canvas + IsActive: false + NumberOfChildren: 1 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + IsActive: false + Scripts: ~ +- EID: 8 + Name: Default + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, 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: 52901020 + Hovered Texture: 62235279 + Clicked Texture: 64722619 + IsActive: true + UI Component: + Canvas ID: 10 + IsActive: true + Scripts: ~ \ No newline at end of file diff --git a/Assets/Scripts/Audio/AudioHandler.cs b/Assets/Scripts/Audio/AudioHandler.cs index f2e552c1..c6067819 100644 --- a/Assets/Scripts/Audio/AudioHandler.cs +++ b/Assets/Scripts/Audio/AudioHandler.cs @@ -19,5 +19,13 @@ namespace SHADE_Scripting.Audio h.Value.Stop(fadeOut); } } + + public static void pauseAllSounds(bool pause) + { + foreach (KeyValuePair h in audioClipHandlers) + { + h.Value.SetPause(pause); + } + } } } diff --git a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs index a2f1ddb8..d5046db1 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs @@ -8,7 +8,7 @@ using static Item; public class PickAndThrow : Script { - public Vector3 throwForce = new Vector3(100.0f, 200.0f, 100.0f); + public Vector3 throwForce = new Vector3(10.0f, 8.0f, 10.0f); public Vector3 cameraArmOffSet = new Vector3(0.0f, 0.25f, 0.0f); public GameObject item { get; set; } public float delayTimer = 1.0f; @@ -33,6 +33,9 @@ public class PickAndThrow : Script [Tooltip("Height of ray")] public float rayHeight = 0.1f; + public float aimingFOV = 50; + public float defaultFOV = 45; + protected override void awake() { pc = GetScript(); @@ -74,6 +77,7 @@ public class PickAndThrow : Script pc.isAiming = true; pc.camArm.ArmLength = aimingLength; pc.camArm.TargetOffset = cameraArmOffSet; + pc.cam.FOV = aimingFOV; } if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming) @@ -83,6 +87,7 @@ public class PickAndThrow : Script itemCollider.GetCollisionShape(0).IsTrigger = false; pc.isAiming = false; pc.camArm.TargetOffset = Vector3.Zero; + pc.cam.FOV = defaultFOV; if (tpc) pc.camArm.ArmLength = tpc.armLength; pc.holdItem = false; @@ -103,6 +108,7 @@ public class PickAndThrow : Script if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming) { pc.isAiming = false; + pc.cam.FOV = defaultFOV; pc.camArm.TargetOffset = Vector3.Zero; if (tpc) pc.camArm.ArmLength = tpc.armLength; @@ -132,7 +138,7 @@ public class PickAndThrow : Script { if (itemScript) { - Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir); + Vector3 vec = new Vector3(throwForce.x * lastXDir, throwForce.y + (throwForce.y * GetPitchRatioRange()), throwForce.z * lastZDir); if (itemScript.currCategory == ItemCategory.LIGHT) itemRidigBody.AddForce(vec * 0.2f); if (itemScript.currCategory == ItemCategory.MEDIUM) @@ -254,5 +260,10 @@ public class PickAndThrow : Script return false; } + private float GetPitchRatioRange() + { + return (pc.camArm.Pitch - tpc.pitchUpperClamp) / (tpc.pitchLowerClamp - tpc.pitchUpperClamp); + } + } \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs b/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs index b03dbf2f..c3026ce6 100644 --- a/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs +++ b/Assets/Scripts/Gameplay/Player/SC_ThirdPersonCamera.cs @@ -14,10 +14,10 @@ namespace SHADE_Scripting public float armLength = 2.0f; public float turnSpeedPitch = 0.3f; public float turnSpeedYaw = 0.5f; - public float pitchClamp = 45.0f; public bool inverseXControls = false; public bool inverseYControls = false; - public float lowerClamp = 5.0f; + public float pitchUpperClamp = 45.0f; + public float pitchLowerClamp = 5.0f; protected override void awake() { @@ -51,17 +51,17 @@ namespace SHADE_Scripting arm.Pitch += vel.y * turnSpeedPitch * Time.DeltaTimeF; if (inverseXControls) - arm.Yaw -= vel.x * turnSpeedYaw * Time.DeltaTimeF; - else arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF; + else + arm.Yaw -= vel.x * turnSpeedYaw * Time.DeltaTimeF; - if (arm.Pitch > pitchClamp) + if (arm.Pitch > pitchUpperClamp) { - arm.Pitch = pitchClamp; + arm.Pitch = pitchUpperClamp; } - else if (arm.Pitch < lowerClamp) + else if (arm.Pitch < pitchLowerClamp) { - arm.Pitch = lowerClamp; + arm.Pitch = pitchLowerClamp; } } } diff --git a/Assets/Scripts/Gameplay/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs index 83b0747a..24a7012b 100644 --- a/Assets/Scripts/Gameplay/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -26,6 +26,7 @@ public class GameManager : Script public GameObject scoreText; public GameObject timeText; + public GameObject gamePauseText; //mulitpler info public GameObject multiplierText; @@ -38,6 +39,9 @@ public class GameManager : Script private Vector3 fontScalar; public static GameManager Instance { get; private set; } + //public static int highScore { get; private set; } maybe need + + public bool GamePause { get; set; } protected override void start() { @@ -76,6 +80,7 @@ public class GameManager : Script currMultiplierCombo = 1; currMultiplierDuration = 0; fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration); + GamePause = false; AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win"); AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose"); @@ -83,7 +88,26 @@ public class GameManager : Script protected override void update() { - Cheats(); + if (GamePause) + { + if (Input.GetKeyDown(Input.KeyCode.Escape) && GamePause) + { + GamePause = false; + AudioHandler.pauseAllSounds(false); + gamePauseText.GetComponent().Enabled = false; + } + return; + } + + //Cheats(); + + if (Input.GetKeyDown(Input.KeyCode.Escape) && !GamePause) + { + GamePause = true; + AudioHandler.pauseAllSounds(true); + gamePauseText.GetComponent().Enabled = true; + } + if (currGameState == GameState.START) { timer -= Time.DeltaTimeF; diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp index ffd5ac96..e1935634 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/TextRendering/SHTextRenderingSubSystem.cpp @@ -13,6 +13,7 @@ #include "Math/Transform/SHTransformComponent.h" #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" #include "Graphics/MiddleEnd/Interface/SHRenderer.h" +#include "Scene/SHSceneManager.h" namespace SHADE { @@ -184,6 +185,9 @@ namespace SHADE for (auto& comp : textRendererComps) { + if (!SHSceneManager::CheckNodeAndComponentsActive(comp.GetEID())) + continue; + auto* transform = SHComponentManager::GetComponent(comp.GetEID()); Handle fontHandle = comp.fontHandle; diff --git a/SHADE_Engine/src/Serialization/SHSerialization.cpp b/SHADE_Engine/src/Serialization/SHSerialization.cpp index bb0f4a43..febca024 100644 --- a/SHADE_Engine/src/Serialization/SHSerialization.cpp +++ b/SHADE_Engine/src/Serialization/SHSerialization.cpp @@ -70,6 +70,7 @@ namespace SHADE //Compile component IDs const auto componentIDList = SHSerialization::GetComponentIDList(node[ComponentsNode]); eid = SHEntityManager::CreateEntity(componentIDList, eid, name, parentEID); + createdEntities[oldEID] = eid; //createdEntities.push_back(eid); if (node[NumberOfChildrenNode]) @@ -90,6 +91,12 @@ namespace SHADE if (node[ScriptsNode]) SHSystemManager::GetSystem()->DeserialiseScripts(eid, node[ScriptsNode]); + auto& sceneGraph = SHSceneManager::GetCurrentSceneGraph(); + if (node[IsActiveNode]) + { + sceneGraph.SetActive(eid, node[IsActiveNode].as()); + } + return eid; } -- 2.40.1 From d7725f4e26f1c8e03c171d2bb6834585a8b3e28b Mon Sep 17 00:00:00 2001 From: Glence Date: Tue, 21 Feb 2023 00:47:20 +0800 Subject: [PATCH 4/4] Pause is done --- Assets/Scenes/MainGame.shade | 70 ++++++++++++-- Assets/Scripts/Gameplay/SC_GameManager.cs | 26 ------ Assets/Scripts/UI/SC_PauseMenu.cs | 106 ++++++++++++++++++++++ Assets/Scripts/UI/SC_PauseMenu.cs.shmeta | 3 + 4 files changed, 170 insertions(+), 35 deletions(-) create mode 100644 Assets/Scripts/UI/SC_PauseMenu.cs create mode 100644 Assets/Scripts/UI/SC_PauseMenu.cs.shmeta diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 5e30379e..591c386f 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -9563,11 +9563,17 @@ timer: 200 scoreText: 237 timeText: 206 - gamePauseText: 11 multiplierText: 139 maxMultiplierDuration: 5 maxMultiplierCombo: 10 multiplierFont: 60 + - Type: PauseMenu + Enabled: true + resumeBtn: 8 + retryBtn: 461 + quitBtn: 0 + gamePauseText: 11 + canvas: 10 - EID: 199 Name: =====Text==== IsActive: true @@ -9625,14 +9631,14 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: -145, y: 200, z: 0} + Translate: {x: -250, y: 300, 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 Text Renderer Component: Text: Game Pause Font: 176667660 - IsActive: true + IsActive: false Scripts: ~ - EID: 198 Name: ====Raccoon==== @@ -9733,8 +9739,8 @@ Pitch: 0 Yaw: 360 Roll: 1.28065994e-06 - Width: 1055 - Height: 604 + Width: 2560 + Height: 1369 Near: 0.00999999978 Far: 10000 Perspective: true @@ -10627,7 +10633,7 @@ - EID: 10 Name: Canvas IsActive: false - NumberOfChildren: 1 + NumberOfChildren: 3 Components: Canvas Component: Canvas Width: 1920 @@ -10635,12 +10641,12 @@ IsActive: false Scripts: ~ - EID: 8 - Name: Default + Name: ResumeButton IsActive: true NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 0, z: 0} + Translate: {x: 0, y: 100, z: 0} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 300, y: 200, z: 500} IsActive: true @@ -10656,4 +10662,50 @@ UI Component: Canvas ID: 10 IsActive: true + 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: ~ \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs index 24a7012b..6478b5ea 100644 --- a/Assets/Scripts/Gameplay/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -26,7 +26,6 @@ public class GameManager : Script public GameObject scoreText; public GameObject timeText; - public GameObject gamePauseText; //mulitpler info public GameObject multiplierText; @@ -80,7 +79,6 @@ public class GameManager : Script currMultiplierCombo = 1; currMultiplierDuration = 0; fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration); - GamePause = false; AudioHandler.audioClipHandlers["BGMWin"] = Audio.CreateAudioClip("event:/Music/stingers/game_win"); AudioHandler.audioClipHandlers["BGMLose"] = Audio.CreateAudioClip("event:/Music/stingers/game_lose"); @@ -90,24 +88,9 @@ public class GameManager : Script { if (GamePause) { - if (Input.GetKeyDown(Input.KeyCode.Escape) && GamePause) - { - GamePause = false; - AudioHandler.pauseAllSounds(false); - gamePauseText.GetComponent().Enabled = false; - } return; } - //Cheats(); - - if (Input.GetKeyDown(Input.KeyCode.Escape) && !GamePause) - { - GamePause = true; - AudioHandler.pauseAllSounds(true); - gamePauseText.GetComponent().Enabled = true; - } - if (currGameState == GameState.START) { timer -= Time.DeltaTimeF; @@ -164,15 +147,6 @@ public class GameManager : Script Instance = null; } - private void Cheats() - { - if (Input.GetKeyDown(Input.KeyCode.Escape)) - { - Audio.StopAllSounds(); - SceneManager.ChangeScene(97158628); - } - } - public void ItemScored() { totalItemCount -= 1; diff --git a/Assets/Scripts/UI/SC_PauseMenu.cs b/Assets/Scripts/UI/SC_PauseMenu.cs new file mode 100644 index 00000000..eae7aa91 --- /dev/null +++ b/Assets/Scripts/UI/SC_PauseMenu.cs @@ -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().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(); + if (resume != null) + { + resume.OnClick.RegisterAction(() => + { + if (GameManager.Instance.GamePause) + { + GameManager.Instance.GamePause = false; + AudioHandler.pauseAllSounds(false); + if (gamePauseText) + gamePauseText.GetComponent().Enabled = false; + if (canvas) + canvas.SetActive(false); + } + }); + } + else + { + Debug.LogError("Failed to register resume button."); + } + + //retry + UIElement retry = retryBtn.GetComponent(); + 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(); + 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().Enabled = true; + if (canvas) + canvas.SetActive(true); + } + + } +} + diff --git a/Assets/Scripts/UI/SC_PauseMenu.cs.shmeta b/Assets/Scripts/UI/SC_PauseMenu.cs.shmeta new file mode 100644 index 00000000..0ddcf762 --- /dev/null +++ b/Assets/Scripts/UI/SC_PauseMenu.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_PauseMenu +ID: 151952680 +Type: 9 -- 2.40.1