Added CaughtRaccoon state to AI FSM #449
|
@ -5911,6 +5911,7 @@
|
|||
- Type: SHADE_Scripting.Gameplay.AIBehaviour.AIRework.HomeOwnerAI
|
||||
Enabled: true
|
||||
idleDuration: 1
|
||||
caughtDuration: 2
|
||||
timeoutDuration: 2
|
||||
patrolPointParent: 166
|
||||
patrolSpeed: 1
|
||||
|
@ -17271,3 +17272,4 @@
|
|||
- Type: SHADE_Scripting.Gameplay.AIBehaviour.AIRework.HomeOwnerAttackHitbox
|
||||
Enabled: true
|
||||
aiGO: 158
|
||||
raccoonFound: false
|
|
@ -10,6 +10,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|||
public class HomeOwnerAI : Script
|
||||
{
|
||||
public float idleDuration = 1.0f;
|
||||
public float caughtDuration = 2.0f;
|
||||
public float timeoutDuration = 2.0f;
|
||||
public GameObject patrolPointParent;
|
||||
|
||||
|
@ -41,6 +42,9 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|||
|
||||
private Transform transform;
|
||||
|
||||
[NonSerialized]
|
||||
public HomeOwnerAttackHitbox hitboxScript;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
StateMachine machine = GetScript<StateMachine>();
|
||||
|
@ -65,6 +69,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|||
dictionary.Add(typeof(ChaseState), new ChaseState(machine));
|
||||
dictionary.Add(typeof(AlertState), new AlertState(machine));
|
||||
dictionary.Add(typeof(AttackState), new AttackState(machine));
|
||||
dictionary.Add(typeof(CaughtRaccoonState), new CaughtRaccoonState(machine));
|
||||
|
||||
machine.InitStateMachine(dictionary);
|
||||
}
|
||||
|
@ -84,6 +89,11 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|||
//attackHitbox.SetActive(false);
|
||||
if (pppList != null)
|
||||
startPos = pppList[0].LocalPosition;
|
||||
|
||||
if (attackHitbox)
|
||||
hitboxScript = attackHitbox.GetScript<HomeOwnerAttackHitbox>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,11 +13,12 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|||
{
|
||||
public GameObject aiGO;
|
||||
|
||||
private bool raccoonFound = false;
|
||||
public bool raccoonFound = false;
|
||||
Transform transform;
|
||||
Transform aiTransform;
|
||||
|
||||
private PlayerController pc;
|
||||
[NonSerialized]
|
||||
public PlayerController pc;
|
||||
private HomeOwnerAI ai;
|
||||
|
||||
protected override void start()
|
||||
|
@ -39,19 +40,17 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|||
|
||||
if (raccoonFound && pc && ai)
|
||||
{
|
||||
pc.currentState = RaccoonStates.CAUGHT;
|
||||
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
|
||||
pc.stateMachine.SetState(typeof(PlayerCaughtState));
|
||||
|
||||
pc.GotCaught();
|
||||
ai.Reset();
|
||||
if (!ai.atk)
|
||||
raccoonFound = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void onTriggerStay(CollisionInfo info)
|
||||
{
|
||||
if(info.GameObject.GetScript<PlayerController>())
|
||||
pc = info.GameObject.GetScript<PlayerController>();
|
||||
if (ai && ai.atk && pc)
|
||||
{
|
||||
|
|
|
@ -37,23 +37,23 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|||
{
|
||||
lookOffset = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(left )
|
||||
{
|
||||
if (lookOffset > -lookAroundAngle)
|
||||
lookOffset -= rotationPerSecond * Time.DeltaTimeF;
|
||||
else
|
||||
left = false;
|
||||
}
|
||||
if (!left)
|
||||
{
|
||||
if (lookOffset < lookAroundAngle)
|
||||
lookOffset += rotationPerSecond * Time.DeltaTimeF;
|
||||
else
|
||||
left = false;
|
||||
}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// if(left )
|
||||
// {
|
||||
// if (lookOffset > -lookAroundAngle)
|
||||
// lookOffset -= rotationPerSecond * Time.DeltaTimeF;
|
||||
// else
|
||||
// left = false;
|
||||
// }
|
||||
// if (!left)
|
||||
// {
|
||||
// if (lookOffset < lookAroundAngle)
|
||||
// lookOffset += rotationPerSecond * Time.DeltaTimeF;
|
||||
// else
|
||||
// left = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
|||
|
||||
public AttackState(StateMachine machine) : base(machine)
|
||||
{
|
||||
|
||||
stateName = "Attack";
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
|||
|
||||
public override void OnExit()
|
||||
{
|
||||
animator.Stop();
|
||||
|
||||
RotateToVelocity rotate = ai.GetScript<RotateToVelocity>();
|
||||
if (rotate)
|
||||
{
|
||||
|
@ -84,6 +84,12 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
|||
|
||||
public override void update()
|
||||
{
|
||||
if (ai.hitboxScript.raccoonFound)
|
||||
{
|
||||
machine.SetState(typeof(CaughtRaccoonState));
|
||||
}
|
||||
|
||||
|
||||
timer -= Time.DeltaTimeF;
|
||||
if (windUp)
|
||||
{
|
||||
|
@ -141,9 +147,13 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
|||
machine.SetState(typeof(TimeoutState));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void fixedUpdate()
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SHADE;
|
||||
using static PlayerController;
|
||||
|
||||
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
||||
{
|
||||
public class CaughtRaccoonState: AIBaseState
|
||||
{
|
||||
|
||||
private float timer = 0.0f;
|
||||
private PlayerController pc;
|
||||
|
||||
public CaughtRaccoonState(StateMachine machine):base(machine)
|
||||
{
|
||||
stateName = "Caught Raccoon";
|
||||
}
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
if(ai.hitboxScript)
|
||||
pc = ai.hitboxScript.pc;
|
||||
|
||||
timer = ai.caughtDuration;
|
||||
}
|
||||
|
||||
|
||||
public override void OnExit()
|
||||
{
|
||||
animator.Stop();
|
||||
}
|
||||
|
||||
public override void update()
|
||||
{
|
||||
timer -= Time.DeltaTimeF;
|
||||
if(timer <= 0.0f)
|
||||
{
|
||||
if (pc)
|
||||
{
|
||||
pc.currentState = RaccoonStates.CAUGHT;
|
||||
if (pc.stateMachine && !pc.stateMachine.IsState(typeof(PlayerCaughtState)))
|
||||
pc.stateMachine.SetState(typeof(PlayerCaughtState));
|
||||
|
||||
pc.GotCaught();
|
||||
}
|
||||
ai.Reset();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void fixedUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Name: CaughtRaccoonState
|
||||
ID: 153010954
|
||||
Type: 9
|
|
@ -14,7 +14,7 @@ namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
|
|||
|
||||
float giveUpDuration = 10.0f;
|
||||
float giveUpTimer = 0.0f;
|
||||
float atkDistance = 2.0f;
|
||||
float atkDistance = 1.0f;
|
||||
|
||||
|
||||
bool run = true;
|
||||
|
|
Loading…
Reference in New Issue