96 lines
2.0 KiB
C#
96 lines
2.0 KiB
C#
using Game;
|
|
using Game.HotFix;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace Game
|
|
{
|
|
public class CharacterMachine : ICharMachineBase //是否使用其他基类或是否使用MonoBehaviour 靠外部驱动,按需修改
|
|
{
|
|
private Animator _animator;
|
|
|
|
public bool IsAttacking()
|
|
{
|
|
AnimatorStateInfo stateInfo = _animator.GetCurrentAnimatorStateInfo(0);
|
|
|
|
if (stateInfo.IsName("Idle"))
|
|
return false;
|
|
|
|
if (stateInfo.IsName("Run"))
|
|
return false;
|
|
|
|
if (stateInfo.IsName("Hit"))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
#region 虚函数实现
|
|
public void InitMachine(Transform trans, S_ROLE_DATA_BASE data = null)
|
|
{
|
|
_animator = trans.GetComponent<Animator>();
|
|
|
|
if (data != null)
|
|
{
|
|
_animator.SetInteger("RoleID", (int)data.innate.roleid);
|
|
_animator.SetInteger("NodeType", (int)data.RoleType);
|
|
}
|
|
}
|
|
|
|
public void ReleazeMachine()
|
|
{
|
|
_animator = null;
|
|
}
|
|
public void Update_Logic()
|
|
{ }
|
|
|
|
public void StartRun()
|
|
{
|
|
_animator.SetInteger("Speed", 1);
|
|
}
|
|
|
|
public void BackToIdle()
|
|
{
|
|
_animator.SetInteger("Speed", 0);
|
|
}
|
|
public void DeadToIdle()
|
|
{
|
|
_animator.SetBool("Dead", false);
|
|
}
|
|
|
|
//public void SetAttack(string anim)
|
|
//{
|
|
// _animator.SetBool(anim, true);
|
|
//}
|
|
|
|
public void SetAttack(string anim)
|
|
{
|
|
_animator.Play(anim);
|
|
}
|
|
|
|
public void SetOtherAnime(string anim)
|
|
{
|
|
_animator.Play(anim);
|
|
}
|
|
|
|
public void PlayDead()
|
|
{
|
|
_animator.Play("Dead");
|
|
}
|
|
|
|
public void PlayHit()
|
|
{
|
|
_animator.Play("Hurt");
|
|
}
|
|
|
|
public void SetAnimatorSpeed(float speed)
|
|
{
|
|
_animator.speed = speed;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|