From 875657cfde0e5a40b73a67ed0a71922a6f6a94f5 Mon Sep 17 00:00:00 2001 From: Glence Date: Sun, 20 Nov 2022 16:27:39 +0800 Subject: [PATCH] added playerstate scripts added sub folders for player remove unneeded scripts --- Assets/Scenes/PlayerControllerTest.shade | 81 +++++++------ Assets/Scripts/CameraFix.cs | 23 ---- Assets/Scripts/CameraFix.cs.shmeta | 3 - .../{ => Gameplay/Player}/SC_PickAndThrow.cs | 70 +++++++----- .../Player}/SC_PickAndThrow.cs.shmeta | 0 .../Player}/SC_PlayerController.cs | 108 +++--------------- .../Player}/SC_PlayerController.cs.shmeta | 0 .../Player}/ThirdPersonCamera.cs | 0 .../Player}/ThirdPersonCamera.cs.shmeta | 0 .../Gameplay/Player/UT_PlayerCaughtState .cs | 31 +++++ .../Player/UT_PlayerCaughtState .cs.shmeta | 3 + .../Gameplay/Player/UT_PlayerFallState.cs | 31 +++++ .../Player/UT_PlayerFallState.cs.shmeta | 3 + .../Gameplay/Player/UT_PlayerIdleState.cs | 31 +++++ .../Player/UT_PlayerIdleState.cs.shmeta | 3 + .../Gameplay/Player/UT_PlayerJumpState.cs | 31 +++++ .../Player/UT_PlayerJumpState.cs.shmeta | 3 + .../Gameplay/Player/UT_PlayerLandState.cs | 31 +++++ .../Player/UT_PlayerLandState.cs.shmeta | 3 + .../Gameplay/Player/UT_PlayerRunState.cs | 31 +++++ .../Player/UT_PlayerRunState.cs.shmeta | 3 + .../Gameplay/Player/UT_PlayerWalkState.cs | 31 +++++ .../Player/UT_PlayerWalkState.cs.shmeta | 3 + .../Scripts/{ => Gameplay}/SC_GameManager.cs | 25 ++-- .../{ => Gameplay}/SC_GameManager.cs.shmeta | 0 Assets/Scripts/{ => Gameplay}/SC_Item.cs | 8 ++ .../Scripts/{ => Gameplay}/SC_Item.cs.shmeta | 0 .../Scripts/{ => Gameplay}/SC_ScoringZone.cs | 0 .../{ => Gameplay}/SC_ScoringZone.cs.shmeta | 0 Assets/Scripts/Item.cs.shmeta | 3 - Assets/Scripts/PhysicsTest.cs | 71 ------------ Assets/Scripts/PickAndThrow.cs.shmeta | 3 - Assets/Scripts/PlayerController.cs.shmeta | 3 - Assets/Scripts/SC_SoundsBoard.cs | 74 ++++++++++++ Assets/Scripts/SC_SoundsBoard.cs.shmeta | 3 + Assets/Scripts/{ => Utility}/UT_BaseSate.cs | 0 .../{ => Utility}/UT_BaseSate.cs.shmeta | 0 .../Scripts/{ => Utility}/UT_StateMachine.cs | 0 .../{ => Utility}/UT_StateMachine.cs.shmeta | 0 39 files changed, 443 insertions(+), 270 deletions(-) delete mode 100644 Assets/Scripts/CameraFix.cs delete mode 100644 Assets/Scripts/CameraFix.cs.shmeta rename Assets/Scripts/{ => Gameplay/Player}/SC_PickAndThrow.cs (63%) rename Assets/Scripts/{ => Gameplay/Player}/SC_PickAndThrow.cs.shmeta (100%) rename Assets/Scripts/{ => Gameplay/Player}/SC_PlayerController.cs (80%) rename Assets/Scripts/{ => Gameplay/Player}/SC_PlayerController.cs.shmeta (100%) rename Assets/Scripts/{ => Gameplay/Player}/ThirdPersonCamera.cs (100%) rename Assets/Scripts/{ => Gameplay/Player}/ThirdPersonCamera.cs.shmeta (100%) create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs.shmeta create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs.shmeta create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs.shmeta create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs.shmeta create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs.shmeta create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs.shmeta create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs create mode 100644 Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs.shmeta rename Assets/Scripts/{ => Gameplay}/SC_GameManager.cs (64%) rename Assets/Scripts/{ => Gameplay}/SC_GameManager.cs.shmeta (100%) rename Assets/Scripts/{ => Gameplay}/SC_Item.cs (61%) rename Assets/Scripts/{ => Gameplay}/SC_Item.cs.shmeta (100%) rename Assets/Scripts/{ => Gameplay}/SC_ScoringZone.cs (100%) rename Assets/Scripts/{ => Gameplay}/SC_ScoringZone.cs.shmeta (100%) delete mode 100644 Assets/Scripts/Item.cs.shmeta delete mode 100644 Assets/Scripts/PhysicsTest.cs delete mode 100644 Assets/Scripts/PickAndThrow.cs.shmeta delete mode 100644 Assets/Scripts/PlayerController.cs.shmeta create mode 100644 Assets/Scripts/SC_SoundsBoard.cs create mode 100644 Assets/Scripts/SC_SoundsBoard.cs.shmeta rename Assets/Scripts/{ => Utility}/UT_BaseSate.cs (100%) rename Assets/Scripts/{ => Utility}/UT_BaseSate.cs.shmeta (100%) rename Assets/Scripts/{ => Utility}/UT_StateMachine.cs (100%) rename Assets/Scripts/{ => Utility}/UT_StateMachine.cs.shmeta (100%) diff --git a/Assets/Scenes/PlayerControllerTest.shade b/Assets/Scenes/PlayerControllerTest.shade index 01039622..203bbfeb 100644 --- a/Assets/Scenes/PlayerControllerTest.shade +++ b/Assets/Scenes/PlayerControllerTest.shade @@ -44,6 +44,7 @@ Angular Drag: 0.00999999978 Use Gravity: true Interpolate: true + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false @@ -68,7 +69,7 @@ NumberOfChildren: 3 Components: Transform Component: - Translate: {x: -18.9007454, y: -3.67369723, z: -5.23871422} + Translate: {x: -21.4454765, y: -3.67383885, z: -3.43293667} Rotate: {x: -0, y: 0, z: 0} Scale: {x: 2, y: 2, z: 2} IsActive: true @@ -83,6 +84,7 @@ Angular Drag: 0 Use Gravity: false Interpolate: false + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false @@ -114,16 +116,15 @@ mediumMultiper: 0.5 heavyMultiper: 0.25 - Type: PickAndThrow - holdPosition: [0, 1.20000005, 0] throwForce: [200, 300, 200] - EID: 3 - Name: Default + Name: HoldingPoint IsActive: true NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 1.20000005, z: 0} - Rotate: {x: -0, y: 0, z: -0} + Translate: {x: 0, y: 1.20000005, z: 0.5} + Rotate: {x: 0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} IsActive: true Scripts: ~ @@ -134,13 +135,13 @@ Components: Transform Component: Translate: {x: 0, y: 0, z: 0} - Rotate: {x: -0.785401046, y: 1.65799224, z: 0} + Rotate: {x: -0.607372105, y: 4.78226185, z: 0} Scale: {x: 1, y: 1, z: 1} IsActive: true Camera Component: - Position: {x: -18.9007454, y: -3.67369723, z: -5.23871422} - Pitch: -45.000164 - Yaw: 94.9959564 + Position: {x: -21.4454765, y: -3.67383885, z: -3.43293667} + Pitch: -34.7998581 + Yaw: 274.003418 Roll: 0 Width: 1920 Height: 1080 @@ -190,6 +191,7 @@ Angular Drag: 0 Use Gravity: true Interpolate: false + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false @@ -254,6 +256,7 @@ Angular Drag: 0.00999999978 Use Gravity: true Interpolate: true + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false @@ -267,11 +270,11 @@ Scripts: - Type: GameManager itemPool: 12 - zonePool: 51000 - currGameState: 0 - totalItemCount: -202 - Score: 204 - timer: 0 + zonePool: 15 + currGameState: 3 + totalItemCount: 2 + Score: 0 + timer: 4.00741768 - EID: 12 Name: ItemPool IsActive: true @@ -284,8 +287,8 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 3.19870043, y: -3.67369723, z: -5} - Rotate: {x: -0, y: 0, z: 0} + Translate: {x: 3.19867921, y: -3.66373587, z: -4.99996376} + Rotate: {x: -9.79829474e-06, y: 1.93362598e-06, z: 2.07606699e-05} Scale: {x: 2, y: 2, z: 2} IsActive: true Renderable Component: @@ -299,12 +302,13 @@ Angular Drag: 0 Use Gravity: true Interpolate: false + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false - Freeze Rotation X: true - Freeze Rotation Y: true - Freeze Rotation Z: true + Freeze Rotation X: false + Freeze Rotation Y: false + Freeze Rotation Z: false IsActive: true Collider Component: Colliders: @@ -333,45 +337,46 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: -20.6163979, y: -0.0419634879, z: -5.08873653} - Rotate: {x: -0, y: 0, z: 0} + Translate: {x: -21.4424801, y: -1.21456838, z: -1.82083583} + Rotate: {x: -0, y: 0, z: -0} Scale: {x: 2, y: 2, z: 2} - IsActive: false + IsActive: true Renderable Component: Mesh: 144838771 Material: 123745521 - IsActive: false + IsActive: true RigidBody Component: Type: Dynamic Mass: 1 - Drag: 0 - Angular Drag: 0 + Drag: 5 + Angular Drag: 1 Use Gravity: true Interpolate: false + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false - Freeze Rotation X: true - Freeze Rotation Y: true - Freeze Rotation Z: true - IsActive: false + Freeze Rotation X: false + Freeze Rotation Y: false + Freeze Rotation Z: false + IsActive: true Collider Component: Colliders: - Is Trigger: false Type: Box - Half Extents: {x: 1, y: 1, z: 1} + Half Extents: {x: 0.5, y: 0.5, z: 0.5} Friction: 0.400000006 Bounciness: 0 Density: 1 Position Offset: {x: 0, y: 0.5, z: 0} - Is Trigger: true Type: Box - Half Extents: {x: 2, y: 2, z: 2} + Half Extents: {x: 1, y: 1, z: 1} Friction: 0.400000006 Bounciness: 0 Density: 1 Position Offset: {x: 0, y: 0.5, z: 0} - IsActive: false + IsActive: true Scripts: - Type: Item Score: 1 @@ -388,8 +393,8 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: -24.5947151, y: -3.15127993, z: -3.29243231} - Rotate: {x: 0, y: 0, z: 0} + Translate: {x: -24.4654179, y: -3.15127993, z: -3.29243231} + Rotate: {x: -0, y: 0, z: -0} Scale: {x: 1, y: 1, z: 1} IsActive: true RigidBody Component: @@ -399,6 +404,7 @@ Angular Drag: 0.00999999978 Use Gravity: true Interpolate: true + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false @@ -416,7 +422,8 @@ Density: 1 Position Offset: {x: 0, y: 0, z: 0} IsActive: true - Scripts: ~ + Scripts: + - Type: ScoringZone - EID: 14 Name: ScoreZone IsActive: true @@ -434,6 +441,7 @@ Angular Drag: 0.00999999978 Use Gravity: true Interpolate: true + Sleeping Enabled: true Freeze Position X: false Freeze Position Y: false Freeze Position Z: false @@ -451,4 +459,5 @@ Density: 1 Position Offset: {x: 0, y: 0, z: 0} IsActive: true - Scripts: ~ \ No newline at end of file + Scripts: + - Type: ScoringZone \ No newline at end of file diff --git a/Assets/Scripts/CameraFix.cs b/Assets/Scripts/CameraFix.cs deleted file mode 100644 index 0ca085ad..00000000 --- a/Assets/Scripts/CameraFix.cs +++ /dev/null @@ -1,23 +0,0 @@ -using SHADE; -using System; - -public class CameraFix : Script -{ - - private Transform tranform; - public Vector3 pos = Vector3.Zero; - public Vector3 rot = Vector3.Zero; - protected override void awake() - { - tranform = GetComponent(); - if (tranform == null) - Debug.LogError("tranform is NULL!"); - else - { - tranform.LocalPosition = pos; - tranform.LocalEulerAngles = rot; - } - - - } -} diff --git a/Assets/Scripts/CameraFix.cs.shmeta b/Assets/Scripts/CameraFix.cs.shmeta deleted file mode 100644 index d1e5412a..00000000 --- a/Assets/Scripts/CameraFix.cs.shmeta +++ /dev/null @@ -1,3 +0,0 @@ -Name: CameraFix -ID: 162231964 -Type: 9 diff --git a/Assets/Scripts/SC_PickAndThrow.cs b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs similarity index 63% rename from Assets/Scripts/SC_PickAndThrow.cs rename to Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs index 15edd302..1ffeaef7 100644 --- a/Assets/Scripts/SC_PickAndThrow.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs @@ -4,7 +4,6 @@ using static PlayerController; public class PickAndThrow : Script { - public Vector3 holdPosition = new Vector3(0.0f, 1.0f, 0.0f); public Vector3 throwForce = new Vector3(100.0f, 200.0f, 100.0f); public GameObject item { get; set; } private PlayerController pc; @@ -22,34 +21,40 @@ public class PickAndThrow : Script raccoonHoldLocation = GetComponentInChildren(); if (raccoonHoldLocation == null) Debug.Log("CHILD EMPTY"); - else - raccoonHoldLocation.LocalPosition = holdPosition; } protected override void update() { CalculateDir(); - if (pc != null && pc.holdItem && itemRidibody != null && itemTransform != null) + if (pc && itemRidibody && itemTransform) { - itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition; - itemRidibody.IsGravityEnabled = false; - itemRidibody.LinearVelocity = Vector3.Zero; - itemRidibody.AngularVelocity = Vector3.Zero; - - if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton)) + if (pc.holdItem) { - pc.holdItem = false; - inRange = false; - itemRidibody.IsGravityEnabled = true; - itemRidibody.AddForce(new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir)); - itemRidibody.LinearVelocity += pc.rb.LinearVelocity; - ResetItemObject(); - } - } - else if(!pc.holdItem && itemRidibody != null) - itemRidibody.IsGravityEnabled = true; + itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition; - if (pc != null && !pc.holdItem && inRange && Input.GetMouseButtonDown(Input.MouseCode.LeftButton)) + if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton)) + { + pc.holdItem = false; + inRange = false; + itemRidibody.IsGravityEnabled = true; + itemRidibody.AddForce(new Vector3(throwForce.x * lastXDir, throwForce.y, throwForce.z * lastZDir)); + itemRidibody.LinearVelocity += pc.rb.LinearVelocity; + ResetItemObject(); + } + + if (Input.GetMouseButtonDown(Input.MouseCode.RightButton)) + { + pc.holdItem = false; + inRange = false; + itemRidibody.IsGravityEnabled = true; + ResetItemObject(); + } + } + else if (!pc.holdItem) + itemRidibody.IsGravityEnabled = true; + } + + if (pc && !pc.holdItem && inRange && Input.GetMouseButtonDown(Input.MouseCode.LeftButton)) { pc.holdItem = true; RetrieveItemComponets(); @@ -66,15 +71,26 @@ public class PickAndThrow : Script private void RetrieveItemComponets() { //get the transform of the given item - if (item.GetScript() != null && itemTransform == null && itemRidibody == null) + if (item.GetScript() && itemTransform == null && itemRidibody == null) { - itemTransform = item.GetComponent(); - if (itemTransform == null) - Debug.Log("Item transform EMPTY"); - itemRidibody = item.GetComponent(); if (itemRidibody == null) Debug.Log("Item rb EMPTY"); + else + { + itemRidibody.IsGravityEnabled = false; + itemRidibody.LinearVelocity = Vector3.Zero; + itemRidibody.AngularVelocity = Vector3.Zero; + } + + itemTransform = item.GetComponent(); + if (itemTransform == null) + Debug.Log("Item transform EMPTY"); + else + { + itemTransform.LocalEulerAngles = Vector3.Zero; + } + } } @@ -82,7 +98,7 @@ public class PickAndThrow : Script { if (cam == null) cam = GetComponentInChildren(); - else if (cam != null) + else if (cam) { Vector3 camerAixs = cam.GetForward(); camerAixs.y = 0; diff --git a/Assets/Scripts/SC_PickAndThrow.cs.shmeta b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs.shmeta similarity index 100% rename from Assets/Scripts/SC_PickAndThrow.cs.shmeta rename to Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs.shmeta diff --git a/Assets/Scripts/SC_PlayerController.cs b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs similarity index 80% rename from Assets/Scripts/SC_PlayerController.cs rename to Assets/Scripts/Gameplay/Player/SC_PlayerController.cs index 189622ac..5afbc18f 100644 --- a/Assets/Scripts/SC_PlayerController.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs @@ -81,7 +81,6 @@ public class PlayerController : Script protected override void awake() { - Audio.PlayBGMOnce2D("event:/Music/player_undetected"); //default setup isMoveKeyPress = false; holdItem = false; @@ -113,9 +112,13 @@ public class PlayerController : Script stateMachine = AddScript(); Dictionary dictionary = new Dictionary(); - dictionary.Add(typeof(IdleState), new IdleState(stateMachine)); - dictionary.Add(typeof(WalkState), new WalkState(stateMachine)); - dictionary.Add(typeof(RunState), new RunState(stateMachine)); + dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine)); + dictionary.Add(typeof(PlayerWalkState), new PlayerWalkState(stateMachine)); + dictionary.Add(typeof(PlayerRunState), new PlayerRunState(stateMachine)); + dictionary.Add(typeof(PlayerJumpState), new PlayerJumpState(stateMachine)); + dictionary.Add(typeof(PlayerFallState), new PlayerFallState(stateMachine)); + dictionary.Add(typeof(PlayerLandState), new PlayerLandState(stateMachine)); + dictionary.Add(typeof(PlayerCaughtState), new PlayerCaughtState(stateMachine)); stateMachine.InitStateMachine(dictionary); } @@ -188,16 +191,16 @@ public class PlayerController : Script { currentState = RaccoonStates.WALKING; - if(stateMachine && !stateMachine.IsState(typeof(WalkState))) - stateMachine.SetState(typeof(WalkState)); + if(stateMachine && !stateMachine.IsState(typeof(PlayerWalkState))) + stateMachine.SetState(typeof(PlayerWalkState)); } if (!isMoveKeyPress && isGrounded) { currentState = RaccoonStates.IDLE; - if(stateMachine && !stateMachine.IsState(typeof(IdleState))) - stateMachine.SetState(typeof(IdleState)); + if(stateMachine && !stateMachine.IsState(typeof(PlayerIdleState))) + stateMachine.SetState(typeof(PlayerIdleState)); } } @@ -230,8 +233,8 @@ public class PlayerController : Script if (Input.GetKey(Input.KeyCode.LeftShift) && isMoveKeyPress && isGrounded) { currentState = RaccoonStates.RUNNING; - if (stateMachine && !stateMachine.IsState(typeof(RunState))) - stateMachine.SetState(typeof(RunState)); + if (stateMachine && !stateMachine.IsState(typeof(PlayerRunState))) + stateMachine.SetState(typeof(PlayerRunState)); holdItem = false; if (!sprintIncreaseOnce) @@ -250,8 +253,8 @@ public class PlayerController : Script if (isMoveKeyPress) { currentState = RaccoonStates.WALKING; - if(stateMachine && !stateMachine.IsState(typeof(WalkState))) - stateMachine.SetState(typeof(WalkState)); + if(stateMachine && !stateMachine.IsState(typeof(PlayerWalkState))) + stateMachine.SetState(typeof(PlayerWalkState)); } sprintIncreaseOnce = false; moveForce = oldForce; @@ -349,8 +352,8 @@ public class PlayerController : Script if (currentState == RaccoonStates.CAUGHT && tranform != null) { currentState = RaccoonStates.IDLE; - if (stateMachine && !stateMachine.IsState(typeof(IdleState))) - stateMachine.SetState(typeof(IdleState)); + if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState))) + stateMachine.SetState(typeof(PlayerIdleState)); tranform.LocalPosition = new Vector3(-3.0f, -2.0f, -5.0f); } } @@ -361,80 +364,3 @@ public class PlayerController : Script } -public class WalkState : BaseState -{ - public WalkState(StateMachine stateMachine) : base(stateMachine) - { - stateName = "Walk State"; - } - public override void OnEnter() - { - //Debug.Log("WALK ENTER"); - } - public override void update() - { - //Debug.Log("WALKING"); - } - public override void fixedUpdate() - { - //Debug.Log("FIXED WALKING"); - } - public override void OnExit() - { - //Debug.Log("WALK EXIT"); - } - public override void onTriggerEnter(CollisionInfo info) - { - //Debug.Log("TRIGGER"); - } - -} - -public class RunState : BaseState -{ - public RunState(StateMachine stateMachine) : base(stateMachine) - { - stateName = "Run State"; - } - public override void OnEnter() - { - //Debug.Log("Run ENTER"); - } - public override void update() - { - //Debug.Log("RUNING"); - } - public override void fixedUpdate() - { - //Debug.Log("FIXED RUNNING"); - } - public override void OnExit() - { - //Debug.Log("Run EXIT"); - } -} - -public class IdleState : BaseState -{ - public IdleState(StateMachine stateMachine) : base(stateMachine) - { - stateName = "Idle State"; - } - public override void OnEnter() - { - //Debug.Log("IDLE ENTER"); - } - public override void update() - { - //Debug.Log("IDLING"); - } - public override void fixedUpdate() - { - //Debug.Log("FIXED IDLING"); - } - public override void OnExit() - { - //Debug.Log("IDLE EXIT"); - } -} - diff --git a/Assets/Scripts/SC_PlayerController.cs.shmeta b/Assets/Scripts/Gameplay/Player/SC_PlayerController.cs.shmeta similarity index 100% rename from Assets/Scripts/SC_PlayerController.cs.shmeta rename to Assets/Scripts/Gameplay/Player/SC_PlayerController.cs.shmeta diff --git a/Assets/Scripts/ThirdPersonCamera.cs b/Assets/Scripts/Gameplay/Player/ThirdPersonCamera.cs similarity index 100% rename from Assets/Scripts/ThirdPersonCamera.cs rename to Assets/Scripts/Gameplay/Player/ThirdPersonCamera.cs diff --git a/Assets/Scripts/ThirdPersonCamera.cs.shmeta b/Assets/Scripts/Gameplay/Player/ThirdPersonCamera.cs.shmeta similarity index 100% rename from Assets/Scripts/ThirdPersonCamera.cs.shmeta rename to Assets/Scripts/Gameplay/Player/ThirdPersonCamera.cs.shmeta diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs b/Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs new file mode 100644 index 00000000..1f3d4760 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class PlayerCaughtState : BaseState +{ + public PlayerCaughtState(StateMachine stateMachine) : base(stateMachine) + { + stateName = "Caught State"; + } + public override void OnEnter() + { + //Debug.Log("WALK ENTER"); + } + public override void update() + { + //Debug.Log("WALKING"); + } + public override void fixedUpdate() + { + //Debug.Log("FIXED WALKING"); + } + public override void OnExit() + { + //Debug.Log("WALK EXIT"); + } + public override void onTriggerEnter(CollisionInfo info) + { + //Debug.Log("TRIGGER"); + } +} + diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs.shmeta b/Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs.shmeta new file mode 100644 index 00000000..6a7b9648 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerCaughtState .cs.shmeta @@ -0,0 +1,3 @@ +Name: UT_PlayerCaughtState +ID: 152856879 +Type: 9 diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs b/Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs new file mode 100644 index 00000000..806b332d --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class PlayerFallState : BaseState +{ + public PlayerFallState(StateMachine stateMachine) : base(stateMachine) + { + stateName = "Fall State"; + } + public override void OnEnter() + { + //Debug.Log("WALK ENTER"); + } + public override void update() + { + //Debug.Log("WALKING"); + } + public override void fixedUpdate() + { + //Debug.Log("FIXED WALKING"); + } + public override void OnExit() + { + //Debug.Log("WALK EXIT"); + } + public override void onTriggerEnter(CollisionInfo info) + { + //Debug.Log("TRIGGER"); + } +} + diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs.shmeta b/Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs.shmeta new file mode 100644 index 00000000..8de9a555 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerFallState.cs.shmeta @@ -0,0 +1,3 @@ +Name: UT_PlayerFallState +ID: 155635109 +Type: 9 diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs b/Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs new file mode 100644 index 00000000..144233a3 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class PlayerIdleState : BaseState +{ + public PlayerIdleState(StateMachine stateMachine) : base(stateMachine) + { + stateName = "Idle State"; + } + public override void OnEnter() + { + //Debug.Log("WALK ENTER"); + } + public override void update() + { + //Debug.Log("WALKING"); + } + public override void fixedUpdate() + { + //Debug.Log("FIXED WALKING"); + } + public override void OnExit() + { + //Debug.Log("WALK EXIT"); + } + public override void onTriggerEnter(CollisionInfo info) + { + //Debug.Log("TRIGGER"); + } +} + diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs.shmeta b/Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs.shmeta new file mode 100644 index 00000000..9ea6c4d1 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerIdleState.cs.shmeta @@ -0,0 +1,3 @@ +Name: UT_PlayerIdleState +ID: 167587808 +Type: 9 diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs b/Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs new file mode 100644 index 00000000..1adfdf67 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class PlayerJumpState : BaseState +{ + public PlayerJumpState(StateMachine stateMachine) : base(stateMachine) + { + stateName = "Jump State"; + } + public override void OnEnter() + { + //Debug.Log("WALK ENTER"); + } + public override void update() + { + //Debug.Log("WALKING"); + } + public override void fixedUpdate() + { + //Debug.Log("FIXED WALKING"); + } + public override void OnExit() + { + //Debug.Log("WALK EXIT"); + } + public override void onTriggerEnter(CollisionInfo info) + { + //Debug.Log("TRIGGER"); + } +} + diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs.shmeta b/Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs.shmeta new file mode 100644 index 00000000..0c918232 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerJumpState.cs.shmeta @@ -0,0 +1,3 @@ +Name: UT_PlayerJumpState +ID: 158874227 +Type: 9 diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs b/Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs new file mode 100644 index 00000000..518bab4c --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class PlayerLandState : BaseState +{ + public PlayerLandState(StateMachine stateMachine) : base(stateMachine) + { + stateName = "Land State"; + } + public override void OnEnter() + { + //Debug.Log("WALK ENTER"); + } + public override void update() + { + //Debug.Log("WALKING"); + } + public override void fixedUpdate() + { + //Debug.Log("FIXED WALKING"); + } + public override void OnExit() + { + //Debug.Log("WALK EXIT"); + } + public override void onTriggerEnter(CollisionInfo info) + { + //Debug.Log("TRIGGER"); + } +} + diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs.shmeta b/Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs.shmeta new file mode 100644 index 00000000..ed3d4020 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerLandState.cs.shmeta @@ -0,0 +1,3 @@ +Name: UT_PlayerLandState +ID: 151865541 +Type: 9 diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs b/Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs new file mode 100644 index 00000000..aae467b3 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class PlayerRunState : BaseState +{ + public PlayerRunState(StateMachine stateMachine) : base(stateMachine) + { + stateName = "Walk State"; + } + public override void OnEnter() + { + //Debug.Log("WALK ENTER"); + } + public override void update() + { + //Debug.Log("WALKING"); + } + public override void fixedUpdate() + { + //Debug.Log("FIXED WALKING"); + } + public override void OnExit() + { + //Debug.Log("WALK EXIT"); + } + public override void onTriggerEnter(CollisionInfo info) + { + //Debug.Log("TRIGGER"); + } +} + diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs.shmeta b/Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs.shmeta new file mode 100644 index 00000000..c41112f3 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerRunState.cs.shmeta @@ -0,0 +1,3 @@ +Name: UT_PlayerRunState +ID: 153407272 +Type: 9 diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs b/Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs new file mode 100644 index 00000000..d299381c --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class PlayerWalkState : BaseState +{ + public PlayerWalkState(StateMachine stateMachine) : base(stateMachine) + { + stateName = "Walk State"; + } + public override void OnEnter() + { + //Debug.Log("WALK ENTER"); + } + public override void update() + { + //Debug.Log("WALKING"); + } + public override void fixedUpdate() + { + //Debug.Log("FIXED WALKING"); + } + public override void OnExit() + { + //Debug.Log("WALK EXIT"); + } + public override void onTriggerEnter(CollisionInfo info) + { + //Debug.Log("TRIGGER"); + } +} + diff --git a/Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs.shmeta b/Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs.shmeta new file mode 100644 index 00000000..a09dee13 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player/UT_PlayerWalkState.cs.shmeta @@ -0,0 +1,3 @@ +Name: UT_PlayerWalkState +ID: 166650679 +Type: 9 diff --git a/Assets/Scripts/SC_GameManager.cs b/Assets/Scripts/Gameplay/SC_GameManager.cs similarity index 64% rename from Assets/Scripts/SC_GameManager.cs rename to Assets/Scripts/Gameplay/SC_GameManager.cs index 743827ed..98d2ca23 100644 --- a/Assets/Scripts/SC_GameManager.cs +++ b/Assets/Scripts/Gameplay/SC_GameManager.cs @@ -7,6 +7,7 @@ public class GameManager : Script public enum GameState { MAINMENU, + START, WIN, LOSE, TOTAL @@ -35,28 +36,32 @@ public class GameManager : Script if (itemPool) { listOfItems = itemPool.GetScriptsInChildren(); - foreach (Item i in listOfItems) - totalItemCount += 1; + if (listOfItems != null) + foreach (Item i in listOfItems) + totalItemCount += 1; } if (zonePool) { - listOfZone = itemPool.GetScriptsInChildren(); - foreach (ScoringZone i in listOfZone) - i.gameManger = Owner.GetScript(); + listOfZone = zonePool.GetScriptsInChildren(); + if (listOfZone != null) + foreach (ScoringZone sz in listOfZone) + sz.gameManger = Owner.GetScript(); } } protected override void update() { - if (timer > 0) + if (timer > 0 && currGameState == GameState.START) + { timer -= Time.DeltaTimeF; + if (totalItemCount <= 0) + { + currGameState = GameState.WIN; + } + } else currGameState = GameState.LOSE; } - protected override void onTriggerEnter(CollisionInfo info) - { - } - } diff --git a/Assets/Scripts/SC_GameManager.cs.shmeta b/Assets/Scripts/Gameplay/SC_GameManager.cs.shmeta similarity index 100% rename from Assets/Scripts/SC_GameManager.cs.shmeta rename to Assets/Scripts/Gameplay/SC_GameManager.cs.shmeta diff --git a/Assets/Scripts/SC_Item.cs b/Assets/Scripts/Gameplay/SC_Item.cs similarity index 61% rename from Assets/Scripts/SC_Item.cs rename to Assets/Scripts/Gameplay/SC_Item.cs index cb2a5d32..e6cc79af 100644 --- a/Assets/Scripts/SC_Item.cs +++ b/Assets/Scripts/Gameplay/SC_Item.cs @@ -12,9 +12,17 @@ public class Item : Script public int Score = 10; public ItemCategory currCategory; + private RigidBody rb; protected override void awake() { + rb = GetComponent(); + if (rb) + { + rb.FreezeRotationX = false; + rb.FreezeRotationY = false; + rb.FreezeRotationZ = false; + } } protected override void onTriggerEnter(CollisionInfo info) diff --git a/Assets/Scripts/SC_Item.cs.shmeta b/Assets/Scripts/Gameplay/SC_Item.cs.shmeta similarity index 100% rename from Assets/Scripts/SC_Item.cs.shmeta rename to Assets/Scripts/Gameplay/SC_Item.cs.shmeta diff --git a/Assets/Scripts/SC_ScoringZone.cs b/Assets/Scripts/Gameplay/SC_ScoringZone.cs similarity index 100% rename from Assets/Scripts/SC_ScoringZone.cs rename to Assets/Scripts/Gameplay/SC_ScoringZone.cs diff --git a/Assets/Scripts/SC_ScoringZone.cs.shmeta b/Assets/Scripts/Gameplay/SC_ScoringZone.cs.shmeta similarity index 100% rename from Assets/Scripts/SC_ScoringZone.cs.shmeta rename to Assets/Scripts/Gameplay/SC_ScoringZone.cs.shmeta diff --git a/Assets/Scripts/Item.cs.shmeta b/Assets/Scripts/Item.cs.shmeta deleted file mode 100644 index 84830b76..00000000 --- a/Assets/Scripts/Item.cs.shmeta +++ /dev/null @@ -1,3 +0,0 @@ -Name: Item -ID: 163145289 -Type: 9 diff --git a/Assets/Scripts/PhysicsTest.cs b/Assets/Scripts/PhysicsTest.cs deleted file mode 100644 index 9726a51c..00000000 --- a/Assets/Scripts/PhysicsTest.cs +++ /dev/null @@ -1,71 +0,0 @@ -using SHADE; -using System; -public class PhysicsTest : Script -{ - [SerializeField] - [Tooltip("Force to apply when pressing Space.")] - private Vector3 Force = new Vector3(0.0f, 200.0f, 0.0f); - private Transform Transform; - private RigidBody RigidBody; - private Collider Collider; - - protected override void awake() - { - Transform = GetComponent(); - if (Transform == null) - { - Debug.LogError("Transform is NULL!"); - } - RigidBody = GetComponent(); - if (RigidBody == null) - { - Debug.LogError("RigidBody is NULL!"); - } - Collider = GetComponent(); - if (Collider == null) - { - Debug.LogError("Collider is NULL!"); - } - - var subColider = Collider.CollisionShapeCount; - Debug.Log($"There are {subColider} colliders."); - } - protected override void update() - { - if (Input.GetKeyUp(Input.KeyCode.Space)) - { - RigidBody.AddForce(Force); - Debug.Log($"Jump!"); - } - } - - protected override void fixedUpdate() - { - Debug.Log("Fixed Update"); - } - - protected override void onCollisionEnter(CollisionInfo info) - { - Debug.Log($"Collision Enter: {info.GameObject.Name}"); - } - protected override void onCollisionStay(CollisionInfo info) - { - Debug.Log($"Collision Stay: {info.GameObject.Name}"); - } - protected override void onCollisionExit(CollisionInfo info) - { - Debug.Log($"Collision Exit: {info.GameObject.Name}"); - } - protected override void onTriggerEnter(CollisionInfo info) - { - Debug.Log($"Trigger Enter: {info.GameObject.Name}"); - } - protected override void onTriggerStay(CollisionInfo info) - { - Debug.Log($"Trigger Stay: {info.GameObject.Name}"); - } - protected override void onTriggerExit(CollisionInfo info) - { - Debug.Log($"Trigger Exit: {info.GameObject.Name}"); - } -} \ No newline at end of file diff --git a/Assets/Scripts/PickAndThrow.cs.shmeta b/Assets/Scripts/PickAndThrow.cs.shmeta deleted file mode 100644 index 0eb38f59..00000000 --- a/Assets/Scripts/PickAndThrow.cs.shmeta +++ /dev/null @@ -1,3 +0,0 @@ -Name: PickAndThrow -ID: 165331952 -Type: 9 diff --git a/Assets/Scripts/PlayerController.cs.shmeta b/Assets/Scripts/PlayerController.cs.shmeta deleted file mode 100644 index 8b71915c..00000000 --- a/Assets/Scripts/PlayerController.cs.shmeta +++ /dev/null @@ -1,3 +0,0 @@ -Name: PlayerController -ID: 164563088 -Type: 9 diff --git a/Assets/Scripts/SC_SoundsBoard.cs b/Assets/Scripts/SC_SoundsBoard.cs new file mode 100644 index 00000000..e1f89855 --- /dev/null +++ b/Assets/Scripts/SC_SoundsBoard.cs @@ -0,0 +1,74 @@ +using SHADE; +using System; + + +public class SoundsBoard : Script +{ + protected override void awake() + { + /* + * event:/UI/failure +event:/UI/mouse_down_element +event:/UI/mouse_down_empty +event:/UI/mouse_enter_element +event:/UI/mouse_exit_element +event:/UI/success + +event:/Raccoon/raccoon_footsteps +event:/Raccoon/raccoon_throw + +event:/Props/impact_hard +event:/Props/impact_elastic + + +event:/Music/player_undetected +event:/Music/player_detected + +event:/Music/stingers/player_detected +event:/Music/stingers/item_scored + +event:/Homeowner/homeowner_humming +event:/Homeowner/homeowner_footsteps +event:/Homeowner/homeowner_detect_raccoon + */ + } + protected override void update() + { + if (Input.GetKey(Input.KeyCode.Q)) + Audio.PlayBGMOnce2D("event:/UI/mouse_down_element"); + if (Input.GetKey(Input.KeyCode.W)) + Audio.PlayBGMOnce2D("event:/UI/mouse_down_empty"); + if (Input.GetKey(Input.KeyCode.E)) + Audio.PlayBGMOnce2D("event:/UI/mouse_enter_element"); + if (Input.GetKey(Input.KeyCode.R)) + Audio.PlayBGMOnce2D("event:/UI/mouse_exit_element"); + if (Input.GetKey(Input.KeyCode.T)) + Audio.PlayBGMOnce2D("event:/UI/success"); + if (Input.GetKey(Input.KeyCode.Y)) + Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_throw"); + if (Input.GetKey(Input.KeyCode.U)) + Audio.PlayBGMOnce2D("event:/Props/impact_hard"); + if (Input.GetKey(Input.KeyCode.I)) + Audio.PlayBGMOnce2D("event:/Music/player_undetected"); + if (Input.GetKey(Input.KeyCode.O)) + Audio.PlayBGMOnce2D("event:/Music/player_detected"); + if (Input.GetKey(Input.KeyCode.P)) + Audio.PlayBGMOnce2D("event:/Music/stingers/player_detected"); + if (Input.GetKey(Input.KeyCode.A)) + Audio.PlayBGMOnce2D("event:/Music/stingers/item_scored"); + if (Input.GetKey(Input.KeyCode.S)) + Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_humming"); + if (Input.GetKey(Input.KeyCode.D)) + Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_footsteps"); + if (Input.GetKey(Input.KeyCode.F)) + Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_detect_raccoon"); + if (Input.GetKey(Input.KeyCode.G)) + Audio.PlayBGMOnce2D("event:/Music/player_undetected"); + if (Input.GetKey(Input.KeyCode.H)) + Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_footsteps"); + if (Input.GetKey(Input.KeyCode.J)) + Audio.PlayBGMOnce2D("event:/Props/impact_elastic"); + + } +} + diff --git a/Assets/Scripts/SC_SoundsBoard.cs.shmeta b/Assets/Scripts/SC_SoundsBoard.cs.shmeta new file mode 100644 index 00000000..a953fecf --- /dev/null +++ b/Assets/Scripts/SC_SoundsBoard.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_SoundsBoard +ID: 156397807 +Type: 9 diff --git a/Assets/Scripts/UT_BaseSate.cs b/Assets/Scripts/Utility/UT_BaseSate.cs similarity index 100% rename from Assets/Scripts/UT_BaseSate.cs rename to Assets/Scripts/Utility/UT_BaseSate.cs diff --git a/Assets/Scripts/UT_BaseSate.cs.shmeta b/Assets/Scripts/Utility/UT_BaseSate.cs.shmeta similarity index 100% rename from Assets/Scripts/UT_BaseSate.cs.shmeta rename to Assets/Scripts/Utility/UT_BaseSate.cs.shmeta diff --git a/Assets/Scripts/UT_StateMachine.cs b/Assets/Scripts/Utility/UT_StateMachine.cs similarity index 100% rename from Assets/Scripts/UT_StateMachine.cs rename to Assets/Scripts/Utility/UT_StateMachine.cs diff --git a/Assets/Scripts/UT_StateMachine.cs.shmeta b/Assets/Scripts/Utility/UT_StateMachine.cs.shmeta similarity index 100% rename from Assets/Scripts/UT_StateMachine.cs.shmeta rename to Assets/Scripts/Utility/UT_StateMachine.cs.shmeta