From 152007e8100921320383ef4c472cd301bc02aa95 Mon Sep 17 00:00:00 2001 From: Glence Date: Wed, 23 Nov 2022 16:57:32 +0800 Subject: [PATCH] adding audio for the rest of the level setting player position so it doesnt fall through the floor --- Assets/Scenes/MainGame.shade | 38 +++++++++++++++---- .../Gameplay/Player/SC_PlayerController.cs | 31 +++++++++++++-- Assets/Scripts/Gameplay/SC_GameManager.cs | 11 +++++- Assets/Scripts/SC_MainMenu.cs | 1 + 4 files changed, 68 insertions(+), 13 deletions(-) diff --git a/Assets/Scenes/MainGame.shade b/Assets/Scenes/MainGame.shade index 6039151c..96235cf5 100644 --- a/Assets/Scenes/MainGame.shade +++ b/Assets/Scenes/MainGame.shade @@ -8220,7 +8220,7 @@ Interpolate: true Sleeping Enabled: true Freeze Position X: false - Freeze Position Y: false + Freeze Position Y: true Freeze Position Z: false Freeze Rotation X: true Freeze Rotation Y: true @@ -8240,6 +8240,7 @@ Scripts: - Type: PlayerController Enabled: true + respawnPoint: 239 currentState: 0 maxMoveVel: 3 moveForce: 50 @@ -8255,14 +8256,14 @@ Enabled: true throwForce: [300, 300, 300] delayTimer: 1 - aimingLength: 1.5 + aimingLength: 0.5 - EID: 3 Name: HoldingPoint IsActive: true NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 1.20000005, z: 0.5} + Translate: {x: 0, y: 0.699999988, z: 0.200000003} Rotate: {x: 0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} IsActive: true @@ -8369,7 +8370,11 @@ Position Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} IsActive: true - Scripts: ~ + Scripts: + - Type: Item + Enabled: true + Score: 10 + currCategory: 0 - EID: 242 Name: Mesh_Cheese IsActive: true @@ -8417,7 +8422,11 @@ Position Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} IsActive: true - Scripts: ~ + Scripts: + - Type: Item + Enabled: true + Score: 10 + currCategory: 0 - EID: 241 Name: Mesh_Meat IsActive: true @@ -8465,7 +8474,11 @@ Position Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0} IsActive: true - Scripts: ~ + Scripts: + - Type: Item + Enabled: true + Score: 10 + currCategory: 0 - EID: 15 Name: ====ScoreZonePool==== IsActive: true @@ -8547,4 +8560,15 @@ IsActive: true Scripts: - Type: ScoringZone - Enabled: true \ No newline at end of file + Enabled: true +- EID: 239 + Name: RespawnPoint + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 2.5, y: 0.660660267, z: 7} + Rotate: {x: -0, y: 0, z: -0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Scripts: ~ \ 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 4673d12c..72eb8f22 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -17,14 +17,14 @@ public class PlayerController : Script TOTAL } - public enum WalkingState +/* public enum WalkingState { CARRY, AIMING, THROW, WALK, TOTAL - } + }*/ public RigidBody rb { get; set; } private Transform tranform; @@ -36,6 +36,9 @@ public class PlayerController : Script public bool holdItem { get; set; } public bool isAiming { get; set; } + public GameObject respawnPoint; + private float delayTimer = 0.0f; + [Tooltip("The current state fo the raccoon")] public RaccoonStates currentState = RaccoonStates.IDLE; @@ -113,8 +116,27 @@ public class PlayerController : Script } + protected override void lateUpdate() + { + //rb.FreezePositionY = false; + } protected override void update() { + if (delayTimer <= 1) + delayTimer += Time.DeltaTimeF; + + if (delayTimer < 1) + { + if (tranform && respawnPoint && rb) + { + rb.LinearVelocity = Vector3.Zero; + tranform.LocalPosition = respawnPoint.GetComponent().LocalPosition; + } + } + else + { + rb.FreezePositionY = false; + } //PickAndThrow check if (!pat) { @@ -138,6 +160,7 @@ public class PlayerController : Script protected override void fixedUpdate() { + MoveKey(); Move(); Sprint(); @@ -341,12 +364,12 @@ public class PlayerController : Script private void GotCaught() { - if (currentState == RaccoonStates.CAUGHT && tranform != null) + if (currentState == RaccoonStates.CAUGHT && tranform && respawnPoint) { currentState = RaccoonStates.IDLE; if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState))) stateMachine.SetState(typeof(PlayerIdleState)); - tranform.LocalPosition = new Vector3(-3.0f, -2.0f, -5.0f); + tranform.LocalPosition = respawnPoint.GetComponent().LocalPosition; } } diff --git a/Assets/Scripts/Gameplay/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs index 2301a2a1..ff3a3160 100644 --- a/Assets/Scripts/Gameplay/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -14,6 +14,9 @@ public class GameManager : Script public GameObject itemPool; public GameObject zonePool; + public uint winScene = 92009475; + public uint loseScene = 91685359; + [NonSerialized] public GameState currGameState; [NonSerialized] @@ -52,15 +55,19 @@ public class GameManager : Script protected override void update() { if (timer > 0 && currGameState == GameState.START) - { + { timer -= Time.DeltaTimeF; if (totalItemCount <= 0) - { + { currGameState = GameState.WIN; + SceneManager.ChangeScene(winScene); } } else + { currGameState = GameState.LOSE; + SceneManager.ChangeScene(loseScene); + } } } diff --git a/Assets/Scripts/SC_MainMenu.cs b/Assets/Scripts/SC_MainMenu.cs index 9d6b4b4c..c7529e74 100644 --- a/Assets/Scripts/SC_MainMenu.cs +++ b/Assets/Scripts/SC_MainMenu.cs @@ -5,6 +5,7 @@ public class MainMenu : Script { protected override void awake() { + Audio.PlayBGMOnce2D("event:/Music/player_undetected"); } protected override void update() {