Navigation and AI merge for level 3 #445

Merged
maverickdgg merged 6 commits from Navigation into main 2023-03-25 18:49:20 +08:00
4 changed files with 30 additions and 21 deletions
Showing only changes of commit e7ec24c15a - Show all commits

View File

@ -5535,7 +5535,7 @@
- Is Trigger: false - Is Trigger: false
Collision Tag: 5 Collision Tag: 5
Type: Box Type: Box
Half Extents: {x: 0.600000024, y: 1.79999995, z: 0.400000006} Half Extents: {x: 0.200000003, y: 1.79999995, z: 0.200000003}
Friction: 0.400000006 Friction: 0.400000006
Bounciness: 0 Bounciness: 0
Density: 1 Density: 1

View File

@ -127,14 +127,17 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
private void AICheat() private void AICheat()
{ {
StateMachine machine = GetScript<StateMachine>(); StateMachine machine = GetScript<StateMachine>();
if(machine) AILineOfSight los = GetScript<AILineOfSight>();
if(machine && los)
{ {
if (Input.GetKeyDown(Input.KeyCode.F)) if (Input.GetKeyDown(Input.KeyCode.K))
{ {
los.range = 5.0f;
machine.SetState(typeof(AlertState)); machine.SetState(typeof(AlertState));
} }
if(Input.GetKeyDown(Input.KeyCode.L)) if(Input.GetKeyDown(Input.KeyCode.L))
{ {
los.range = 0.0f;
machine.SetState(typeof(IdleState)); machine.SetState(typeof(IdleState));
} }

View File

@ -42,11 +42,11 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
HomeOwnerAI ai = aiGO.GetScript<HomeOwnerAI>(); HomeOwnerAI ai = aiGO.GetScript<HomeOwnerAI>();
if (pc) if (pc)
{ {
//pc.currentState = RaccoonStates.CAUGHT; pc.currentState = RaccoonStates.CAUGHT;
//if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState))) if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
// pc.stateMachine.SetState(typeof(PlayerCaughtState)); pc.stateMachine.SetState(typeof(PlayerCaughtState));
//pc.GotCaught(); pc.GotCaught();
if (ai) if (ai)
{ {
ai.Reset(); ai.Reset();

View File

@ -14,7 +14,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
float windupTime = 8.0f / 30.0f; float windupTime = 8.0f / 30.0f;
float holdTime = 0.3f; float holdTime = 0.3f;
float seqTime = 8.0f / 30.0f; float seqTime = 8.0f / 30.0f ;
float endTime = 0.5f; float endTime = 0.5f;
@ -48,8 +48,19 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{ {
rigid.LinearVelocity = Vector3.Zero; rigid.LinearVelocity = Vector3.Zero;
} }
Transform transform = machine.GetComponent<Transform>();
AILineOfSight los = machine.GetScript<AILineOfSight>();
Transform playerTransform = ai.player.GetComponent<Transform>();
if (los && transform)
{
Vector3 direction = playerTransform.GlobalPosition - transform.GlobalPosition;
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
transform.LocalRotation = targetRotation;
}
ai.attackHitbox.SetActive(false); ai.attackHitbox.SetActive(false);
} }
@ -64,18 +75,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
rotate.lookAround = false; rotate.lookAround = false;
} }
Transform transform = machine.GetComponent<Transform>();
AILineOfSight los = machine.GetScript<AILineOfSight>();
Transform playerTransform = ai.player.GetComponent<Transform>();
if(los && transform)
{
Vector3 direction = playerTransform.GlobalPosition - transform.GlobalPosition;
Quaternion targetRotation = Quaternion.Euler(0.0f, MathF.Atan2(direction.x, direction.z), 0.0f);
transform.LocalRotation = targetRotation;
}
ai.attackHitbox.SetActive(false); ai.attackHitbox.SetActive(false);
} }
@ -106,11 +106,17 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
} }
else if(seq) else if(seq)
{ {
if(timer <= 1.0f / 30.0f)
{
ai.attackHitbox.SetActive(true);
}
if(timer <= 0.0f) if(timer <= 0.0f)
{ {
seq = false; seq = false;
end = true; end = true;
animator.PlayOneShot(ai.atkSeqAnim);
timer = endTime; timer = endTime;