using System; using UnityEngine; namespace Game { public class AnimatorCockController : ICockController { private readonly Animator _animator; private const string Status = "status"; private const int StatusIdle = 1; private const int StatusWalk = 2; private const int StatusRun = 3; private const int StatusIdle2 = 4; private const string TriggerAttack = "attack"; private const string TriggerUnderAttack = "underattack"; private const string TriggerJumpAttack = "jumpattack"; private const string TriggerDie = "die"; private const string TriggerRandom1 = "random1"; private const string TriggerRandom2 = "random2"; private const string TriggerRandom3 = "random3"; private const string TriggerRandom4 = "random4"; private const string TriggerRandom5 = "random5"; public AnimatorCockController(Animator animator) { _animator = animator; } public Action OnRun { get; set; } public Action OnIdle { get; set; } public Action OnAttack { get; set; } public Action OnJumpAttack { get; set; } public void Idle() { _animator.SetInteger(Status, StatusIdle); OnIdle?.Invoke(); } public void Walk() { throw new System.NotImplementedException(); } public void Run() { _animator.SetInteger(Status, StatusRun); OnRun?.Invoke(); } public void IdleInBattle() { _animator.SetInteger(Status, StatusIdle2); OnIdle?.Invoke(); } public void Attack() { _animator.ResetTrigger(TriggerAttack); _animator.SetTrigger(TriggerAttack); OnAttack?.Invoke(); } public void JumpAndAttack() { _animator.ResetTrigger(TriggerJumpAttack); _animator.SetTrigger(TriggerJumpAttack); OnJumpAttack?.Invoke(); } public void UnderAttack() { _animator.ResetTrigger(TriggerUnderAttack); _animator.SetTrigger(TriggerUnderAttack); } public void Die() { _animator.ResetTrigger(TriggerDie); _animator.SetTrigger(TriggerDie); } public void RandomAttack(int attack) { switch (attack) { case 1: _animator.ResetTrigger(TriggerRandom1); _animator.SetTrigger(TriggerRandom1); break; case 2: _animator.ResetTrigger(TriggerRandom2); _animator.SetTrigger(TriggerRandom2); break; case 3: _animator.ResetTrigger(TriggerRandom3); _animator.SetTrigger(TriggerRandom3); break; case 4: _animator.ResetTrigger(TriggerRandom4); _animator.SetTrigger(TriggerRandom4); break; case 5: _animator.ResetTrigger(TriggerRandom5); _animator.SetTrigger(TriggerRandom5); break; default: _animator.ResetTrigger(TriggerJumpAttack); _animator.SetTrigger(TriggerJumpAttack); break; } OnJumpAttack?.Invoke(); } public void BeLift() { } } }