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

59 lines
1.2 KiB
C#

using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHADE_Scripting.Audio;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework.States
{
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()
{
alertTimer -= Time.DeltaTimeF;
if (alertTimer <= 0.0f)
{
machine.SetState(typeof(ChaseState));
}
}
public override void fixedUpdate()
{
}
}
}