1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- 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<Firearm>();
- 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;
- }
- }
- }
|