Bug fixes and new assets #246

Merged
glencelow merged 10 commits from PlayerController into main 2022-11-22 16:25:14 +08:00
7 changed files with 58 additions and 23 deletions
Showing only changes of commit 56e7f73bbb - Show all commits

View File

@ -26,7 +26,7 @@ public class PickAndThrow : Script
protected override void awake() protected override void awake()
{ {
playerTran = GetComponent<Transform>(); playerTran = GetComponent<Transform>();
if (playerTran) if (!playerTran)
Debug.Log("PLAYERTRANSFORM EMPTY"); ; Debug.Log("PLAYERTRANSFORM EMPTY"); ;
pc = GetScript<PlayerController>(); pc = GetScript<PlayerController>();
@ -34,7 +34,7 @@ public class PickAndThrow : Script
Debug.Log("PLAYER CONTROLLER EMPTY"); Debug.Log("PLAYER CONTROLLER EMPTY");
raccoonHoldLocation = GetComponentInChildren<Transform>(); raccoonHoldLocation = GetComponentInChildren<Transform>();
if (raccoonHoldLocation == null) if (!raccoonHoldLocation)
Debug.Log("CHILD EMPTY"); Debug.Log("CHILD EMPTY");
tpc = GetScriptInChildren<ThirdPersonCamera>(); tpc = GetScriptInChildren<ThirdPersonCamera>();
@ -66,6 +66,7 @@ public class PickAndThrow : Script
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming) if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
{ {
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_throw");
pc.isAiming = false; pc.isAiming = false;
if(tpc) if(tpc)
pc.camArm.ArmLength = tpc.armLength; pc.camArm.ArmLength = tpc.armLength;
@ -94,7 +95,6 @@ public class PickAndThrow : Script
{ {
if (pc.currentState == RaccoonStates.WALKING || pc.currentState == RaccoonStates.IDLE) if (pc.currentState == RaccoonStates.WALKING || pc.currentState == RaccoonStates.IDLE)
{ {
Debug.Log("PCIKUP");
pc.holdItem = true; pc.holdItem = true;
RetrieveItemComponets(); RetrieveItemComponets();
} }

View File

@ -1,3 +1,3 @@
Name: UT_PlayerCaughtState Name: UT_PlayerCaughtState
ID: 153166405 ID: 154071709
Type: 9 Type: 9

View File

@ -3,9 +3,12 @@ using System;
public class PlayerRunState : BaseState public class PlayerRunState : BaseState
{ {
private float timer;
private float delay = 0.25f;
public PlayerRunState(StateMachine stateMachine) : base(stateMachine) public PlayerRunState(StateMachine stateMachine) : base(stateMachine)
{ {
stateName = "Walk State"; stateName = "Run State";
} }
public override void OnEnter() public override void OnEnter()
{ {
@ -14,6 +17,13 @@ public class PlayerRunState : BaseState
public override void update() public override void update()
{ {
//Debug.Log("WALKING"); //Debug.Log("WALKING");
timer += Time.DeltaTimeF;
if (timer > delay)
{
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_footsteps");
timer = 0;
}
} }
public override void fixedUpdate() public override void fixedUpdate()
{ {

View File

@ -3,6 +3,8 @@ using System;
public class PlayerWalkState : BaseState public class PlayerWalkState : BaseState
{ {
private float timer;
private float delay = 0.5f;
public PlayerWalkState(StateMachine stateMachine) : base(stateMachine) public PlayerWalkState(StateMachine stateMachine) : base(stateMachine)
{ {
stateName = "Walk State"; stateName = "Walk State";
@ -10,10 +12,18 @@ public class PlayerWalkState : BaseState
public override void OnEnter() public override void OnEnter()
{ {
//Debug.Log("WALK ENTER"); //Debug.Log("WALK ENTER");
timer = delay;
} }
public override void update() public override void update()
{ {
//Debug.Log("WALKING"); //Debug.Log("WALKING");
timer += Time.DeltaTimeF;
if (timer > delay)
{
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_footsteps");
timer = 0;
}
} }
public override void fixedUpdate() public override void fixedUpdate()
{ {

View File

@ -14,6 +14,7 @@ public class Item : Script
public ItemCategory currCategory; public ItemCategory currCategory;
private RigidBody rb; private RigidBody rb;
private Collider collider; private Collider collider;
private bool once = false;
protected override void awake() protected override void awake()
{ {
@ -31,8 +32,21 @@ public class Item : Script
} }
} }
protected override void onTriggerEnter(CollisionInfo info) protected override void onCollisionEnter(CollisionInfo info)
{ {
if (once)
{
if(currCategory == ItemCategory.LIGHT)
Audio.PlayBGMOnce2D("event:/Props/impact_elastic");
else if (currCategory == ItemCategory.MEDIUM || currCategory == ItemCategory.HEAVY)
Audio.PlayBGMOnce2D("event:/Props/impact_hard");
once = false;
}
}
protected override void onCollisionExit(CollisionInfo info)
{
once = true;
} }
} }

View File

@ -12,6 +12,7 @@ public class ScoringZone : Script
{ {
if (gameManger && info.GameObject.GetScript<Item>()) if (gameManger && info.GameObject.GetScript<Item>())
{ {
Audio.PlayBGMOnce2D("event:/Music/stingers/item_scored");
gameManger.Score += info.GameObject.GetScript<Item>().Score; gameManger.Score += info.GameObject.GetScript<Item>().Score;
gameManger.totalItemCount -= 1; gameManger.totalItemCount -= 1;
info.GameObject.SetActive(false); info.GameObject.SetActive(false);

View File

@ -34,39 +34,39 @@ event:/Homeowner/homeowner_detect_raccoon
} }
protected override void update() protected override void update()
{ {
if (Input.GetKey(Input.KeyCode.Q)) if (Input.GetKeyDown(Input.KeyCode.Q))
Audio.PlayBGMOnce2D("event:/UI/mouse_down_element"); Audio.PlayBGMOnce2D("event:/UI/mouse_down_element");
if (Input.GetKey(Input.KeyCode.W)) if (Input.GetKeyDown(Input.KeyCode.W))
Audio.PlayBGMOnce2D("event:/UI/mouse_down_empty"); Audio.PlayBGMOnce2D("event:/UI/mouse_down_empty");
if (Input.GetKey(Input.KeyCode.E)) if (Input.GetKeyDown(Input.KeyCode.E))
Audio.PlayBGMOnce2D("event:/UI/mouse_enter_element"); Audio.PlayBGMOnce2D("event:/UI/mouse_enter_element");
if (Input.GetKey(Input.KeyCode.R)) if (Input.GetKeyDown(Input.KeyCode.R))
Audio.PlayBGMOnce2D("event:/UI/mouse_exit_element"); Audio.PlayBGMOnce2D("event:/UI/mouse_exit_element");
if (Input.GetKey(Input.KeyCode.T)) if (Input.GetKeyDown(Input.KeyCode.T))
Audio.PlayBGMOnce2D("event:/UI/success"); Audio.PlayBGMOnce2D("event:/UI/success");
if (Input.GetKey(Input.KeyCode.Y)) if (Input.GetKeyDown(Input.KeyCode.Y))
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_throw"); Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_throw");
if (Input.GetKey(Input.KeyCode.U)) if (Input.GetKeyDown(Input.KeyCode.U))
Audio.PlayBGMOnce2D("event:/Props/impact_hard"); Audio.PlayBGMOnce2D("event:/Props/impact_hard");
if (Input.GetKey(Input.KeyCode.I)) if (Input.GetKeyDown(Input.KeyCode.I))
Audio.PlayBGMOnce2D("event:/Music/player_undetected"); Audio.PlayBGMOnce2D("event:/Music/player_undetected");
if (Input.GetKey(Input.KeyCode.O)) if (Input.GetKeyDown(Input.KeyCode.O))
Audio.PlayBGMOnce2D("event:/Music/player_detected"); Audio.PlayBGMOnce2D("event:/Music/player_detected");
if (Input.GetKey(Input.KeyCode.P)) if (Input.GetKeyDown(Input.KeyCode.P))
Audio.PlayBGMOnce2D("event:/Music/stingers/player_detected"); Audio.PlayBGMOnce2D("event:/Music/stingers/player_detected");
if (Input.GetKey(Input.KeyCode.A)) if (Input.GetKeyDown(Input.KeyCode.A))
Audio.PlayBGMOnce2D("event:/Music/stingers/item_scored"); Audio.PlayBGMOnce2D("event:/Music/stingers/item_scored");
if (Input.GetKey(Input.KeyCode.S)) if (Input.GetKeyDown(Input.KeyCode.S))
Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_humming"); Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_humming");
if (Input.GetKey(Input.KeyCode.D)) if (Input.GetKeyDown(Input.KeyCode.D))
Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_footsteps"); Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_footsteps");
if (Input.GetKey(Input.KeyCode.F)) if (Input.GetKeyDown(Input.KeyCode.F))
Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_detect_raccoon"); Audio.PlayBGMOnce2D("event:/Homeowner/homeowner_detect_raccoon");
if (Input.GetKey(Input.KeyCode.G)) if (Input.GetKeyDown(Input.KeyCode.G))
Audio.PlayBGMOnce2D("event:/Music/player_undetected"); Audio.PlayBGMOnce2D("event:/Music/player_undetected");
if (Input.GetKey(Input.KeyCode.H)) if (Input.GetKeyDown(Input.KeyCode.H))
Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_footsteps"); Audio.PlayBGMOnce2D("event:/Raccoon/raccoon_footsteps");
if (Input.GetKey(Input.KeyCode.J)) if (Input.GetKeyDown(Input.KeyCode.J))
Audio.PlayBGMOnce2D("event:/Props/impact_elastic"); Audio.PlayBGMOnce2D("event:/Props/impact_elastic");
} }