2026-04-07 스킬 시스템 진행중
This commit is contained in:
8
Assets/02_Scripts/Skill.meta
Normal file
8
Assets/02_Scripts/Skill.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7bbe248aa186d745a960c66ef779c16
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/02_Scripts/Skill/Data.meta
Normal file
8
Assets/02_Scripts/Skill/Data.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b956bf81ee4833341acdf7059a1d938b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -28,6 +28,9 @@ public class SkillData : ScriptableObject
|
||||
[Header("이펙트")]
|
||||
public GameObject EffectPrefab;
|
||||
|
||||
[Header("범위 지정 (AreaSelect용)")]
|
||||
public GameObject AreaIndicatorPrefab;
|
||||
|
||||
[Header("레벨별 수치")]
|
||||
public SkillLevelData[] Levels;
|
||||
|
||||
@@ -50,5 +53,5 @@ public class SkillLevelData
|
||||
}
|
||||
|
||||
public enum SkillType { Active, Passive }
|
||||
public enum ActivationType { Instant, Charge }
|
||||
public enum ActivationType { Instant, Charge, AreaSelect }
|
||||
public enum TargetType { Self, Single, Area, Projectile }
|
||||
|
||||
2
Assets/02_Scripts/Skill/Data/SkillData.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Data/SkillData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8aa8aab15385b846adf08d005daa382
|
||||
2
Assets/02_Scripts/Skill/Data/WeaponSkillSet.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Data/WeaponSkillSet.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac616ef280c255c448061b78e6e0d2d5
|
||||
8
Assets/02_Scripts/Skill/Effects.meta
Normal file
8
Assets/02_Scripts/Skill/Effects.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c055da5732c2e1d4ebf43e41d419b8dd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -22,4 +22,22 @@ public void Execute(SkillInstance skill, Transform caster, float chargeRatio)
|
||||
Debug.Log($"[범위] {hit.name}에게 {finalDamage} 데미지");
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteAtPosition(SkillInstance skill, Transform caster, Vector3 targetPos)
|
||||
{
|
||||
SkillLevelData levelData = skill.CurrentLevelData;
|
||||
|
||||
if (skill.Data.EffectPrefab != null)
|
||||
{
|
||||
Instantiate(skill.Data.EffectPrefab, targetPos, Quaternion.identity);
|
||||
}
|
||||
|
||||
Collider[] hits = Physics.OverlapSphere(targetPos, levelData.Range);
|
||||
foreach (Collider hit in hits)
|
||||
{
|
||||
if (hit.transform == caster) continue;
|
||||
|
||||
Debug.Log($"[범위지정] {hit.name}에게 {levelData.Damage} 데미지");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
Assets/02_Scripts/Skill/Effects/AreaEffect.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Effects/AreaEffect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5746059337329945a31ec9d01642e50
|
||||
2
Assets/02_Scripts/Skill/Effects/BuffEffect.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Effects/BuffEffect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20d041c01752a8c4c92afe47384dd2ee
|
||||
2
Assets/02_Scripts/Skill/Effects/DamageEffect.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Effects/DamageEffect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7bafae519de550c48a5e64ca631a8859
|
||||
2
Assets/02_Scripts/Skill/Effects/ISkillEffect.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Effects/ISkillEffect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96115cf6a2e3f694fab06c6c3c08a446
|
||||
2
Assets/02_Scripts/Skill/Effects/ProjectileEffect.cs.meta
Normal file
2
Assets/02_Scripts/Skill/Effects/ProjectileEffect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abfe13628584cc9429a5ef30dfd56f57
|
||||
2
Assets/02_Scripts/Skill/SkillInstance.cs.meta
Normal file
2
Assets/02_Scripts/Skill/SkillInstance.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0f8bfa2f5004744aad5b6585118b1ad
|
||||
@@ -1,8 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SkillManager : MonoBehaviour
|
||||
public class SkillModule : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int _maxSlots = 4;
|
||||
[SerializeField] private LayerMask _groundLayer; // 바닥 레이캐스트용
|
||||
|
||||
private PlayerStateMachine _stateMachine;
|
||||
private Animator _anim;
|
||||
@@ -11,9 +12,16 @@ public class SkillManager : MonoBehaviour
|
||||
private SkillInstance[] _equippedSkills;
|
||||
private ISkillEffect[] _skillEffects;
|
||||
|
||||
// 차지
|
||||
private int _chargingSlot = -1;
|
||||
private float _chargeTimer = 0f;
|
||||
|
||||
// 범위 지정
|
||||
private int _areaSelectSlot = -1;
|
||||
private GameObject _areaIndicator;
|
||||
|
||||
public bool IsAreaSelecting => _areaSelectSlot >= 0;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_stateMachine = GetComponent<PlayerStateMachine>();
|
||||
@@ -28,6 +36,7 @@ private void Update()
|
||||
{
|
||||
TickCooldowns();
|
||||
TickCharge();
|
||||
TickAreaSelect();
|
||||
}
|
||||
|
||||
#region 스킬 장착
|
||||
@@ -74,6 +83,13 @@ public void SkillInput(int slotIndex, InputState inputState)
|
||||
|
||||
if (inputState == InputState.Started)
|
||||
{
|
||||
// 범위 지정 중에 같은 스킬 키를 다시 누르면 취소
|
||||
if (_areaSelectSlot == slotIndex)
|
||||
{
|
||||
CancelAreaSelect();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanUseSkill(skill)) return;
|
||||
|
||||
if (skill.Data.ActivationType == ActivationType.Instant)
|
||||
@@ -84,6 +100,10 @@ public void SkillInput(int slotIndex, InputState inputState)
|
||||
{
|
||||
StartCharge(slotIndex);
|
||||
}
|
||||
else if (skill.Data.ActivationType == ActivationType.AreaSelect)
|
||||
{
|
||||
StartAreaSelect(slotIndex);
|
||||
}
|
||||
}
|
||||
else if (inputState == InputState.Canceled)
|
||||
{
|
||||
@@ -93,6 +113,19 @@ public void SkillInput(int slotIndex, InputState inputState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 범위 지정 모드 중 마우스 클릭 입력 (InputManager에서 호출)
|
||||
/// </summary>
|
||||
public void AreaConfirmInput(InputState inputState)
|
||||
{
|
||||
if (_areaSelectSlot < 0) return;
|
||||
|
||||
if (inputState == InputState.Started)
|
||||
{
|
||||
ConfirmAreaSelect();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 실행
|
||||
@@ -167,6 +200,67 @@ private void TickCharge()
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 범위 지정
|
||||
private void StartAreaSelect(int slotIndex)
|
||||
{
|
||||
_areaSelectSlot = slotIndex;
|
||||
SkillInstance skill = _equippedSkills[slotIndex];
|
||||
|
||||
if (skill.Data.AreaIndicatorPrefab != null)
|
||||
{
|
||||
_areaIndicator = Instantiate(skill.Data.AreaIndicatorPrefab);
|
||||
float range = skill.CurrentLevelData.Range;
|
||||
_areaIndicator.transform.localScale = new Vector3(range * 2f, 1f, range * 2f);
|
||||
}
|
||||
}
|
||||
|
||||
private void TickAreaSelect()
|
||||
{
|
||||
if (_areaSelectSlot < 0 || _areaIndicator == null) return;
|
||||
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, 200f, _groundLayer))
|
||||
{
|
||||
_areaIndicator.transform.position = hit.point;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfirmAreaSelect()
|
||||
{
|
||||
if (_areaSelectSlot < 0) return;
|
||||
|
||||
SkillInstance skill = _equippedSkills[_areaSelectSlot];
|
||||
ISkillEffect effect = _skillEffects[_areaSelectSlot];
|
||||
|
||||
_stateMachine.ChangeState(PlayerState.Attack);
|
||||
|
||||
if (!string.IsNullOrEmpty(skill.Data.AnimTrigger))
|
||||
_anim.SetTrigger(skill.Data.AnimTrigger);
|
||||
|
||||
Vector3 targetPos = _areaIndicator.transform.position;
|
||||
|
||||
if (effect is AreaEffect areaEffect)
|
||||
{
|
||||
areaEffect.ExecuteAtPosition(skill, _transform, targetPos);
|
||||
}
|
||||
|
||||
skill.StartCooldown();
|
||||
|
||||
Destroy(_areaIndicator);
|
||||
_areaIndicator = null;
|
||||
_areaSelectSlot = -1;
|
||||
}
|
||||
|
||||
public void CancelAreaSelect()
|
||||
{
|
||||
if (_areaIndicator != null)
|
||||
Destroy(_areaIndicator);
|
||||
|
||||
_areaIndicator = null;
|
||||
_areaSelectSlot = -1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 쿨다운
|
||||
private void TickCooldowns()
|
||||
{
|
||||
2
Assets/02_Scripts/Skill/SkillModule.cs.meta
Normal file
2
Assets/02_Scripts/Skill/SkillModule.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57617c4607df14449bbf0853cd718274
|
||||
Reference in New Issue
Block a user