AnimatorCockController.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. using UnityEngine;
  3. namespace Game
  4. {
  5. public class AnimatorCockController : ICockController
  6. {
  7. private readonly Animator _animator;
  8. private const string Status = "status";
  9. private const int StatusIdle = 1;
  10. private const int StatusWalk = 2;
  11. private const int StatusRun = 3;
  12. private const int StatusIdle2 = 4;
  13. private const string TriggerAttack = "attack";
  14. private const string TriggerUnderAttack = "underattack";
  15. private const string TriggerJumpAttack = "jumpattack";
  16. private const string TriggerDie = "die";
  17. public AnimatorCockController(Animator animator)
  18. {
  19. _animator = animator;
  20. }
  21. public Action OnRun { get; set; }
  22. public Action OnIdle { get; set; }
  23. public Action OnAttack { get; set; }
  24. public Action OnJumpAttack { get; set; }
  25. public void Idle()
  26. {
  27. _animator.SetInteger(Status, StatusIdle);
  28. OnIdle?.Invoke();
  29. }
  30. public void Walk()
  31. {
  32. throw new System.NotImplementedException();
  33. }
  34. public void Run()
  35. {
  36. _animator.SetInteger(Status, StatusRun);
  37. OnRun?.Invoke();
  38. }
  39. public void IdleInBattle()
  40. {
  41. _animator.SetInteger(Status, StatusIdle2);
  42. OnIdle?.Invoke();
  43. }
  44. public void Attack()
  45. {
  46. _animator.ResetTrigger(TriggerAttack);
  47. _animator.SetTrigger(TriggerAttack);
  48. OnAttack?.Invoke();
  49. }
  50. public void JumpAndAttack()
  51. {
  52. _animator.ResetTrigger(TriggerJumpAttack);
  53. _animator.SetTrigger(TriggerJumpAttack);
  54. OnJumpAttack?.Invoke();
  55. }
  56. public void UnderAttack()
  57. {
  58. _animator.ResetTrigger(TriggerUnderAttack);
  59. _animator.SetTrigger(TriggerUnderAttack);
  60. }
  61. public void Die()
  62. {
  63. _animator.ResetTrigger(TriggerDie);
  64. _animator.SetTrigger(TriggerDie);
  65. }
  66. public void BeLift()
  67. {
  68. }
  69. }
  70. }