Merge pull request #336 from SHADE-DP/PlayerController

Scene changes and Bug fixes
This commit is contained in:
XiaoQiDigipen 2023-02-03 22:08:18 +08:00 committed by GitHub
commit 0e4400fc98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 2394 additions and 199 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8432,7 +8432,7 @@
- EID: 20
Name: ===== Light =====
IsActive: true
NumberOfChildren: 2
NumberOfChildren: 3
Components: ~
Scripts: ~
- EID: 296
@ -8463,6 +8463,25 @@
Strength: 0.699999988
IsActive: true
Scripts: ~
- EID: 65674
Name: Light_Directional
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 2, y: 1.5, z: -5.5999999}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Light Component:
Position: {x: 2, y: 1.5, z: -5.5999999}
Type: Directional
Direction: {x: 1, y: 0, z: 0}
Color: {x: 0, y: 0, z: 0, w: 1}
Layer: 4294967295
Strength: 1
IsActive: true
Scripts: ~
- EID: 240
Name: ====ItemPool====
IsActive: true
@ -8486,7 +8505,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8533,7 +8552,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8580,7 +8599,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8627,7 +8646,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8674,7 +8693,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8721,7 +8740,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8768,7 +8787,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8815,7 +8834,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8862,7 +8881,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8909,7 +8928,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -8960,7 +8979,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9007,7 +9026,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9054,7 +9073,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9101,7 +9120,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9148,7 +9167,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9195,7 +9214,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9246,7 +9265,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9287,7 +9306,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9328,7 +9347,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9369,7 +9388,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9410,9 +9429,9 @@
Scale: {x: 1, y: 1, z: 1}
IsActive: true
RigidBody Component:
Type: Static
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9449,9 +9468,9 @@
Scale: {x: 1, y: 1, z: 1}
IsActive: true
RigidBody Component:
Type: Static
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9493,10 +9512,14 @@
timer: 200
scoreText: 237
timeText: 206
multiplierText: 139
maxMultiplierDuration: 5
maxMultiplierCombo: 10
multiplierFont: 60
- EID: 199
Name: =====Text====
IsActive: true
NumberOfChildren: 2
NumberOfChildren: 3
Components: ~
Scripts: ~
- EID: 237
@ -9529,6 +9552,21 @@
Font: 176667660
IsActive: true
Scripts: ~
- EID: 139
Name: Multiplier
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: -800, y: 300, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 60, y: 60, z: 60}
IsActive: true
Text Renderer Component:
Text: TEST
Font: 176667660
IsActive: true
Scripts: ~
- EID: 198
Name: ====Raccoon====
IsActive: true
@ -9551,7 +9589,7 @@
IsActive: true
RigidBody Component:
Type: Dynamic
Drag: 1
Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: false
Interpolate: true
@ -9696,7 +9734,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9741,7 +9779,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9782,7 +9820,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9823,7 +9861,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9864,7 +9902,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9905,7 +9943,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9950,7 +9988,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -9991,7 +10029,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10032,7 +10070,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10073,7 +10111,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10114,7 +10152,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10159,7 +10197,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10200,7 +10238,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10241,7 +10279,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10282,7 +10320,7 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: true
Sleeping Enabled: true
@ -10406,9 +10444,9 @@
RigidBody Component:
Type: Dynamic
Drag: 0.00999999978
Angular Drag: 0.00999999978
Angular Drag: 0.100000001
Use Gravity: true
Interpolate: false
Interpolate: true
Sleeping Enabled: true
Freeze Position X: false
Freeze Position Y: false

View File

@ -67,3 +67,4 @@
Scripts:
- Type: MainMenu
Enabled: true
sceneID: 96668835

View File

@ -0,0 +1,19 @@
using System;
using SHADE;
public class FixRotation : Script
{
Transform tran;
protected override void awake()
{
tran = GetComponent<Transform>();
}
protected override void update()
{
if(tran)
tran.LocalEulerAngles = Vector3.Zero;
}
}

View File

@ -0,0 +1,3 @@
Name: FixRotation
ID: 162507316
Type: 9

View File

@ -12,7 +12,6 @@ public class Breakable : Script
private Transform trans;
public bool isBreak { get; set; }
private List<GameObject> itemPieces = new List<GameObject>();
private Random ran = new Random();
protected override void awake()
{
@ -44,7 +43,7 @@ public class Breakable : Script
if (ignoreRaccoon && info.GameObject.GetScript<PlayerController>())
return;
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold)
if (rb.LinearVelocity.GetSqrMagnitude() > threshHold && !info.GameObject.GetScript<PlayerController>())
{
isBreak = true;
if(GameObject.GetScript<Item>())

View File

@ -200,25 +200,36 @@ public class PickAndThrow : Script
{
if (pc != null)
{
Vector3 dirNor = pc.tranform.Forward;
Vector3 playerRayPos = pc.tranform.GlobalPosition;
playerRayPos.y += 0.05f;
dirNor.Normalise();
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
Vector3 dirNor = pc.tranform.Forward;
Vector3 playerRayPos = pc.tranform.GlobalPosition;
playerRayPos.y += 0.05f;
dirNor.Normalise();
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535);
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535);
if (rayList1.Count > 0 && rayList2.Count > 0 && rayList3.Count > 0)
{
RaycastHit ray1 = rayList1[0];
RaycastHit ray2 = rayList2[0];
RaycastHit ray3 = rayList3[0];
inRange = CheckForItem(ray1) || CheckForItem(ray2) || CheckForItem(ray3);
}
else
{
inRange = false;
}
if (rayList1.Count > 0)
{
RaycastHit ray1 = rayList1[0];
inRange = CheckForItem(ray1);
return;
}
else if (rayList2.Count > 0)
{
RaycastHit ray2 = rayList2[0];
inRange = CheckForItem(ray2);
return;
}
else if (rayList3.Count > 0)
{
RaycastHit ray3 = rayList3[0];
inRange = CheckForItem(ray3);
return;
}
else
{
inRange = false;
}
}
}

View File

@ -371,7 +371,7 @@ public class PlayerController : Script
stateMachine.SetState(typeof(PlayerIdleState));
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
if (pat && pat.item.GetScript<Item>())
if (pat && pat.item)
{
holdItem = false;
isAiming = false;

View File

@ -26,6 +26,16 @@ public class GameManager : Script
public GameObject scoreText;
public GameObject timeText;
//mulitpler info
public GameObject multiplierText;
public float maxMultiplierDuration = 5.0f;
public float currMultiplierDuration { get; set; }
public int maxMultiplierCombo = 10;
public bool itemScored {get;set;}
public int currMultiplierCombo { get; set;}
public float multiplierFont = 60.0f;
private Vector3 fontScalar;
public static GameManager Instance { get; private set; }
protected override void awake()
@ -40,12 +50,15 @@ public class GameManager : Script
totalItemCount = 0;
Score = 0;
currGameState = GameState.START;
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
fontScalar = new Vector3(multiplierFont / maxMultiplierDuration, multiplierFont / maxMultiplierDuration , multiplierFont / maxMultiplierDuration);
}
protected override void update()
{
Cheats();
if (currGameState == GameState.START)
{
timer -= Time.DeltaTimeF;
@ -54,6 +67,25 @@ public class GameManager : Script
if(timeText)
timeText.GetComponent<TextRenderable>().Text = $"Time Left: {timer.ToString("0.00")}";
if (itemScored)
{
multiplierText.GetComponent<TextRenderable>().Text = $"X {currMultiplierCombo}";
multiplierText.GetComponent<Transform>().LocalScale -= fontScalar * Time.DeltaTimeF;
currMultiplierDuration += Time.DeltaTimeF;
if (currMultiplierDuration >= maxMultiplierDuration)
{
itemScored = false;
currMultiplierCombo = 1;
currMultiplierDuration = 0;
}
}
else
{
multiplierText.GetComponent<Transform>().LocalScale = Vector3.Zero;
}
if ((timer > 0 && totalItemCount < 0) || Input.GetKeyDown(Input.KeyCode.F1))
{
currGameState = GameState.WIN;
@ -86,4 +118,14 @@ public class GameManager : Script
}
}
public void ItemScored()
{
totalItemCount -= 1;
itemScored = true;
currMultiplierDuration = 0;
multiplierText.GetComponent<Transform>().LocalScale = new Vector3(multiplierFont, multiplierFont, multiplierFont);
if (currMultiplierCombo < maxMultiplierCombo)
currMultiplierCombo += 1;
}
}

View File

@ -12,8 +12,8 @@ public class ScoringZone : Script
if (GameManager.Instance && info.GameObject.GetScript<Item>())
{
Audio.PlaySFXOnce2D("event:/Music/stingers/item_scored");
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score;
GameManager.Instance.totalItemCount -= 1;
GameManager.Instance.ItemScored();
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score * GameManager.Instance.currMultiplierCombo;
info.GameObject.SetActive(false);
}
}

View File

@ -3,6 +3,7 @@ using SHADE;
public class MainMenu : Script
{
public uint sceneID;
protected override void awake()
{
Audio.PlayBGMOnce2D("event:/Music/main_menu");
@ -17,7 +18,7 @@ public class MainMenu : Script
if (Input.GetKeyUp(Input.KeyCode.Space))
{
Audio.PlaySFXOnce2D("event:/UI/success");
SceneManager.ChangeScene(86098106);
SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds();
}

View File

@ -11,6 +11,7 @@ namespace SHADE
{
if (Begin())
{
DrawMenuBar();
ImGui::BeginTable("CollisionMtxTable", SHCollisionTag::NUM_LAYERS + 1, ImGuiTableRowFlags_Headers);
ImGui::TableNextRow();
ImGui::PushID("CollisionTagNames");
@ -56,7 +57,10 @@ namespace SHADE
if(i == idx)
continue;
std::string label = std::format("##{} vs {}", tagName, tagName2);
SHEditorWidgets::CheckBox(label, [tag, &idx]{return tag->GetLayerState(idx);}, [tag, i, idx](bool const& value){tag->SetLayerState(idx, value); SHCollisionTagMatrix::GetTag(idx)->SetLayerState(i, value);}, label.substr(2));
if (SHEditorWidgets::CheckBox(label, [tag, &idx] {return tag->GetLayerState(idx); }, [tag, i, idx](bool const& value) {tag->SetLayerState(idx, value); SHCollisionTagMatrix::GetTag(idx)->SetLayerState(i, value); }, label.substr(2)))
{
isDirty = true;
}
}
}
ImGui::EndTable();
@ -64,4 +68,21 @@ namespace SHADE
ImGui::End();
}
void SHColliderTagPanel::DrawMenuBar()
{
if (ImGui::BeginMenuBar())
{
ImGui::BeginDisabled(!isDirty);
if (ImGui::Button("Save"))
{
std::filesystem::path defaultCollisionTagNameFilePath{ ASSET_ROOT };
defaultCollisionTagNameFilePath.append("CollisionTags.SHConfig");
SHCollisionTagMatrix::Exit(defaultCollisionTagNameFilePath);
isDirty = false;
}
ImGui::EndDisabled();
ImGui::EndMenuBar();
}
}
}

View File

@ -14,6 +14,7 @@ namespace SHADE
//void Exit();
private:
void DrawMenuBar();
bool isDirty;
};
}

View File

@ -94,8 +94,8 @@ namespace SHADE
{
const bool CLEAR_EVENT = C_INFO.GetCollisionState() == SHCollisionInfo::State::EXIT || C_INFO.GetCollisionState() == SHCollisionInfo::State::INVALID;
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
const bool INACTIVE_OBJECT = !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityA())
|| !SHSceneManager::CheckNodeAndHasComponentsActive<SHColliderComponent>(C_INFO.GetEntityB());
if (CLEAR_EVENT || INACTIVE_OBJECT)
{

View File

@ -155,7 +155,7 @@ namespace SHADE
// Load start and end points into the container for debug drawing
#ifdef SHEDITOR
SHVec3 endPos = info.ray.position + info.ray.direction * SHRay::MAX_RAYCAST_DIST;
SHVec3 endPos = info.ray.position + info.ray.direction * std::clamp(info.distance,0.0f, SHRay::MAX_RAYCAST_DIST);
if (!results.empty())
endPos = results.back().position;