Merge branch 'main' into Navigation

This commit is contained in:
maverickdgg 2023-03-25 17:20:49 +08:00
commit 2d9b7f3a5d
2 changed files with 36 additions and 29 deletions

View File

@ -4,37 +4,43 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static PlayerController;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
{ {
public class HomeOwnerAttackHitbox:Script public class HomeOwnerAttackHitbox : Script
{
public GameObject aiGO;
protected override void update()
{ {
public GameObject aiGO; Transform transform = GetComponent<Transform>();
protected override void update() Transform aiTransform = aiGO.GetComponent<Transform>();
{
Transform transform = GetComponent<Transform>();
Transform aiTransform = aiGO.GetComponent<Transform>();
if(transform)
{
transform.GlobalPosition = aiTransform.GlobalPosition;
}
}
protected override void onTriggerStay(CollisionInfo info)
{
PlayerController pc = info.GameObject.GetScript<PlayerController>();
HomeOwnerAI ai = aiGO.GetScript<HomeOwnerAI>();
if (pc)
{
pc.GotCaught();
if(ai)
ai.Reset();
}
}
if (transform)
{
transform.GlobalPosition = aiTransform.GlobalPosition;
transform.GlobalEulerAngles = aiTransform.GlobalEulerAngles;
}
} }
protected override void onTriggerStay(CollisionInfo info)
{
PlayerController pc = info.GameObject.GetScript<PlayerController>();
HomeOwnerAI ai = aiGO.GetScript<HomeOwnerAI>();
if (pc)
{
pc.currentState = RaccoonStates.CAUGHT;
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
pc.stateMachine.SetState(typeof(PlayerCaughtState));
pc.GotCaught();
if (ai)
ai.Reset();
}
}
}
} }

View File

@ -510,9 +510,10 @@ public class PlayerController : Script
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));
tranform.LocalPosition = respawnPoint.GetComponent<Transform>().LocalPosition;
GameManager.Instance.RacoonCaught(); tranform.GlobalPosition = respawnPoint.GetComponent<Transform>().GlobalPosition;
GameManager.Instance.RacoonCaught();
if (pat && pat.item) if (pat && pat.item)
{ {