diff --git a/Assets/Scenes/Level1.shade b/Assets/Scenes/Level1.shade index 88086f58..019b946d 100644 --- a/Assets/Scenes/Level1.shade +++ b/Assets/Scenes/Level1.shade @@ -7594,7 +7594,6 @@ - Type: GameManager Enabled: true winScene: 86098106 - loseScene: 91685359 currGameState: 0 totalItemCount: 4 Score: 0 @@ -7602,6 +7601,7 @@ scoreText: 237 timeText: 131278 minusTimerText: 131211 + Results: 626 multiplierText: 66055 maxMultiplierDuration: 5 maxMultiplierCombo: 10 @@ -9510,15 +9510,24 @@ Scripts: ~ - EID: 626 Name: Result Canvas - IsActive: true + IsActive: false NumberOfChildren: 6 Components: Canvas Component: Canvas Width: 1920 Canvas Height: 1080 Scale by canvas width: false - IsActive: true - Scripts: ~ + IsActive: false + Scripts: + - Type: Results + Enabled: true + score: 623 + timeLeft: 622 + maxCombo: 621 + finalScore: 620 + contiuneBtn: 624 + nextScene: 86098106 + scoreTweenDur: 2 - EID: 624 Name: Contiune_BTN IsActive: true @@ -9644,7 +9653,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 50, y: -285, z: 0.400000006} + Translate: {x: 0, y: -285, z: 0.400000006} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 1, y: 1, z: 1} IsActive: true diff --git a/Assets/Scenes/Level2.shade b/Assets/Scenes/Level2.shade index 8246c9aa..376d3b66 100644 --- a/Assets/Scenes/Level2.shade +++ b/Assets/Scenes/Level2.shade @@ -3881,7 +3881,6 @@ - Type: GameManager Enabled: true winScene: 88928066 - loseScene: 91685359 currGameState: 0 totalItemCount: 0 Score: 0 @@ -3889,6 +3888,7 @@ scoreText: 237 timeText: 131278 minusTimerText: 131211 + Results: 624 multiplierText: 66055 maxMultiplierDuration: 5 maxMultiplierCombo: 10 @@ -17473,4 +17473,165 @@ - Type: SHADE_Scripting.Gameplay.AIBehaviour.AIRework.HomeOwnerAttackHitbox Enabled: true aiGO: 158 - raccoonFound: false \ No newline at end of file + raccoonFound: false +- EID: 624 + Name: Result Canvas + IsActive: false + NumberOfChildren: 6 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: false + Scripts: + - Type: Results + Enabled: true + score: 621 + timeLeft: 620 + maxCombo: 612 + finalScore: 610 + contiuneBtn: 623 + nextScene: 88928066 + scoreTweenDur: 2 +- EID: 623 + Name: Contiune_BTN + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 300, y: -400, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 344, y: 166, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 59330417 + Hovered Texture: 55195346 + Clicked Texture: 56163414 + IsActive: true + UI Component: + Canvas ID: 624 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/UI/botton_hover + onHoverExitSound: Empty + onClickSound: event:/UI/button_success + onReleaseSound: event:/UI/button_fail + hoverScale: 1.10000002 + clickScale: 0.899999976 +- EID: 622 + Name: Result_BG + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1024, y: 1024, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 130179375 + IsActive: true + UI Component: + Canvas ID: 624 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 621 + Name: Score_text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 50, y: 175, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 80, y: 80, z: 80} + IsActive: true + UI Component: + Canvas ID: 624 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 620 + Name: TimeLeft_Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 50, y: 45, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 80, y: 80, z: 80} + IsActive: true + UI Component: + Canvas ID: 624 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 612 + Name: MaxCombo_Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 50, y: -80, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 80, y: 80, z: 80} + IsActive: true + UI Component: + Canvas ID: 624 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 610 + Name: FinalScore_Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -285, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 160, y: 160, z: 160} + IsActive: true + UI Component: + Canvas ID: 624 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ \ No newline at end of file diff --git a/Assets/Scenes/Level3.shade b/Assets/Scenes/Level3.shade index 394523f4..a65d0a77 100644 --- a/Assets/Scenes/Level3.shade +++ b/Assets/Scenes/Level3.shade @@ -9053,7 +9053,6 @@ - Type: GameManager Enabled: true winScene: 84606951 - loseScene: 91685359 currGameState: 0 totalItemCount: 0 Score: 0 @@ -9061,6 +9060,7 @@ scoreText: 237 timeText: 66135 minusTimerText: 66057 + Results: 505 multiplierText: 66055 maxMultiplierDuration: 5 maxMultiplierCombo: 10 @@ -15578,6 +15578,7 @@ - Type: SHADE_Scripting.Gameplay.AIBehaviour.AIRework.HomeOwnerAI Enabled: true idleDuration: 1 + caughtDuration: 2 timeoutDuration: 2 patrolPointParent: 541 patrolSpeed: 1 @@ -15624,6 +15625,7 @@ - Type: SHADE_Scripting.Gameplay.AIBehaviour.AIRework.HomeOwnerAttackHitbox Enabled: true aiGO: 66078 + raccoonFound: false - EID: 66062 Name: Gameplay Canvas IsActive: true @@ -15809,4 +15811,165 @@ Hovered: false Clicked: false IsActive: true + Scripts: ~ +- EID: 505 + Name: Result Canvas + IsActive: false + NumberOfChildren: 6 + Components: + Canvas Component: + Canvas Width: 1920 + Canvas Height: 1080 + Scale by canvas width: false + IsActive: false + Scripts: + - Type: Results + Enabled: true + score: 486 + timeLeft: 485 + maxCombo: 484 + finalScore: 274 + contiuneBtn: 488 + nextScene: 84606951 + scoreTweenDur: 2 +- EID: 488 + Name: Contiune_BTN + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 300, y: -400, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 344, y: 166, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Button Component: + Default Texture: 59330417 + Hovered Texture: 55195346 + Clicked Texture: 56163414 + IsActive: true + UI Component: + Canvas ID: 505 + Hovered: false + Clicked: false + IsActive: true + Scripts: + - Type: SHADE_Scripting.UI.ButtonFX + Enabled: true + onHoverEnterSound: event:/UI/botton_hover + onHoverExitSound: Empty + onClickSound: event:/UI/button_success + onReleaseSound: event:/UI/button_fail + hoverScale: 1.10000002 + clickScale: 0.899999976 +- EID: 487 + Name: Result_BG + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: 0, z: 0.5} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1024, y: 1024, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 130179375 + IsActive: true + UI Component: + Canvas ID: 505 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 486 + Name: Score_text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 50, y: 175, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 80, y: 80, z: 80} + IsActive: true + UI Component: + Canvas ID: 505 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 485 + Name: TimeLeft_Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 50, y: 45, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 80, y: 80, z: 80} + IsActive: true + UI Component: + Canvas ID: 505 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 484 + Name: MaxCombo_Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 50, y: -80, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 80, y: 80, z: 80} + IsActive: true + UI Component: + Canvas ID: 505 + Hovered: false + Clicked: false + IsActive: true + Scripts: ~ +- EID: 274 + Name: FinalScore_Text + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -285, z: 0.400000006} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Text Renderer Component: + Text: 0 + Font: 174412429 + Color: {x: 1, y: 1, z: 1, w: 1} + Text Size: {x: 160, y: 160, z: 160} + IsActive: true + UI Component: + Canvas ID: 505 + Hovered: false + Clicked: false + 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 89679ff1..7235ef8b 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -538,6 +538,46 @@ public class PlayerController : Script } } + public void Caught() + { + currentState = RaccoonStates.CAUGHT; + if (stateMachine && !stateMachine.IsState(typeof(PlayerCaughtState))) + stateMachine.SetState(typeof(PlayerCaughtState)); + + AudioHandler.audioClipHandlers["RaccoonCaught"].Play(); + if (pat && pat.item) + { + if (holdItem) + { + holdItem = false; + pat.item.GetScript().returnBack = true; + pat.SetItemGravityBack(); + pat.ResetItemObject(); + } + if (isAiming) + { + isAiming = false; + cam.FOV = Settings.cameraFOV; + camArm.TargetOffset = pat.prevTargetOffSet; + camArm.ArmLength = pat.tpc.armLength; + } + } + } + + public void Reset() + { + if (currentState == RaccoonStates.CAUGHT && tranform && respawnPoint) + { + currentState = RaccoonStates.IDLE; + if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState))) + stateMachine.SetState(typeof(PlayerIdleState)); + + tranform.GlobalPosition = respawnPoint.GetComponent().GlobalPosition; + + GameManager.Instance.RacoonCaught(); + } + } + protected override void onCollisionEnter(CollisionInfo info) { } diff --git a/Assets/Scripts/Gameplay/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs index 0579abd9..59a56106 100644 --- a/Assets/Scripts/Gameplay/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -10,12 +10,10 @@ public class GameManager : Script public enum GameState { START, - WIN, - LOSE + OVER } public uint winScene = 92009475; - public uint loseScene = 91685359; [NonSerialized] public GameState currGameState; @@ -30,6 +28,12 @@ public class GameManager : Script public GameObject timeText; public GameObject minusTimerText; + public GameObject Results; + public int MaxComboAccquired { get; set; } + public int finalTime { get; set; } + public int finalScore { get; set; } + + //mulitpler info public GameObject multiplierText; public float maxMultiplierDuration = 5.0f; @@ -48,8 +52,7 @@ public class GameManager : Script public bool itemShatter { get; set; } //For scene transitions - private bool goingToWin; - private bool goingToLose; + private bool waitForTransition; private bool playSpeedUp = false; @@ -79,8 +82,7 @@ public class GameManager : Script loseAudio.DestroyOnSceneExit = false; AudioHandler.audioClipHandlers["BGMLose"] = loseAudio; - goingToWin = false; - goingToLose = false; + waitForTransition = false; if (scoreText) scoreText.GetComponent().Text = $"{Score}"; @@ -114,8 +116,6 @@ public class GameManager : Script protected override void update() { - - if (GamePause || !stealFoodPopUpDone) { return; @@ -124,7 +124,7 @@ public class GameManager : Script Cheat(); if (currGameState == GameState.START) - { + { timer -= Time.DeltaTimeF; if (timer < 30.0f && !playSpeedUp) @@ -133,9 +133,9 @@ public class GameManager : Script playSpeedUp = true; } - if(scoreText) + if (scoreText) scoreText.GetComponent().Text = $"{Score}"; - if(timeText) + if (timeText) timeText.GetComponent().Text = $"{timer.ToString("0")}"; if (itemScored) @@ -143,92 +143,61 @@ public class GameManager : Script currMultiplierDuration += Time.DeltaTimeF; if (currMultiplierDuration >= maxMultiplierDuration) - { + { itemScored = false; currMultiplierCombo = 1; currMultiplierDuration = 0; } - } - if (!goingToLose && ((timer > 0 && totalItemCount <= 0 && !itemShatter))) + if (timer <= 0 || (totalItemCount <= 0 && !itemShatter)) { - currGameState = GameState.WIN; AudioHandler.StopAllSounds(false); - AudioHandler.audioClipHandlers["BGMWin"].Play(); - goingToWin = true; - if (SceneFadeInOut.Instance != null) - SceneFadeInOut.Instance.CallFadeIn(); - } - else if(!goingToWin && (timer < 0)) - { - currGameState = GameState.LOSE; - AudioHandler.StopAllSounds(false); - AudioHandler.audioClipHandlers["BGMLose"].Play(); - goingToLose = true; - if (SceneFadeInOut.Instance != null) - SceneFadeInOut.Instance.CallFadeIn(); + + if (timer <= 0) + AudioHandler.audioClipHandlers["BGMLose"].Play(); + else if (totalItemCount <= 0) + AudioHandler.audioClipHandlers["BGMWin"].Play(); + + currGameState = GameState.OVER; + finalTime = (int)timer; + Results.SetActive(true); + + Input.SetMouseCentering(false); + Application.IsCursorVisible = true; + GamePause = true; + Application.FixDeltaTime = 0; + AnimationSystem.TimeScale = 0; } } - //Handling transitions - if (SceneFadeInOut.Instance != null) - { - if (SceneFadeInOut.Instance.FadeInFinished()) - { - if (goingToWin) - { - SceneManager.ChangeScene(winScene); - } - if (goingToLose) - { - SceneManager.ChangeScene(loseScene); - } - } - } - else - { - if (goingToWin) - { - SceneManager.ChangeScene(winScene); - } - if (goingToLose) - { - SceneManager.ChangeScene(loseScene); - } - } + + if (SceneFadeInOut.Instance && SceneFadeInOut.Instance.FadeInFinished() && waitForTransition) + SceneManager.ChangeScene(winScene); + } public void RacoonCaught() + { + timer -= 10.0f; + if (minusTimerText != GameObject.Null) { - timer -= 10.0f; - if(minusTimerText != GameObject.Null) - { - MinusTimerText text =minusTimerText.GetScript(); - if(text) - { - text.Reset(); - } - } + MinusTimerText text = minusTimerText.GetScript(); + if (text) + { + text.Reset(); + } } + } private void Cheat() { if (Input.GetKeyUp(Input.KeyCode.F1)) { - currGameState = GameState.WIN; + currGameState = GameState.OVER; AudioHandler.audioClipHandlers["BGMWin"].Play(); AudioHandler.StopAllSounds(false); - goingToWin = true; - if (SceneFadeInOut.Instance != null) - SceneFadeInOut.Instance.CallFadeIn(); - } - else if (Input.GetKeyUp(Input.KeyCode.F2)) - { - currGameState = GameState.LOSE; - AudioHandler.audioClipHandlers["BGMLose"].Play(); - AudioHandler.StopAllSounds(false); - goingToLose = true; + waitForTransition = true; if (SceneFadeInOut.Instance != null) SceneFadeInOut.Instance.CallFadeIn(); } @@ -255,7 +224,11 @@ public class GameManager : Script currMultiplierDuration = 0; if (currMultiplierCombo < maxMultiplierCombo) + { currMultiplierCombo += 1; + if (currMultiplierCombo > MaxComboAccquired) + MaxComboAccquired = currMultiplierCombo; + } Audio.SetParameter("Multiplier", currMultiplierCombo); AudioHandler.audioClipHandlers["SFXItemScore"].Play(); diff --git a/Assets/Scripts/UI/SC_Results.cs b/Assets/Scripts/UI/SC_Results.cs new file mode 100644 index 00000000..b61c1c44 --- /dev/null +++ b/Assets/Scripts/UI/SC_Results.cs @@ -0,0 +1,112 @@ +using SHADE; +using SHADE_Scripting.UI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +public class Results : Script +{ + public GameObject score; + public GameObject timeLeft; + public GameObject maxCombo; + public GameObject finalScore; + public GameObject contiuneBtn; + public uint nextScene; + public float scoreTweenDur = 2.0f; + + private TextRenderable scoreText; + private TextRenderable timeLeftText; + private TextRenderable maxComboText; + private TextRenderable finalScoreText; + + private int scoreCount = 0; + private bool once = true; + + [NonSerialized] + private TweenThread scoreTween; + + private bool waitForTransition; + protected override void awake() + { + scoreText = score.GetComponent(); + if (!scoreText) + Debug.LogError("MISSING SCORE TEXT"); + + timeLeftText = timeLeft.GetComponent(); + if (!timeLeftText) + Debug.LogError("MISSING TIME LEFT TEXT"); + + maxComboText = maxCombo.GetComponent(); + if (!maxComboText) + Debug.LogError("MISSING MAX COMBO TEXT"); + + finalScoreText = finalScore.GetComponent(); + if (!finalScoreText) + Debug.LogError("MISSING FINAL SCORE TEXT"); + + if (!contiuneBtn) + Debug.LogError("MISSING CONTIUNE BTN"); + else + contiuneBtn.SetActive(false); + + waitForTransition = false; + } + + protected override void start() + { + scoreCount = GameManager.Instance.Score + (GameManager.Instance.finalTime * 100); + + if(scoreText) + scoreText.Text = $"{GameManager.Instance.Score}"; + if (timeLeftText) + timeLeftText.Text = $"{GameManager.Instance.finalTime}s"; + if (maxComboText) + maxComboText.Text = $"X{GameManager.Instance.MaxComboAccquired}"; + if (finalScoreText) + finalScoreText.Text = $"{scoreCount}"; + + UIElement contiune = contiuneBtn.GetComponent(); + if (contiune != null) + { + contiune.OnRelease.RegisterAction(() => + { + if (SceneFadeInOut.Instance != null) + SceneFadeInOut.Instance.CallFadeIn(); + + waitForTransition = true; + + GameManager.Instance.GamePause = false; + Application.FixDeltaTime = Time.DefaultFixDeltaTime; + AnimationSystem.TimeScale = AnimationSystem.DefaultTimeScale; + }); + } + else + { + Debug.LogError("Failed to register contiune button."); + } + + scoreTween = TweenManager.CreateTweenThread(scoreTweenDur, 0, scoreCount, EASING_METHOD.EASE_IN_SINE); + } + + protected override void update() + { + if (SceneFadeInOut.Instance && SceneFadeInOut.Instance.FadeInFinished() && waitForTransition) + { + Audio.StopAllSounds(); + SceneManager.ChangeScene(nextScene); + } + + if (finalScoreText && !scoreTween.IsCompleted()) + finalScoreText.Text = $"{(int)scoreTween.GetValue()}"; + else if(scoreTween.IsCompleted() && once) + { + contiuneBtn.SetActive(true); + finalScoreText.Text = $"{scoreCount}"; + once = false; + } + } +} + diff --git a/Assets/Scripts/UI/SC_Results.cs.shmeta b/Assets/Scripts/UI/SC_Results.cs.shmeta new file mode 100644 index 00000000..a85c2c34 --- /dev/null +++ b/Assets/Scripts/UI/SC_Results.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_Results +ID: 154482040 +Type: 9