AnimatorMasterController.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using UnityEngine;
  3. namespace Game
  4. {
  5. public class AnimatorMasterController : IMasterController
  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 StatusLift = 3;
  12. private const int StatusPutDown = 4;
  13. private const string TriggerPutDown = "putdown";
  14. public AnimatorMasterController(Animator animator)
  15. {
  16. _animator = animator;
  17. }
  18. public Action OnRun { get; set; }
  19. public Action OnWalk { get; set; }
  20. public Action OnIdle { get; set; }
  21. public Action OnPutDown { get; set; }
  22. public void Idle()
  23. {
  24. _animator.SetInteger(Status, StatusIdle);
  25. OnIdle?.Invoke();
  26. }
  27. public void Walk()
  28. {
  29. _animator.SetInteger(Status, StatusWalk);
  30. OnWalk?.Invoke();
  31. }
  32. public void Lift()
  33. {
  34. _animator.SetInteger(Status, StatusLift);
  35. }
  36. public void LiftAndWalk()
  37. {
  38. }
  39. public void PutDown()
  40. {
  41. _animator.SetTrigger(TriggerPutDown);
  42. OnPutDown?.Invoke();
  43. }
  44. }
  45. }