+ GameManager CurrentCombatPlayer 버그 및 로직 수정 + 타이탄 슬라임 스프라이트 변경 + Tycoon action 추가 + JumpSlam 스프라이트 형식으로 변경 + Npc 레이어 추가
80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using Sirenix.OdinInspector;
|
|
using Spine.Unity;
|
|
using UnityEngine;
|
|
using AnimationState = Spine.AnimationState;
|
|
|
|
namespace BlueWater.Players
|
|
{
|
|
public class SpineController : MonoBehaviour
|
|
{
|
|
// Variables
|
|
#region Variables
|
|
// Components
|
|
[SerializeField]
|
|
private SkeletonAnimation _skeletonAnimation;
|
|
private AnimationState _animationState;
|
|
|
|
// Variables
|
|
[SerializeField]
|
|
private string _initialSkinName;
|
|
|
|
#endregion
|
|
|
|
// Unity events
|
|
#region Unity events
|
|
|
|
private void Awake()
|
|
{
|
|
InitializeComponents();
|
|
}
|
|
|
|
#endregion
|
|
|
|
// Initialize methods
|
|
#region Initialize methods
|
|
|
|
[Button("셋팅 초기화")]
|
|
public virtual void InitializeComponents()
|
|
{
|
|
_skeletonAnimation = transform.GetComponentInChildren<SkeletonAnimation>();
|
|
_animationState = _skeletonAnimation.AnimationState;
|
|
SetSkin(_initialSkinName);
|
|
}
|
|
|
|
#endregion
|
|
|
|
// Methods
|
|
#region Methods
|
|
|
|
public void PlayAnimation(string animationName, bool isLoopActive, float speed = 1f)
|
|
{
|
|
if (!_skeletonAnimation && _animationState == null) return;
|
|
|
|
if (string.IsNullOrEmpty(animationName))
|
|
{
|
|
Debug.LogError($"{animationName}의 애니메이션은 존재하지 않습니다.");
|
|
return;
|
|
}
|
|
|
|
_animationState.TimeScale = speed;
|
|
_animationState.SetAnimation(0, animationName, isLoopActive);
|
|
}
|
|
|
|
public void SetSkin(string skinName)
|
|
{
|
|
if (_skeletonAnimation == null && _animationState == null) return;
|
|
|
|
if (string.IsNullOrEmpty(skinName))
|
|
{
|
|
Debug.LogError($"{skinName}의 스킨 이름은 존재하지 않습니다.");
|
|
return;
|
|
}
|
|
|
|
_skeletonAnimation.Skeleton.SetSkin(skinName);
|
|
_skeletonAnimation.Skeleton.SetSlotsToSetupPose();
|
|
_animationState.Apply(_skeletonAnimation.Skeleton);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |