Bug fixes for textrenderable and sterilization, added base for game pause #354

Merged
glencelow merged 5 commits from PlayerController into main 2023-02-21 15:49:10 +08:00
7 changed files with 183 additions and 30 deletions
Showing only changes of commit 09d88b5a70 - Show all commits

View File

@ -9563,6 +9563,7 @@
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
@ -9570,7 +9571,7 @@
- EID: 199 - EID: 199
Name: =====Text==== Name: =====Text====
IsActive: true IsActive: true
NumberOfChildren: 3 NumberOfChildren: 4
Components: ~ Components: ~
Scripts: ~ Scripts: ~
- EID: 237 - EID: 237
@ -9618,6 +9619,21 @@
Font: 176667660 Font: 176667660
IsActive: true IsActive: true
Scripts: ~ 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 - EID: 198
Name: ====Raccoon==== Name: ====Raccoon====
IsActive: true IsActive: true
@ -9677,18 +9693,20 @@
maxJumpTime: 0.75 maxJumpTime: 0.75
fallMultipler: 3 fallMultipler: 3
jumpPadMultiplayer: 1.20000005 jumpPadMultiplayer: 1.20000005
lightMultiper: 0.75 lightMultiper: 0.899999976
mediumMultiper: 0.5 mediumMultiper: 0.699999988
heavyMultiper: 0.25 heavyMultiper: 0.5
- Type: PickAndThrow - Type: PickAndThrow
Enabled: true Enabled: true
throwForce: [10, 8, 10] throwForce: [10, 8, 10]
cameraArmOffSet: [0, 0.25, 0] cameraArmOffSet: [0.25, 0.600000024, 0.200000003]
delayTimer: 1 delayTimer: 1
aimingLength: 1 aimingLength: 1
throwItem: false throwItem: false
rayDistance: 0.75 rayDistance: 0.75
rayHeight: 0.100000001 rayHeight: 0.100000001
aimingFOV: 50
defaultFOV: 45
- EID: 3 - EID: 3
Name: HoldingPoint Name: HoldingPoint
IsActive: true IsActive: true
@ -9715,30 +9733,31 @@
Pitch: 0 Pitch: 0
Yaw: 360 Yaw: 360
Roll: 1.28065994e-06 Roll: 1.28065994e-06
Width: 1920 Width: 1055
Height: 1080 Height: 604
Near: 0.00999999978 Near: 0.00999999978
Far: 10000 Far: 10000
Perspective: true Perspective: true
FOV: 45
IsActive: true IsActive: true
Camera Arm Component: Camera Arm Component:
Arm Pitch: 0 Arm Pitch: 0
Arm Yaw: 0 Arm Yaw: 0
Arm Length: 3 Arm Length: 3
Look At Camera Origin: true 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 Camera Collision: true
IsActive: true IsActive: true
Scripts: Scripts:
- Type: SHADE_Scripting.ThirdPersonCamera - Type: SHADE_Scripting.ThirdPersonCamera
Enabled: true Enabled: true
armLength: 3 armLength: 3
turnSpeedPitch: 0.300000012 turnSpeedPitch: 0.200000003
turnSpeedYaw: 0.5 turnSpeedYaw: 0.400000006
pitchClamp: 45
inverseXControls: false inverseXControls: false
inverseYControls: true inverseYControls: false
lowerClamp: 5 pitchUpperClamp: 45
pitchLowerClamp: 5
- EID: 9 - EID: 9
Name: PlayerBag Name: PlayerBag
IsActive: true IsActive: true
@ -10533,28 +10552,108 @@
distanceToCapture: 0.5 distanceToCapture: 0.5
captureTime: 0.5 captureTime: 0.5
footstepSFXIntervalMultiplier: 0.5 footstepSFXIntervalMultiplier: 0.5
- EID: 16 - EID: 12
Name: Default Name: Mesh_Meat
IsActive: true IsActive: true
NumberOfChildren: 0 NumberOfChildren: 0
Components: Components:
Transform Component: 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} Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1} Scale: {x: 1, y: 1, z: 1}
IsActive: true 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: Collider Component:
Colliders: Colliders:
- Is Trigger: false - Is Trigger: false
Collision Tag: 0 Collision Tag: 2
Type: Box 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 Friction: 0.400000006
Bounciness: 0 Bounciness: 0
Density: 1 Density: 1
Position Offset: {x: 0, y: 0, z: 0} Position Offset: {x: 0, y: 0, z: 0}
Rotation Offset: {x: 0, y: 0, z: 0} Rotation Offset: {x: 0, y: 0, z: 0}
IsActive: true 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: Scripts:
- Type: JumpPad - Type: JumpPad
Enabled: true 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: ~

View File

@ -19,5 +19,13 @@ namespace SHADE_Scripting.Audio
h.Value.Stop(fadeOut); h.Value.Stop(fadeOut);
} }
} }
public static void pauseAllSounds(bool pause)
{
foreach (KeyValuePair<string, AudioClipHandler> h in audioClipHandlers)
{
h.Value.SetPause(pause);
}
}
} }
} }

View File

@ -8,7 +8,7 @@ using static Item;
public class PickAndThrow : Script 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 Vector3 cameraArmOffSet = new Vector3(0.0f, 0.25f, 0.0f);
public GameObject item { get; set; } public GameObject item { get; set; }
public float delayTimer = 1.0f; public float delayTimer = 1.0f;
@ -33,6 +33,9 @@ public class PickAndThrow : Script
[Tooltip("Height of ray")] [Tooltip("Height of ray")]
public float rayHeight = 0.1f; public float rayHeight = 0.1f;
public float aimingFOV = 50;
public float defaultFOV = 45;
protected override void awake() protected override void awake()
{ {
pc = GetScript<PlayerController>(); pc = GetScript<PlayerController>();
@ -74,6 +77,7 @@ public class PickAndThrow : Script
pc.isAiming = true; pc.isAiming = true;
pc.camArm.ArmLength = aimingLength; pc.camArm.ArmLength = aimingLength;
pc.camArm.TargetOffset = cameraArmOffSet; pc.camArm.TargetOffset = cameraArmOffSet;
pc.cam.FOV = aimingFOV;
} }
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming) if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
@ -83,6 +87,7 @@ public class PickAndThrow : Script
itemCollider.GetCollisionShape(0).IsTrigger = false; itemCollider.GetCollisionShape(0).IsTrigger = false;
pc.isAiming = false; pc.isAiming = false;
pc.camArm.TargetOffset = Vector3.Zero; pc.camArm.TargetOffset = Vector3.Zero;
pc.cam.FOV = defaultFOV;
if (tpc) if (tpc)
pc.camArm.ArmLength = tpc.armLength; pc.camArm.ArmLength = tpc.armLength;
pc.holdItem = false; pc.holdItem = false;
@ -103,6 +108,7 @@ public class PickAndThrow : Script
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming) if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
{ {
pc.isAiming = false; pc.isAiming = false;
pc.cam.FOV = defaultFOV;
pc.camArm.TargetOffset = Vector3.Zero; pc.camArm.TargetOffset = Vector3.Zero;
if (tpc) if (tpc)
pc.camArm.ArmLength = tpc.armLength; pc.camArm.ArmLength = tpc.armLength;
@ -132,7 +138,7 @@ public class PickAndThrow : Script
{ {
if (itemScript) 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) if (itemScript.currCategory == ItemCategory.LIGHT)
itemRidigBody.AddForce(vec * 0.2f); itemRidigBody.AddForce(vec * 0.2f);
if (itemScript.currCategory == ItemCategory.MEDIUM) if (itemScript.currCategory == ItemCategory.MEDIUM)
@ -254,5 +260,10 @@ public class PickAndThrow : Script
return false; return false;
} }
private float GetPitchRatioRange()
{
return (pc.camArm.Pitch - tpc.pitchUpperClamp) / (tpc.pitchLowerClamp - tpc.pitchUpperClamp);
}
} }

View File

@ -14,10 +14,10 @@ namespace SHADE_Scripting
public float armLength = 2.0f; public float armLength = 2.0f;
public float turnSpeedPitch = 0.3f; public float turnSpeedPitch = 0.3f;
public float turnSpeedYaw = 0.5f; public float turnSpeedYaw = 0.5f;
public float pitchClamp = 45.0f;
public bool inverseXControls = false; public bool inverseXControls = false;
public bool inverseYControls = false; public bool inverseYControls = false;
public float lowerClamp = 5.0f; public float pitchUpperClamp = 45.0f;
public float pitchLowerClamp = 5.0f;
protected override void awake() protected override void awake()
{ {
@ -51,17 +51,17 @@ namespace SHADE_Scripting
arm.Pitch += vel.y * turnSpeedPitch * Time.DeltaTimeF; arm.Pitch += vel.y * turnSpeedPitch * Time.DeltaTimeF;
if (inverseXControls) if (inverseXControls)
arm.Yaw -= vel.x * turnSpeedYaw * Time.DeltaTimeF;
else
arm.Yaw += vel.x * turnSpeedYaw * Time.DeltaTimeF; 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;
} }
} }
} }

View File

@ -26,6 +26,7 @@ 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;
@ -38,6 +39,9 @@ public class GameManager : Script
private Vector3 fontScalar; private Vector3 fontScalar;
public static GameManager Instance { get; private set; } 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() protected override void start()
{ {
@ -76,6 +80,7 @@ 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");
@ -83,7 +88,26 @@ public class GameManager : Script
protected override void update() protected override void update()
{ {
Cheats(); if (GamePause)
{
if (Input.GetKeyDown(Input.KeyCode.Escape) && GamePause)
{
GamePause = false;
AudioHandler.pauseAllSounds(false);
gamePauseText.GetComponent<TextRenderable>().Enabled = false;
}
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;

View File

@ -13,6 +13,7 @@
#include "Math/Transform/SHTransformComponent.h" #include "Math/Transform/SHTransformComponent.h"
#include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h" #include "Graphics/MiddleEnd/GlobalData/SHGlobalDescriptorSets.h"
#include "Graphics/MiddleEnd/Interface/SHRenderer.h" #include "Graphics/MiddleEnd/Interface/SHRenderer.h"
#include "Scene/SHSceneManager.h"
namespace SHADE namespace SHADE
{ {
@ -184,6 +185,9 @@ namespace SHADE
for (auto& comp : textRendererComps) for (auto& comp : textRendererComps)
{ {
if (!SHSceneManager::CheckNodeAndComponentsActive<SHTextRenderableComponent>(comp.GetEID()))
continue;
auto* transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID()); auto* transform = SHComponentManager::GetComponent<SHTransformComponent>(comp.GetEID());
Handle<SHFont> fontHandle = comp.fontHandle; Handle<SHFont> fontHandle = comp.fontHandle;

View File

@ -70,6 +70,7 @@ namespace SHADE
//Compile component IDs //Compile component IDs
const auto componentIDList = SHSerialization::GetComponentIDList(node[ComponentsNode]); const auto componentIDList = SHSerialization::GetComponentIDList(node[ComponentsNode]);
eid = SHEntityManager::CreateEntity(componentIDList, eid, name, parentEID); eid = SHEntityManager::CreateEntity(componentIDList, eid, name, parentEID);
createdEntities[oldEID] = eid; createdEntities[oldEID] = eid;
//createdEntities.push_back(eid); //createdEntities.push_back(eid);
if (node[NumberOfChildrenNode]) if (node[NumberOfChildrenNode])
@ -90,6 +91,12 @@ namespace SHADE
if (node[ScriptsNode]) if (node[ScriptsNode])
SHSystemManager::GetSystem<SHScriptEngine>()->DeserialiseScripts(eid, node[ScriptsNode]); SHSystemManager::GetSystem<SHScriptEngine>()->DeserialiseScripts(eid, node[ScriptsNode]);
auto& sceneGraph = SHSceneManager::GetCurrentSceneGraph();
if (node[IsActiveNode])
{
sceneGraph.SetActive(eid, node[IsActiveNode].as<bool>());
}
return eid; return eid;
} }