NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Weapon/WeaponAnim.cs

52 lines
1.2 KiB
C#
Raw Normal View History

using Gameplay.Character;
using UnityEngine;
2023-10-25 13:52:37 +08:00
namespace Code.Scripts.Gameplay.Weapon
{
public class WeaponAnim
{
public GameObject rootObj;
public Animator rawAnim;
public Character owner;
public WeaponAnim(GameObject rootObj, Character c)
2023-10-25 13:52:37 +08:00
{
owner = c;
2023-10-25 13:52:37 +08:00
this.rootObj = rootObj;
2024-06-06 15:39:43 +08:00
// DebugUtil.Log($"获取到武器root节点:{this.rootObj.name}");
2024-04-08 19:05:30 +08:00
rawAnim = rootObj.GetComponentInChildren<Animator>();
2023-10-25 13:52:37 +08:00
}
public void PlayAnim(string animName)
{
if (string.IsNullOrEmpty(animName))
{
return;
}
2023-10-25 13:52:37 +08:00
if (rawAnim == null)
{
DebugUtil.LogError($"配表需求播放:{animName}但是没有动画组件");
return;
}
var isStand = !owner.runtimeData.isInSuppressed;
animName = isStand ? "stand_" + animName : "crawl_" + animName;
2023-10-25 13:52:37 +08:00
rawAnim.Play(animName, 0, 0);
}
public void StopAnim()
{
if (rawAnim == null)
{
return;
}
rawAnim.Play("idle",0,0);
}
2023-10-25 13:52:37 +08:00
}
}