83 lines
1.7 KiB
C#
83 lines
1.7 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;
|
|
bool firstDetection;
|
|
public AlertState(StateMachine machine) : base(machine)
|
|
{
|
|
stateName = "Alert";
|
|
AudioHandler.audioClipHandlers["raccoondetected"] = SHADE.Audio.CreateAudioClip("event:/Raccoon/raccoon_detected");
|
|
firstDetection = true;
|
|
}
|
|
|
|
public override void OnEnter()
|
|
{
|
|
alertTimer = alertDuration;
|
|
if (animator)
|
|
{
|
|
animator.PlayOneShot(ai.alertAnim);
|
|
|
|
}
|
|
|
|
if(firstDetection)
|
|
{
|
|
SHADE.Audio.SetParameterWithLabel("HomeownerBark", "DetectFirst");
|
|
AudioHandler.audioClipHandlers["HO_bark"].Play();
|
|
firstDetection = false;
|
|
}
|
|
else
|
|
{
|
|
|
|
PlayerController pc = ai.player.GetScript<PlayerController>();
|
|
|
|
if (pc && pc.holdItem)
|
|
{
|
|
SHADE.Audio.SetParameterWithLabel("HomeownerBark", "DetectFood");
|
|
AudioHandler.audioClipHandlers["HO_bark"].Play();
|
|
}
|
|
else
|
|
{
|
|
SHADE.Audio.SetParameterWithLabel("HomeownerBark", "DetectAgain");
|
|
AudioHandler.audioClipHandlers["HO_bark"].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()
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|