48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
namespace BlueWaterProject
|
|
{
|
|
public class OrderToPrisonState : INpcState
|
|
{
|
|
private NavMeshAgent agent;
|
|
private InShipMapInfo inShipMapInfo;
|
|
|
|
public OrderToPrisonState(NavMeshAgent agent, InShipMapInfo inShipMapInfo)
|
|
{
|
|
this.agent = agent;
|
|
this.inShipMapInfo = inShipMapInfo;
|
|
}
|
|
|
|
public event Action OnUnityEvent;
|
|
|
|
public void OnEnter(NpcStateMachine npcStateMachine)
|
|
{
|
|
inShipMapInfo.OpenPrisonDoor();
|
|
agent.isStopped = true;
|
|
agent.destination = inShipMapInfo.prisonPoint.position;
|
|
agent.speed = 10f;
|
|
agent.isStopped = false;
|
|
}
|
|
|
|
public void OnUpdate(NpcStateMachine npcStateMachine)
|
|
{
|
|
if (!agent.pathPending && agent.remainingDistance < 1f)
|
|
{
|
|
inShipMapInfo.ClosePrisonDoor();
|
|
agent.speed = 3.5f;
|
|
}
|
|
}
|
|
|
|
public void OnExit(NpcStateMachine npcStateMachine)
|
|
{
|
|
|
|
}
|
|
|
|
public INpcState Clone()
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
} |