109 lines
2.6 KiB
C#
109 lines
2.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_MoveAction : Stat_BaseAction
|
|
{
|
|
private float _speedFactor;
|
|
|
|
private float _moveSpeed;
|
|
|
|
private float _footStepTime;
|
|
|
|
public Stat_MoveAction(Stat_StateManager statMgr)
|
|
: base(statMgr)
|
|
{
|
|
}
|
|
|
|
public override bool Enter(Dictionary<string, object> param, bool clearDelegates = false)
|
|
{
|
|
base.Enter(param, clearDelegates);
|
|
if (param != null && param.Count > 0)
|
|
{
|
|
_speedFactor = (float)param["speed"];
|
|
}
|
|
else
|
|
{
|
|
_speedFactor = 6.5f;
|
|
}
|
|
_moveSpeed = m_char.GetMoveSpeed();
|
|
m_char.ResetRigidBody();
|
|
m_char.SetAtkCollision(false);
|
|
m_char.SetAtkCollision(true);
|
|
return true;
|
|
}
|
|
|
|
public override bool UpdateDelegate()
|
|
{
|
|
_moveSpeed = m_char.GetMoveSpeed();
|
|
if (_speedFactor > 4.5f)
|
|
{
|
|
_speedFactor -= 2f * Time.deltaTime;
|
|
//string animName = m_char.GetAnimName("run");
|
|
//m_char.PlayAnimation(animName, true);
|
|
_footStepTime += Time.deltaTime;
|
|
if (_footStepTime > 0.3f)
|
|
{
|
|
if (m_char is EntityPlayer)
|
|
{
|
|
//HeroSounds.Instance.PlayStepSound(m_char as EntityPlayer);
|
|
}
|
|
_footStepTime = 0f;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!(_speedFactor > 0.2f))
|
|
{
|
|
SetCurActionState(enStat.STAT_ACTION_IDLE);
|
|
return true;
|
|
}
|
|
if (m_char.m_handMovement)
|
|
{
|
|
m_char.StartAI();
|
|
m_char.m_handMovement = false;
|
|
SetCurActionState(enStat.STAT_ACTION_IDLE);
|
|
return true;
|
|
}
|
|
_speedFactor -= 2f * Time.deltaTime;
|
|
//string animName2 = m_char.GetAnimName("walk");
|
|
//m_char.PlayAnimation(animName2, true);
|
|
//m_char.SetAnimationSpeed(animName2, m_speedFactor / 7.5f + 0.2f);
|
|
_moveSpeed -= (6.5f - _speedFactor) / 14f;
|
|
_footStepTime += Time.deltaTime;
|
|
if (_footStepTime > 0.4f)
|
|
{
|
|
if (m_char is EntityPlayer)
|
|
{
|
|
//HeroSounds.Instance.PlayStepSound(m_char as EntityPlayer);
|
|
}
|
|
_footStepTime = 0f;
|
|
}
|
|
}
|
|
if (_moveSpeed <= 0f)
|
|
{
|
|
_moveSpeed = 0f;
|
|
}
|
|
m_char.Move(m_char.forward, _moveSpeed);
|
|
return true;
|
|
}
|
|
|
|
public override bool CanTransition(enStat stat)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|