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

73 lines
1.1 KiB
C#

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;
if (pc)
pc.Caught();
}
public override void OnExit()
{
animator.Stop();
}
public override void update()
{
timer -= Time.DeltaTimeF;
if(timer <= 0.0f)
{
if (pc)
{
pc.Reset();
}
ai.Reset();
}
else
{
Transform pcTransform = pc.GetComponent<Transform>();
Transform netTransform = ai.attackHitbox.GetComponentInChildren<Transform>();
if (pcTransform && netTransform)
{
pcTransform.GlobalPosition = netTransform.GlobalPosition;
}
}
}
public override void fixedUpdate()
{
}
}
}