using Gameplay.Character; using UnityEngine; namespace Code.Scripts.Gameplay.Weapon { public class WeaponAnim { public GameObject rootObj; public Animator rawAnim; public Character owner; public WeaponAnim(GameObject rootObj, Character c) { owner = c; this.rootObj = rootObj; // DebugUtil.Log($"获取到武器root节点:{this.rootObj.name}"); rawAnim = rootObj.GetComponentInChildren(); } public void PlayAnim(string animName) { if (string.IsNullOrEmpty(animName)) { return; } if (rawAnim == null) { DebugUtil.LogError($"配表需求播放:{animName}但是没有动画组件"); return; } var isStand = !owner.runtimeData.isInSuppressed; animName = isStand ? "stand_" + animName : "crawl_" + animName; rawAnim.Play(animName, 0, 0); } public void StopAnim() { if (rawAnim == null) { return; } rawAnim.Play("idle",0,0); } } }