bug fixes #455

Merged
glencelow merged 2 commits from PlayerController into main 2023-04-01 19:18:29 +08:00
2 changed files with 19 additions and 3 deletions

View File

@ -22,6 +22,7 @@ public class PlayerController : Script
public Transform tranform { get; set; } public Transform tranform { get; set; }
public Camera cam { get; set; } public Camera cam { get; set; }
public CameraArm camArm { get; set; } public CameraArm camArm { get; set; }
public Collider collider { get; set; }
[NonSerialized] [NonSerialized]
public PickAndThrow pat; public PickAndThrow pat;
@ -124,6 +125,10 @@ public class PlayerController : Script
if(!tranform) if(!tranform)
Debug.LogError("tranform is MISSING!"); Debug.LogError("tranform is MISSING!");
collider = GetComponent<Collider>();
if (!collider)
Debug.LogError("collider is MISSING!");
stateMachine = AddScript<StateMachine>(); stateMachine = AddScript<StateMachine>();
Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>(); Dictionary<Type, BaseState> dictionary = new Dictionary<Type, BaseState>();
dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine)); dictionary.Add(typeof(PlayerIdleState), new PlayerIdleState(stateMachine));
@ -520,7 +525,6 @@ public class PlayerController : Script
public void Caught() public void Caught()
{ {
//Debug.Log("PlayerController: Raccoon Caught");
currentState = RaccoonStates.CAUGHT; currentState = RaccoonStates.CAUGHT;
if (stateMachine && !stateMachine.IsState(typeof(PlayerCaughtState))) if (stateMachine && !stateMachine.IsState(typeof(PlayerCaughtState)))
stateMachine.SetState(typeof(PlayerCaughtState)); stateMachine.SetState(typeof(PlayerCaughtState));
@ -543,12 +547,20 @@ public class PlayerController : Script
camArm.ArmLength = pat.tpc.armLength; camArm.ArmLength = pat.tpc.armLength;
} }
} }
landedOnJumpPad = false;
jumpPadDrop = false;
rb.ClearForces();
rb.ClearTorque();
rb.LinearVelocity = Vector3.Zero;
rb.AngularVelocity = Vector3.Zero;
} }
public void Reset() public void Reset()
{ {
if (tranform && respawnPoint) if (tranform && respawnPoint)
{ {
currentState = RaccoonStates.IDLE; currentState = RaccoonStates.IDLE;
if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState))) if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
stateMachine.SetState(typeof(PlayerIdleState)); stateMachine.SetState(typeof(PlayerIdleState));

View File

@ -22,7 +22,11 @@ public class ScoringZone : Script
{ {
if (GameManager.Instance && info.GameObject.GetScript<Item>() && info.GameObject.IsActiveSelf && !info.GameObject.GetComponent<Collider>().GetCollisionShape(0).IsTrigger ) if (GameManager.Instance && info.GameObject.GetScript<Item>() && info.GameObject.IsActiveSelf && !info.GameObject.GetComponent<Collider>().GetCollisionShape(0).IsTrigger )
{ {
if (GameManager.Instance.currMultiplierCombo > 1)
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score * GameManager.Instance.currMultiplierCombo; GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score * GameManager.Instance.currMultiplierCombo;
else
GameManager.Instance.Score += info.GameObject.GetScript<Item>().Score;
GameManager.Instance.ItemScored(); GameManager.Instance.ItemScored();
particle.EmissionCount = startingParticleCount * GameManager.Instance.currMultiplierCombo; particle.EmissionCount = startingParticleCount * GameManager.Instance.currMultiplierCombo;
particle.Emit(); particle.Emit();