using System.Collections; using System.Collections.Generic; using UnityEngine; using KairoEngine.Core; using KairoEngine.Inventory; namespace KairoEngine.CharacterSystem { public class CharacterShootAction : IAction { CharacterController character; Firearm firearm; bool isDone = false; // Constructor public CharacterShootAction(CharacterController character) { this.character = character; } public void Start() { if(character.HasEquipedItem() == false) return; if(character.GetEquipedItem().item.category != ItemType.firearm) return; firearm = character.GetEquipedGameObject().GetComponent(); ItemBaseFirearm weaponItem = (ItemBaseFirearm)firearm.itemFirearmRef.item; if(weaponItem.firearmType == FirearmType.pistol) character.animator.SetBool("Pistol", true); else character.animator.SetBool("Pistol", false); if(firearm.isReady) { firearm.Fire(); if(firearm.itemFirearmRef.ammo > 0) character.animator.SetTrigger("Attack"); isDone = true; } } public void Update() { if(firearm.isReady && !isDone) { firearm.Fire(); isDone = true; } } public void End() { } public bool IsDone() { return isDone; } } }