ZombieAttackCommand.cs 1.4 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 ZombieAttackCommand : ICommand
  8. {
  9. CharacterController character;
  10. Transform target;
  11. Vector3 targetPosition;
  12. string 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="targetPosition">The target position that the attack will hit.</param>
  18. /// <param name="varient">Use "AttackL", "AttackR" or "Attack".</param>
  19. public ZombieAttackCommand(CharacterController character, Vector3 targetPosition, string variant)
  20. {
  21. this.character = character;
  22. this.targetPosition = targetPosition;
  23. this.variant = variant;
  24. }
  25. public void Execute()
  26. {
  27. ZombieAttackAction action = new ZombieAttackAction(character, targetPosition, variant);
  28. ActionController actionController = character.GetComponent<ActionController>();
  29. if(actionController.HasAction(action) == false)
  30. {
  31. actionController.AddAction(action);
  32. }
  33. }
  34. }
  35. }