New features done #450

Merged
glencelow merged 2 commits from PlayerController into main 2023-04-01 00:42:19 +08:00
7 changed files with 544 additions and 83 deletions
Showing only changes of commit a76f2eca87 - Show all commits

View File

@ -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

View File

@ -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
@ -17474,3 +17474,164 @@
Enabled: true
aiGO: 158
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: ~

View File

@ -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
@ -15810,3 +15812,164 @@
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: ~

View File

@ -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<Item>().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<Transform>().GlobalPosition;
GameManager.Instance.RacoonCaught();
}
}
protected override void onCollisionEnter(CollisionInfo info)
{
}

View File

@ -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<TextRenderable>().Text = $"{Score}";
@ -114,8 +116,6 @@ public class GameManager : Script
protected override void update()
{
if (GamePause || !stealFoodPopUpDone)
{
return;
@ -148,55 +148,33 @@ public class GameManager : Script
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);
if (timer <= 0)
AudioHandler.audioClipHandlers["BGMLose"].Play();
goingToLose = true;
if (SceneFadeInOut.Instance != null)
SceneFadeInOut.Instance.CallFadeIn();
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)
{
if (SceneFadeInOut.Instance && SceneFadeInOut.Instance.FadeInFinished() && waitForTransition)
SceneManager.ChangeScene(winScene);
}
if (goingToLose)
{
SceneManager.ChangeScene(loseScene);
}
}
}
else
{
if (goingToWin)
{
SceneManager.ChangeScene(winScene);
}
if (goingToLose)
{
SceneManager.ChangeScene(loseScene);
}
}
}
public void RacoonCaught()
@ -216,19 +194,10 @@ public class GameManager : Script
{
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();

View File

@ -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<TextRenderable>();
if (!scoreText)
Debug.LogError("MISSING SCORE TEXT");
timeLeftText = timeLeft.GetComponent<TextRenderable>();
if (!timeLeftText)
Debug.LogError("MISSING TIME LEFT TEXT");
maxComboText = maxCombo.GetComponent<TextRenderable>();
if (!maxComboText)
Debug.LogError("MISSING MAX COMBO TEXT");
finalScoreText = finalScore.GetComponent<TextRenderable>();
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<UIElement>();
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;
}
}
}

View File

@ -0,0 +1,3 @@
Name: SC_Results
ID: 154482040
Type: 9