Untitled
unknown
csharp
2 years ago
1.6 kB
8
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class Chase : BaseState
{
public Chase(StateMachine stateMachine) : base("Chase", stateMachine) { }
private float cooldownTime;
public override void Enter()
{
base.Enter();
// stateMachine.animator.CrossFade("Idle", 0.2f);
stateMachine.ChangeAnimationStatus(true, 1, null);
stateMachine.ChangeMovingSpeed(stateMachine.runningSpeed);
cooldownTime = 5;
stateMachine.playSound("Guard", 0);
stateMachine.activeCollider(true, true);
}
public override void Update()
{
base.Update();
stateMachine.FOV.currentRate -= Time.deltaTime;
if(cooldownTime > 0 || stateMachine.Agent.isStopped)
{
Game_Manager.Instance.updateLastSeenPosition();
stateMachine.Agent.SetDestination(Game_Manager.Instance.GetLastSeenPosition);
}
if (Time.time > stateMachine.FOV.currentRate + 0.1f)
{
if (stateMachine.FOV.playerInSight)
{
cooldownTime = 5;
}
stateMachine.FOV.currentRate = Time.time;
}
else
{
cooldownTime -= Time.deltaTime;
if(cooldownTime <= 0)
{
stateMachine.ChangeState("Searching");
}
}
}
public override void Exit()
{
base.Exit();
Game_Manager.Instance.updateLastSeenPosition();
}
}
Editor is loading...
Leave a Comment