123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Events;
- using KairoEngine.Core;
- namespace KairoEngine.CharacterSystem
- {
- /// <summary>
- /// Action to move a character in a certain direction and speed.
- /// </summary>
- 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;
- }
- }
- }
|