using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using KairoEngine.Core; namespace KairoEngine.CharacterSystem { /// /// Action to move a character in a certain direction and speed. /// public class CharacterUnarmedAttackAction : IAction { CharacterController character; // Reference to the character that will move Vector3 targetPosition; bool done = false; // Constructor public CharacterUnarmedAttackAction(CharacterController character, Vector3 targetPosition) { this.character = character; this.targetPosition = targetPosition; } public void Start() { if(Random.Range(0, 2) == 0) { character.animator.SetTrigger("AttackL"); character.rightUnarmedObject.SetActive(true); } else { character.animator.SetTrigger("AttackR"); character.leftUnarmedObject.SetActive(true); } GenericEvents.StartListening(character.unique_name + "-AnimationMeleeEnd", End); } public void Update() { } public void End() { done = true; GenericEvents.StopListening(character.unique_name + "-AnimationMeleeEnd", End); character.rightUnarmedObject.SetActive(false); character.leftUnarmedObject.SetActive(false); } public bool IsDone() { return done; } } }