70 lines
1.8 KiB
C#
70 lines
1.8 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_WalkAction : Stat_BaseAction
|
|||
|
{
|
|||
|
#pragma warning disable CS0414 // 字段“Stat_WalkAction.m_speedFactor”已被赋值,但从未使用过它的值
|
|||
|
private float m_speedFactor;
|
|||
|
#pragma warning restore CS0414 // 字段“Stat_WalkAction.m_speedFactor”已被赋值,但从未使用过它的值
|
|||
|
|
|||
|
private float m_moveSpeed;
|
|||
|
|
|||
|
private float m_footStepTime;
|
|||
|
|
|||
|
private Vector3 target;
|
|||
|
|
|||
|
public Stat_WalkAction(Stat_StateManager statMgr)
|
|||
|
: base(statMgr)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public override bool Enter(Dictionary<string, object> param, bool clearDelegates = false)
|
|||
|
{
|
|||
|
base.Enter(param, clearDelegates);
|
|||
|
if (param.ContainsKey("target"))
|
|||
|
{
|
|||
|
target = (Vector3)param["target"];
|
|||
|
}
|
|||
|
Vector3 curDir = target - m_char.transform.position;
|
|||
|
curDir = curDir.normalized;
|
|||
|
curDir.y = 0f;
|
|||
|
m_char.SetCurDir(curDir);
|
|||
|
m_speedFactor = 6.5f;
|
|||
|
m_moveSpeed = m_char.GetMoveSpeed();
|
|||
|
m_char.ResetRigidBody();
|
|||
|
m_char.SetAtkCollision(false);
|
|||
|
m_char.SetAtkCollision(true);
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public override bool UpdateDelegate()
|
|||
|
{
|
|||
|
m_char.Move(m_char.forward, m_moveSpeed);
|
|||
|
float num = Vector3.Distance(m_char.transform.position, target);
|
|||
|
if ((double)num <= 0.01)
|
|||
|
{
|
|||
|
Exit();
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public override bool CanTransition(enStat stat)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|