58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-09-02
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "Stat_IdleAction" company="Kimch"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
namespace G
|
|
{
|
|
|
|
public class Stat_RunAwayAction : Stat_BaseAction
|
|
{
|
|
private Vector3 runawayDirector = Vector3.zero;
|
|
|
|
public Stat_RunAwayAction(Stat_StateManager statMgr)
|
|
: base(statMgr)
|
|
{
|
|
}
|
|
|
|
public override bool Enter(Dictionary<string, object> param, bool clearDelegates = false)
|
|
{
|
|
base.Enter(param, clearDelegates);
|
|
//string animName = m_char.GetAnimName("run");
|
|
//if (m_char.PlayAnimation(animName, true) == -1f)
|
|
//{
|
|
// return false;
|
|
//}
|
|
runawayDirector = m_char.position - m_char.GetTargetPos();
|
|
runawayDirector[1] = 0f;
|
|
runawayDirector = Vector3.Normalize(runawayDirector);
|
|
float angle = Random.Range(-90f, 90f);
|
|
Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.up);
|
|
runawayDirector = rotation * runawayDirector;
|
|
float delay = Random.Range(0.5f, 2f);
|
|
m_statMgr.AddTimer(delay, TimeIsUp);
|
|
return true;
|
|
}
|
|
|
|
public override bool UpdateDelegate()
|
|
{
|
|
float moveSpeed = m_char.GetMoveSpeed();
|
|
m_char.Move(runawayDirector, moveSpeed);
|
|
return true;
|
|
}
|
|
|
|
public bool TimeIsUp(object[] param)
|
|
{
|
|
return SetCurActionState(enStat.STAT_ACTION_IDLE, null, true);
|
|
}
|
|
}
|
|
}
|