72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
using UnityEngine.InputSystem;
|
|
|
|
[System.Serializable]
|
|
public class Weapons
|
|
{
|
|
public bool isUseable; // 공격 가능 여부
|
|
public bool isUse; // 공격중 여부
|
|
|
|
public PlayerAttacks.Types WeaponType; // 어느 무기인가?
|
|
public int WeaponLevel;
|
|
|
|
public int atkCnt; // 공격 횟수
|
|
public float WeaponDmg; // 무기 데미지
|
|
|
|
//public GameObject weaponObj;
|
|
//public string animTrigger; // 애니메이션 실행 트리거 이름
|
|
}
|
|
|
|
public class PlayerAttacks : MonoBehaviour
|
|
{
|
|
private Animator animator;
|
|
public bool IsAnyWeaponInUse => weaponInfos.Any(w => w.isUse); // 배열에 true인 값이 하나라도 있는지 확인
|
|
public Weapons[] weaponInfos;
|
|
Weapondata weaponBase;
|
|
PlayerController playerController;
|
|
|
|
[SerializeField] private GameObject nano;
|
|
[SerializeField] private GameObject tera;
|
|
|
|
public enum Types {scissor, needle, lighter};
|
|
|
|
void Start()
|
|
{
|
|
//Animator 가져오기
|
|
playerController = GetComponent<PlayerController>();
|
|
weaponBase = GetComponent<Weapondata>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public IEnumerator ableAtk(int weaponIndex, string atkType, bool isnano)
|
|
{
|
|
Debug.Log("트리거 작동");
|
|
|
|
|
|
//weaponInfos[weaponIndex].weaponObj.SetActive(true);
|
|
animator = (isnano) ? nano.GetComponent<Animator>() : tera.GetComponent<Animator>();
|
|
Debug.Log(atkType);
|
|
animator.SetTrigger(atkType);
|
|
|
|
|
|
Debug.Log($"공격 대기 시작: {weaponBase.frontdelaytime}초");
|
|
yield return new WaitForSeconds(weaponBase.frontdelaytime);
|
|
|
|
//weaponInfos[weaponIndex].weaponObj.SetActive(false);
|
|
|
|
Debug.Log($"후딜레이 대기 시작: {weaponBase.afterdelaytime}초");
|
|
yield return new WaitForSeconds(weaponBase.afterdelaytime); // 후 딜레이
|
|
|
|
weaponInfos[weaponIndex].isUse = false;
|
|
}
|
|
|
|
}
|