SHADE_Y3/Assets/Scripts/Gameplay/AIBehaviour/AIRework/States/AlertState.cs

59 lines
1.2 KiB
C#
Raw Normal View History

using SHADE;
2023-03-24 13:26:18 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2023-03-26 13:27:42 +08:00
using SHADE_Scripting.Audio;
2023-03-24 13:26:18 +08:00
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{
2023-03-26 13:27:42 +08:00
public class AlertState : AIBaseState
{
const float alertDuration = 16.0f / 30.0f + 1.0f;
float alertTimer = alertDuration;
public AlertState(StateMachine machine) : base(machine)
{
stateName = "Alert";
AudioHandler.audioClipHandlers["raccoondetected"] = SHADE.Audio.CreateAudioClip("event:/Raccoon/raccoon_detected");
}
public override void OnEnter()
{
alertTimer = alertDuration;
if (animator)
{
animator.PlayOneShot(ai.alertAnim);
}
SHADE.Audio.SetParameterWithLabel("PlayerDetection", "Detected");
AudioHandler.audioClipHandlers["raccoondetected"].Play();
}
public override void OnExit()
{
animator.Stop();
}
public override void update()
2023-03-24 13:26:18 +08:00
{
2023-03-26 13:27:42 +08:00
alertTimer -= Time.DeltaTimeF;
if (alertTimer <= 0.0f)
{
machine.SetState(typeof(ChaseState));
}
2023-03-24 13:26:18 +08:00
}
2023-03-26 13:27:42 +08:00
public override void fixedUpdate()
{
}
}
2023-03-24 13:26:18 +08:00
}