2024-04-09 18:45:09 +08:00
|
|
|
|
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;
|
|
|
|
|
|
|
2024-04-09 18:45:09 +08:00
|
|
|
|
public Character owner;
|
2024-05-29 17:52:26 +08:00
|
|
|
|
|
2024-04-09 18:45:09 +08:00
|
|
|
|
public WeaponAnim(GameObject rootObj, Character c)
|
2023-10-25 13:52:37 +08:00
|
|
|
|
{
|
2024-05-17 12:24:55 +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;
|
|
|
|
|
|
}
|
2024-04-09 18:45:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
2023-10-25 13:52:37 +08:00
|
|
|
|
if (rawAnim == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"配表需求播放:{animName}但是没有动画组件");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-04-09 18:45:09 +08:00
|
|
|
|
|
|
|
|
|
|
var isStand = !owner.runtimeData.isInSuppressed;
|
|
|
|
|
|
animName = isStand ? "stand_" + animName : "crawl_" + animName;
|
|
|
|
|
|
|
2023-10-25 13:52:37 +08:00
|
|
|
|
rawAnim.Play(animName, 0, 0);
|
|
|
|
|
|
}
|
2024-05-29 17:52:26 +08:00
|
|
|
|
|
|
|
|
|
|
public void StopAnim()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (rawAnim == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rawAnim.Play("idle",0,0);
|
|
|
|
|
|
}
|
2023-10-25 13:52:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|