MoveCommand.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.Core;
  5. namespace KairoEngine.CharacterSystem
  6. {
  7. public class MoveCommand : ICommand
  8. {
  9. CharacterController character;
  10. Vector2 direction;
  11. Vector2 lookDirection;
  12. float speed;
  13. public MoveCommand(CharacterController character, Vector2 direction, Vector2 lookDirection, float speed)
  14. {
  15. this.character = character;
  16. this.direction = direction;
  17. this.lookDirection = lookDirection;
  18. this.speed = speed;
  19. }
  20. public void Execute()
  21. {
  22. CharacterMoveAction action = new CharacterMoveAction(character, direction, lookDirection, speed);
  23. ActionController actionController = character.GetComponent<ActionController>();
  24. if(actionController.HasAction(action) == false)
  25. {
  26. actionController.AddAction(action);
  27. }
  28. else
  29. {
  30. actionController.ChangeAction(action);
  31. }
  32. }
  33. }
  34. }