Added Attack animation, Fix Edge case for path finding. Added footsteps. Level 2 merge #444

Merged
maverickdgg merged 7 commits from Navigation into main 2023-03-25 16:54:30 +08:00
8 changed files with 482 additions and 492 deletions
Showing only changes of commit 291c9d044e - Show all commits

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -5727,7 +5727,7 @@
Components: Components:
Transform Component: Transform Component:
Translate: {x: 0, y: -300, z: 0} Translate: {x: 0, y: -300, z: 0}
Rotate: {x: -1.48352981, y: 0.5, z: 0.5} Rotate: {x: 1.48352981, y: 0.5, z: 0.5}
Scale: {x: 400, y: 100, z: 500} Scale: {x: 400, y: 100, z: 500}
IsActive: true IsActive: true
Renderable Component: Renderable Component:

View File

@ -1,11 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;
using SHADE; using SHADE;
using SHADE_Scripting.Audio;
using SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States; using SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
@ -68,6 +64,8 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
machine.InitStateMachine(dictionary); machine.InitStateMachine(dictionary);
} }
AudioHandler.audioClipHandlers["HO_footsteps"] = SHADE.Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
patrolPointPool = patrolPointParent.GetComponentsInChildren<Transform>(); patrolPointPool = patrolPointParent.GetComponentsInChildren<Transform>();
Transform transform = GetComponent<Transform>(); Transform transform = GetComponent<Transform>();
if (transform) if (transform)

View File

@ -40,6 +40,13 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
if (rotate) if (rotate)
rotate.active = false; rotate.active = false;
RigidBody rigid = machine.GetComponent<RigidBody>();
if(rigid)
{
rigid.LinearVelocity = Vector3.Zero;
}
ai.attackHitbox.SetActive(false); ai.attackHitbox.SetActive(false);
} }

View File

@ -1,5 +1,6 @@
using SHADE; using SHADE;
using SHADE.Test; using SHADE.Test;
using SHADE_Scripting.Audio;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -18,6 +19,9 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
bool run = true; bool run = true;
float footStepInterval = 12.0f / 30.0f;
float footStepTimer = 0.0f;
public ChaseState(StateMachine machine): base(machine) public ChaseState(StateMachine machine): base(machine)
{ {
@ -35,6 +39,9 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{ {
r.rotateToPlayerLastKnown = true; r.rotateToPlayerLastKnown = true;
} }
footStepTimer = footStepInterval * 0.5f;
} }
public override void OnExit() public override void OnExit()
@ -125,7 +132,12 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
} }
} }
footStepTimer -= Time.DeltaTimeF;
if (footStepTimer <= 0.0f)
{
footStepTimer += footStepInterval;
AudioHandler.audioClipHandlers["HO_footsteps"].Play();
}
} }
public override void fixedUpdate() public override void fixedUpdate()

View File

@ -1,4 +1,5 @@
using SHADE; using SHADE;
using SHADE_Scripting.Audio;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -13,9 +14,12 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
Random rand; Random rand;
Vector3 lastFramePos; Vector3 lastFramePos;
float stuckTimer ; float stuckTimer;
bool run = true; bool run = true;
float footStepInterval = 12.0f / 30.0f;
float footStepTimer = 0.0f;
public PatrolState(StateMachine machine) : base(machine) public PatrolState(StateMachine machine) : base(machine)
{ {
stateName = "Patrol"; stateName = "Patrol";
@ -45,6 +49,9 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
animator.Play(ai.walkingAnim); animator.Play(ai.walkingAnim);
AudioHandler.audioClipHandlers["HO_footsteps"].Play();
footStepTimer = footStepInterval;
RotateToVelocity r = machine.GetScript<RotateToVelocity>(); RotateToVelocity r = machine.GetScript<RotateToVelocity>();
if(r) if(r)
@ -90,7 +97,12 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{ {
machine.SetState(typeof(AlertState)); machine.SetState(typeof(AlertState));
} }
footStepTimer -= Time.DeltaTimeF;
if(footStepTimer <= 0.0f)
{
footStepTimer += footStepInterval;
AudioHandler.audioClipHandlers["HO_footsteps"].Play();
}
} }

View File

@ -322,7 +322,10 @@ namespace SHADE
NavigationGridIndex nxtPoint = comp.path.front(); NavigationGridIndex nxtPoint = comp.path.front();
SHVec3 nxtPointPos = GetGridWorldPos(nxtPoint); SHVec3 nxtPointPos = GetGridWorldPos(nxtPoint);
SHVec3 direction = nxtPointPos - transform->GetWorldPosition(); NavigationGridIndex currPoint = GetNavigationGridIndex(transform->GetWorldPosition());
SHVec3 currPointPos = GetGridWorldPos(currPoint);
SHVec3 direction = nxtPointPos - currPointPos;
direction.y = 0.0f; direction.y = 0.0f;