Scripting changes for item and added level 1 scene #330

Merged
glencelow merged 10 commits from PlayerController into main 2023-02-02 11:20:20 +08:00
4 changed files with 16 additions and 9 deletions
Showing only changes of commit 7d9ab7a381 - Show all commits

View File

@ -95,6 +95,9 @@ public partial class LeafAttack : BehaviourTreeNode
//Catch player when in range for long enough
//Debug.Log("Success: Caught");
player.GetScript<PlayerController>().currentState = PlayerController.RaccoonStates.CAUGHT;
if (player.GetScript<PlayerController>().stateMachine && !player.GetScript<PlayerController>().stateMachine.IsState(typeof(PlayerCaughtState)))
player.GetScript<PlayerController>().stateMachine.SetState(typeof(PlayerCaughtState));
status = BehaviourTreeNodeStatus.SUCCESS;
onExit(BehaviourTreeNodeStatus.SUCCESS);
return status;

View File

@ -49,6 +49,11 @@ public class Item : Script
Audio.PlaySFXOnce2D("event:/Props/impact_hard");
playSound = false;
}
if (info.GameObject.GetScript<Homeowner1>())
{
returnBack = true;
}
}
protected override void onCollisionExit(CollisionInfo info)

View File

@ -117,13 +117,6 @@ public class PickAndThrow : Script
RetrieveItemComponets();
}
}
if (pc.currentState == RaccoonStates.CAUGHT && itemScript)
{
itemScript.returnBack = true;
pc.holdItem = true;
ResetItemObject();
}
}
protected override void fixedUpdate()
@ -230,7 +223,6 @@ public class PickAndThrow : Script
return false;
}
return false;
}

View File

@ -31,7 +31,7 @@ public class PlayerController : Script
public Camera cam { get; set; }
public CameraArm camArm { get; set; }
private PickAndThrow pat;
private StateMachine stateMachine;
public StateMachine stateMachine;
public bool holdItem { get; set; }
public bool isAiming { get; set; }
@ -370,6 +370,13 @@ public class PlayerController : Script
if (stateMachine && !stateMachine.IsState(typeof(PlayerIdleState)))
stateMachine.SetState(typeof(PlayerIdleState));
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
if (pat && pat.item.GetScript<Item>())
{
holdItem = false;
isAiming = false;
pat.item.GetScript<Item>().returnBack = true;
}
}
}