CharacterHandWeaponAttackCommand.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.Core;
  5. namespace KairoEngine.CharacterSystem
  6. {
  7. public class CharacterHandWeaponAttackCommand : ICommand
  8. {
  9. CharacterController character;
  10. Vector3 targetPosition;
  11. /// <summary>
  12. /// Command that creates an unarmed attack action.
  13. /// </summary>
  14. /// <param name="character">The target character to perform the action.</param>
  15. /// <param name="targetPosition">The target position where the attack will be performed.</param>
  16. public CharacterHandWeaponAttackCommand(CharacterController character, Vector3 targetPosition)
  17. {
  18. this.character = character;
  19. this.targetPosition = targetPosition;
  20. }
  21. public void Execute()
  22. {
  23. CharacterHandWeaponAttackAction action = new CharacterHandWeaponAttackAction(character, targetPosition);
  24. ActionController actionController = character.GetComponent<ActionController>();
  25. if(actionController.HasAction(action) == false)
  26. {
  27. actionController.AddAction(action);
  28. }
  29. }
  30. }
  31. }