1. 공격 스크립트를 만듬 - 플레이어 -> 적 공격 테스트 (성공) - 적 -> 플레이어 공격 테스트 (성공) Todo 1. 카메라 컨트롤러는 이거 방법 아예 따로 찾아야 할거 같음 2. 공격 스크립트 (시도) - 투사체 공격 (시작해야 함) - 공격 관련 무기 스테이터스 같은거 생각해야 함 - 몬스터 AI라던가 설정 또는 이동과 관련된것도 생각해야 함 - 공격 받았을 경우 처리는 어떻게 할건지 고민을 해야 함
80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
// using UnityEngine;
|
|
//
|
|
// public interface IDamageable
|
|
// {
|
|
// void TakeDamage(int amount, Vector3 hitPoint, Vector3 hitNormal, GameObject attacker);
|
|
// }
|
|
//
|
|
//
|
|
//
|
|
// public abstract class Weapon : MonoBehaviour
|
|
// {
|
|
// [Header("Base Stats")]
|
|
// [SerializeField] protected int baseDamage = 5;
|
|
// [SerializeField] protected LayerMask hitMask;
|
|
// // [SerializeField] protected Weapon_Damage weaponDamage; // 동일 오브젝트나 자식에 부착
|
|
// [SerializeField] protected bool autoFindDamageComponent = true;
|
|
//
|
|
// protected PlayerController owner;
|
|
// protected Status_Player ownerStatus; // 공격력 배율 등
|
|
// protected bool initialized;
|
|
//
|
|
// public virtual void Initialize(PlayerController owner, Status_Player status)
|
|
// {
|
|
// this.owner = owner;
|
|
// ownerStatus = status;
|
|
//
|
|
// if (autoFindDamageComponent && weaponDamage == null)
|
|
// weaponDamage = GetComponentInChildren<Weapon_Damage>(true);
|
|
//
|
|
// if (weaponDamage != null)
|
|
// weaponDamage.Init(this, hitMask);
|
|
//
|
|
// initialized = true;
|
|
// }
|
|
//
|
|
// // 애니메이션 이벤트에서 호출
|
|
// public void AttackEnableHit()
|
|
// {
|
|
// if (weaponDamage != null) weaponDamage.EnableHit();
|
|
// OnAttackWindowOpened();
|
|
// }
|
|
//
|
|
// // 애니메이션 이벤트에서 호출
|
|
// public void AttackDisableHit()
|
|
// {
|
|
// if (weaponDamage != null) weaponDamage.DisableHit();
|
|
// OnAttackWindowClosed();
|
|
// }
|
|
//
|
|
// // WeaponDamage -> OnTriggerEnter -> 여기로 집결
|
|
// public void HandleHit(IDamageable target, Vector3 hitPoint, Vector3 hitNormal, GameObject targetGO)
|
|
// {
|
|
// int dmg = ComputeFinalDamage();
|
|
// OnPreApplyDamage(target, ref dmg, hitPoint, hitNormal);
|
|
// target.TakeDamage(dmg, hitPoint, hitNormal, owner != null ? owner.gameObject : gameObject);
|
|
// OnPostApplyDamage(target, dmg, hitPoint, hitNormal);
|
|
// }
|
|
//
|
|
// protected virtual int ComputeFinalDamage()
|
|
// {
|
|
// float statMul = 1f;
|
|
// if (ownerStatus != null)
|
|
// statMul = ownerStatus.Atk; // 외부 스탯 곱
|
|
// int dmg = Mathf.RoundToInt(baseDamage * statMul);
|
|
// dmg = Mathf.Max(1, dmg);
|
|
// return ModifyDamage(dmg);
|
|
// }
|
|
//
|
|
// // 자식에서 수치 커스터마이즈
|
|
// protected virtual int ModifyDamage(int current) => current;
|
|
//
|
|
// // 공격 판정 구간 열림/닫힘 훅
|
|
// protected virtual void OnAttackWindowOpened() { }
|
|
// protected virtual void OnAttackWindowClosed() { }
|
|
//
|
|
// // 실제 데미지 적용 직전/직후 훅
|
|
// protected virtual void OnPreApplyDamage(IDamageable target, ref int damage, Vector3 point, Vector3 normal) { }
|
|
// protected virtual void OnPostApplyDamage(IDamageable target, int damage, Vector3 point, Vector3 normal) { }
|
|
// }
|