diff --git a/TempScriptsFolder/Item.cs b/TempScriptsFolder/SC_Item.cs similarity index 91% rename from TempScriptsFolder/Item.cs rename to TempScriptsFolder/SC_Item.cs index 96ec092d..4ad197b0 100644 --- a/TempScriptsFolder/Item.cs +++ b/TempScriptsFolder/SC_Item.cs @@ -8,6 +8,7 @@ public class Item : Script MEDIUM, HEAVY } + public int Score = 1; public ItemCategory currCategory; public Item(GameObject gameObj) : base(gameObj) { } diff --git a/TempScriptsFolder/PickAndThrow.cs b/TempScriptsFolder/SC_PickAndThrow.cs similarity index 82% rename from TempScriptsFolder/PickAndThrow.cs rename to TempScriptsFolder/SC_PickAndThrow.cs index ea814b36..34e7cd04 100644 --- a/TempScriptsFolder/PickAndThrow.cs +++ b/TempScriptsFolder/SC_PickAndThrow.cs @@ -4,6 +4,7 @@ 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; private PlayerController pc; @@ -23,7 +24,7 @@ public class PickAndThrow : Script if (raccoonHoldLocation == null) Debug.Log("CHILD EMPTY"); else - raccoonHoldLocation.LocalPosition = new Vector3(0.0f, 1.0f, 0.0f); + raccoonHoldLocation.LocalPosition = holdPosition; } protected override void update() { @@ -38,21 +39,12 @@ public class PickAndThrow : Script lastZDir = camerAixs.z; } - if (item.GetScript() != null && itemTransform == null && itemRidibody == null) - { - itemTransform = item.GetComponent(); - if (itemTransform == null) - Debug.Log("Item transform EMPTY"); + RetrieveItemComponets(); - itemRidibody = item.GetComponent(); - if (itemRidibody == null) - Debug.Log("Item rb EMPTY"); - } - - if (pc != null && inRange && !pc.holdItem && Input.GetKey(Input.KeyCode.E)) + if (pc != null && inRange && !pc.holdItem && Input.GetMouseButtonDown(Input.MouseCode.LeftButton)) pc.holdItem = true; - if (pc != null && itemRidibody != null && itemTransform != null && pc.holdItem) + if (pc != null && pc.holdItem && itemRidibody != null && itemTransform != null) { itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition; itemRidibody.IsGravityEnabled = false; @@ -71,6 +63,30 @@ public class PickAndThrow : Script else if(!pc.holdItem && itemRidibody != null) itemRidibody.IsGravityEnabled = true; } + + private void ResetItemObject() + { + itemRidibody = null; + itemTransform = null; + item = new GameObject(); + } + + private void RetrieveItemComponets() + { + //get the transform of the given item + if (item.GetScript() != null && 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"); + } + } + + protected override void onCollisionEnter(CollisionInfo info) { } diff --git a/TempScriptsFolder/PlayerController.cs b/TempScriptsFolder/SC_PlayerController.cs similarity index 98% rename from TempScriptsFolder/PlayerController.cs rename to TempScriptsFolder/SC_PlayerController.cs index 86ba7c98..6b5e38d7 100644 --- a/TempScriptsFolder/PlayerController.cs +++ b/TempScriptsFolder/SC_PlayerController.cs @@ -1,5 +1,6 @@ using SHADE; using System; +using System.Collections.Generic; using static Item; public class PlayerController : Script @@ -11,10 +12,20 @@ public class PlayerController : Script RUNNING, JUMP, FALLING, + LANDED, CAUGHT, TOTAL } + public enum WalkingState + { + CARRY, + AIMING, + THROW, + WALK, + TOTAL + } + public RigidBody rb { get; set; } private Transform tranform; private Camera cam; @@ -215,6 +226,7 @@ public class PlayerController : Script { if (rb != null) { + rb.AddForce(new Vector3(axisMove.x, 0.0f,axisMove.y) * moveForce); if (isMoveKeyPress) diff --git a/TempScriptsFolder/UT_BaseSate.cs b/TempScriptsFolder/UT_BaseSate.cs new file mode 100644 index 00000000..a2842eee --- /dev/null +++ b/TempScriptsFolder/UT_BaseSate.cs @@ -0,0 +1,63 @@ +using SHADE; +using System; + +public abstract class BaseState +{ + + protected string stateName = "Base State"; + protected StateMachine machine; + protected string animationName = ""; + + public BaseState(StateMachine stateMachine, string animName) + { + machine = stateMachine; + animationName = animName; + } + + public virtual void OnEnter() + { + + } + + public abstract void Update(float dt); + + public virtual void OnExit() + { + + } + + public string GetStateName() + { + return stateName; + } + + public string GetAnimName() + { + return animationName; + } + + public virtual float GetAnimPercent() + { + return 1.0f; + } + + public virtual void onCollisionEnter(CollisionInfo other) + { + } + + public virtual void onCollisionStay(CollisionInfo other) + { + } + public virtual void onCollisionExit(CollisionInfo info) + { + } + public virtual void onTriggerEnter(CollisionInfo info) + { + } + public virtual void onTriggerStay(CollisionInfo info) + { + } + public virtual void onTriggerExit(CollisionInfo info) + { + } +} diff --git a/TempScriptsFolder/UT_StateMachine.cs b/TempScriptsFolder/UT_StateMachine.cs new file mode 100644 index 00000000..393c6a45 --- /dev/null +++ b/TempScriptsFolder/UT_StateMachine.cs @@ -0,0 +1,15 @@ +using SHADE; +using System; +using System.Collections.Generic; + +public abstract class StateMachine : Script +{ + private Dictionary stateDictionary; + public BaseState currentState = null; + public string currentStateName; + public string currentAnimName; + + public StateMachine(GameObject gameObj) : base(gameObj) { } + +} +