ZombieFollowTargetCommand.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.Core;
  5. namespace KairoEngine.CharacterSystem
  6. {
  7. public class ZombieFollowTargetCommand : ICommand
  8. {
  9. CharacterController character;
  10. Transform target;
  11. float targetDistance;
  12. int variant;
  13. /// <summary>
  14. /// Command that creates an action that will make a character follow a target playing a zombie animation.
  15. /// </summary>
  16. /// <param name="character">The CharacterController performing the action</param>
  17. /// <param name="target">The target Transform to be followed</param>
  18. /// <param name="targetDistance">Stop following when this distance is reached</param>
  19. /// <param name="varient">Type of zombie animation to play. 1 to 7 are walk animations and 8 to 9 are run animations</param>
  20. public ZombieFollowTargetCommand(CharacterController character, Transform target, float targetDistance, int variant)
  21. {
  22. this.character = character;
  23. this.target = target;
  24. this.targetDistance = targetDistance;
  25. this.variant = variant;
  26. }
  27. public void Execute()
  28. {
  29. ZombieFollowTargetAction action = new ZombieFollowTargetAction(character, target, targetDistance, variant);
  30. ActionController actionController = character.GetComponent<ActionController>();
  31. if(actionController.HasAction(action) == false)
  32. {
  33. actionController.AddAction(action);
  34. }
  35. }
  36. }
  37. }