chore: Assets 디렉토리 구조 정리 및 네이밍 컨벤션 적용

- Assets/_Game/ 하위로 게임 에셋 통합
- External/ 패키지 벤더별 분류 (Synty, Animations, UI)
- 에셋 네이밍 컨벤션 확립 및 적용
  (Data_Skill_, Data_SkillEffect_, Prefab_, Anim_, Model_, BT_ 등)
- pre-commit hook으로 네이밍 컨벤션 자동 검사 추가
- RESTRUCTURE_CHECKLIST.md 작성

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 19:08:27 +09:00
parent 309bf5f48b
commit c265f980db
17251 changed files with 2630777 additions and 206 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1401ae499769cb64c9eca36823c46714
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,37 @@
using UnityEngine;
using Colosseum.Abnormalities;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 이상 상태 효과
/// AbnormalityManager를 통해 대상에게 이상 상태를 적용합니다.
/// </summary>
[CreateAssetMenu(fileName = "AbnormalityEffect", menuName = "Colosseum/Skills/Effects/Abnormality")]
public class AbnormalityEffect : SkillEffect
{
[Header("Abnormality")]
[Tooltip("적용할 이상 상태 데이터")]
[SerializeField] private AbnormalityData abnormalityData;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (target == null) return;
if (abnormalityData == null) return;
var abnormalityManager = target.GetComponent<AbnormalityManager>();
if (abnormalityManager == null) return;
abnormalityManager.ApplyAbnormality(abnormalityData, caster);
}
/// <summary>
/// 이상 상태 데이터 설정 (런타임용)
/// </summary>
public void SetAbnormalityData(AbnormalityData data)
{
abnormalityData = data;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bf750718c64c4bd48af905d2927351de

View File

@@ -0,0 +1,92 @@
using UnityEngine;
using Colosseum.Stats;
using Colosseum.Combat;
using Colosseum.Weapons;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 대미지 타입
/// </summary>
public enum DamageType
{
Physical, // 물리 대미지 (STR 기반)
Magical, // 마법 대미지 (INT 기반)
Ranged, // 원거리 대미지 (DEX 기반)
True, // 고정 대미지 (스탯 영향 없음)
}
/// <summary>
/// 데미지 효과
/// </summary>
[CreateAssetMenu(fileName = "DamageEffect", menuName = "Colosseum/Skills/Effects/Damage")]
public class DamageEffect : SkillEffect
{
[Header("Damage Settings")]
[Min(0f)] [SerializeField] private float baseDamage = 10f;
[SerializeField] private DamageType damageType = DamageType.Physical;
[Tooltip("스탯 계수 (1.0 = 100%)")]
[Min(0f)] [SerializeField] private float statScaling = 1f;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (target == null) return;
// 대미지 계산
float totalDamage = CalculateDamage(caster);
// 타겟에 대미지 적용 (IDamageable 인터페이스 사용)
var damageable = target.GetComponent<IDamageable>();
if (damageable != null)
{
damageable.TakeDamage(totalDamage, caster);
}
}
/// <summary>
/// 시전자 스탯 기반 대미지 계산
/// 공식: baseDamage + (statDamage * scaling)
/// </summary>
private float CalculateDamage(GameObject caster)
{
if (damageType == DamageType.True)
{
return baseDamage;
}
var stats = caster.GetComponent<CharacterStats>();
if (stats == null)
{
return baseDamage;
}
float statDamage = damageType switch
{
DamageType.Physical => stats.PhysicalDamage,
DamageType.Magical => stats.MagicDamage,
DamageType.Ranged => stats.Dexterity.FinalValue * 2f, // DEX 기반 원거리 대미지
_ => 0f,
};
float baseTotal = baseDamage + (statDamage * statScaling);
// 무기 데미지 배율 적용
float damageMultiplier = GetDamageMultiplier(caster);
return baseTotal * damageMultiplier;
}
/// <summary>
/// 시전자의 무기 데미지 배율 조회
/// </summary>
private float GetDamageMultiplier(GameObject caster)
{
var weaponEquipment = caster.GetComponent<WeaponEquipment>();
if (weaponEquipment != null)
{
return weaponEquipment.DamageMultiplier;
}
return 1f;
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 58efb3c775496fa40b801b21127a011e

View File

@@ -0,0 +1,49 @@
using UnityEngine;
using Colosseum.Stats;
using Colosseum.Combat;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 치료 효과
/// </summary>
[CreateAssetMenu(fileName = "HealEffect", menuName = "Colosseum/Skills/Effects/Heal")]
public class HealEffect : SkillEffect
{
[Header("Heal Settings")]
[Min(0f)] [SerializeField] private float baseHeal = 10f;
[Tooltip("회복력 계수 (1.0 = 100%)")]
[Min(0f)] [SerializeField] private float healScaling = 1f;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (target == null) return;
// 회복량 계산
float totalHeal = CalculateHeal(caster);
// 타겟에 회복 적용 (IDamageable 인터페이스 사용)
var damageable = target.GetComponent<IDamageable>();
if (damageable != null)
{
damageable.Heal(totalHeal);
}
}
/// <summary>
/// 시전자 스탯 기반 회복량 계산
/// 공식: baseHeal + (healPower * healScaling)
/// </summary>
private float CalculateHeal(GameObject caster)
{
var stats = caster.GetComponent<CharacterStats>();
if (stats == null)
{
return baseHeal;
}
return baseHeal + (stats.HealPower * healScaling);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: abc224c01f587d447bc8df723ef522ba

View File

@@ -0,0 +1,30 @@
using UnityEngine;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 넉백 효과
/// </summary>
[CreateAssetMenu(fileName = "KnockbackEffect", menuName = "Colosseum/Skills/Effects/Knockback")]
public class KnockbackEffect : SkillEffect
{
[Header("Knockback Settings")]
[Min(0f)] [SerializeField] private float force = 5f;
[SerializeField] private float upwardForce = 2f;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (target == null || caster == null) return;
Vector3 direction = target.transform.position - caster.transform.position;
direction.y = 0f;
direction.Normalize();
Vector3 knockback = direction * force + Vector3.up * upwardForce;
// TODO: 실제 물리 시스템 연동
// if (target.TryGetComponent<Rigidbody>(out var rb))
// rb.AddForce(knockback, ForceMode.Impulse);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 27cd4e4eb6a485845953db2a108a37f8

View File

@@ -0,0 +1,22 @@
using UnityEngine;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 사운드 재생 효과
/// </summary>
[CreateAssetMenu(fileName = "SoundEffect", menuName = "Colosseum/Skills/Effects/Sound")]
public class SoundEffect : SkillEffect
{
[Header("Sound Settings")]
[SerializeField] private AudioClip clip;
[Range(0f, 1f)] [SerializeField] private float volume = 1f;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (clip == null || caster == null) return;
AudioSource.PlayClipAtPoint(clip, caster.transform.position, volume);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 052c59e9f6bf6864da0248beab125037

View File

@@ -0,0 +1,68 @@
using UnityEngine;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 프리팹 스폰 효과 (투사체, 파티클 등)
/// </summary>
[CreateAssetMenu(fileName = "SpawnEffect", menuName = "Colosseum/Skills/Effects/Spawn")]
public class SpawnEffect : SkillEffect
{
[Header("Spawn Settings")]
[SerializeField] private GameObject prefab;
[SerializeField] private SpawnLocation spawnLocation = SpawnLocation.Caster;
[SerializeField] private Vector3 spawnOffset = Vector3.zero;
[SerializeField] private bool parentToCaster = false;
[Min(0f)] [SerializeField] private float autoDestroyTime = 3f;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (prefab == null || caster == null) return;
Vector3 spawnPos = GetSpawnPosition(caster, target) + spawnOffset;
Quaternion spawnRot = GetSpawnRotation(caster, target);
Transform parent = parentToCaster ? caster.transform : null;
GameObject instance = Object.Instantiate(prefab, spawnPos, spawnRot, parent);
// SkillProjectile 컴포넌트가 있으면 초기화
var projectile = instance.GetComponent<SkillProjectile>();
if (projectile != null)
{
projectile.Initialize(caster, this);
}
if (autoDestroyTime > 0f)
{
Object.Destroy(instance, autoDestroyTime);
}
}
private Vector3 GetSpawnPosition(GameObject caster, GameObject target)
{
return spawnLocation switch
{
SpawnLocation.Caster => caster.transform.position,
SpawnLocation.CasterForward => caster.transform.position + caster.transform.forward * 2f,
SpawnLocation.Target => target != null ? target.transform.position : caster.transform.position,
_ => caster.transform.position
};
}
private Quaternion GetSpawnRotation(GameObject caster, GameObject target)
{
if (spawnLocation == SpawnLocation.Target && target != null)
{
return Quaternion.LookRotation(target.transform.position - caster.transform.position);
}
return caster.transform.rotation;
}
}
public enum SpawnLocation
{
Caster,
CasterForward,
Target
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a3139ddf07cfe324fa692a88cd565e24

View File

@@ -0,0 +1,304 @@
using UnityEngine;
using System.Collections.Generic;
namespace Colosseum.Skills
{
/// <summary>
/// 스킬 실행을 관리하는 컴포넌트.
/// 애니메이션 이벤트 기반으로 효과가 발동됩니다.
/// </summary>
public class SkillController : MonoBehaviour
{
private const string SKILL_STATE_NAME = "Skill";
private const string END_STATE_NAME = "SkillEnd";
[Header("애니메이션")]
[SerializeField] private Animator animator;
[Tooltip("기본 Animator Controller (스킬 종료 후 복원용)")]
[SerializeField] private RuntimeAnimatorController baseController;
[Tooltip("Skill 상태에 연결된 기본 클립 (Override용)")]
[SerializeField] private AnimationClip baseSkillClip;
[Header("설정")]
[SerializeField] private bool debugMode = false;
[Tooltip("공격 범위 시각화 (Scene 뷰에서 확인)")]
[SerializeField] private bool showAreaDebug = true;
[Tooltip("범위 표시 지속 시간")]
[Min(0.1f)] [SerializeField] private float debugDrawDuration = 1f;
// 현재 실행 중인 스킬
private SkillData currentSkill;
private bool skillEndRequested; // OnSkillEnd 이벤트 호출 여부
private bool waitingForEndAnimation; // EndAnimation 종료 대기 중
// 쿨타임 추적
private Dictionary<SkillData, float> cooldownTracker = new Dictionary<SkillData, float>();
public bool IsExecutingSkill => currentSkill != null && !skillEndRequested;
public bool IsPlayingAnimation => currentSkill != null;
public bool UsesRootMotion => currentSkill != null && currentSkill.UseRootMotion;
public bool IgnoreRootMotionY => currentSkill != null && currentSkill.IgnoreRootMotionY;
public SkillData CurrentSkill => currentSkill;
public Animator Animator => animator;
private void Awake()
{
if (animator == null)
{
animator = GetComponentInChildren<Animator>();
}
// 기본 컨트롤러 저장
if (baseController == null && animator != null)
{
baseController = animator.runtimeAnimatorController;
}
}
private void Update()
{
if (currentSkill == null || animator == null) return;
var stateInfo = animator.GetCurrentAnimatorStateInfo(0);
// EndAnimation 종료 감지
if (waitingForEndAnimation)
{
if (stateInfo.normalizedTime >= 1f)
{
if (debugMode) Debug.Log($"[Skill] EndAnimation complete: {currentSkill.SkillName}");
RestoreBaseController();
currentSkill = null;
}
return;
}
// 애니메이션 종료 시 처리 (OnSkillEnd 여부와 관계없이 애니메이션 끝까지 재생)
if (stateInfo.normalizedTime >= 1f)
{
if (currentSkill.EndClip != null)
{
// EndAnimation 재생 후 종료 대기
if (debugMode) Debug.Log($"[Skill] SkillAnimation done, playing EndAnimation: {currentSkill.SkillName}");
PlayEndClip(currentSkill.EndClip);
waitingForEndAnimation = true;
}
else
{
// EndAnimation 없으면 바로 종료
if (debugMode) Debug.Log($"[Skill] Animation complete: {currentSkill.SkillName}");
RestoreBaseController();
currentSkill = null;
}
}
}
/// <summary>
/// 스킬 시전
/// </summary>
public bool ExecuteSkill(SkillData skill)
{
if (skill == null)
{
Debug.LogWarning("Skill is null!");
return false;
}
// 사망 상태면 스킬 사용 불가
var damageable = GetComponent<Colosseum.Combat.IDamageable>();
if (damageable != null && damageable.IsDead)
{
if (debugMode) Debug.Log($"[Skill] Cannot execute skill - owner is dead");
return false;
}
if (IsExecutingSkill)
{
if (debugMode) Debug.Log($"Already executing skill: {currentSkill.SkillName}");
return false;
}
if (IsOnCooldown(skill))
{
if (debugMode) Debug.Log($"Skill {skill.SkillName} is on cooldown");
return false;
}
currentSkill = skill;
skillEndRequested = false;
waitingForEndAnimation = false;
if (debugMode) Debug.Log($"[Skill] Cast: {skill.SkillName}");
// 쿨타임 시작
StartCooldown(skill);
// 스킬 애니메이션 재생
if (skill.SkillClip != null && animator != null)
{
PlaySkillClip(skill.SkillClip);
}
return true;
}
/// <summary>
/// 스킬 클립으로 Override Controller 생성 후 재생
/// </summary>
private void PlaySkillClip(AnimationClip clip)
{
if (baseSkillClip == null)
{
Debug.LogError("[SkillController] Base Skill Clip is not assigned!");
return;
}
if (debugMode)
{
Debug.Log($"[Skill] PlaySkillClip: {clip.name}, BaseClip: {baseSkillClip.name}");
}
var overrideController = new AnimatorOverrideController(baseController);
overrideController[baseSkillClip] = clip;
animator.runtimeAnimatorController = overrideController;
// 애니메이터 완전 리셋 후 재생
animator.Rebind();
animator.Update(0f);
animator.Play(SKILL_STATE_NAME, 0, 0f);
}
/// <summary>
/// 종료 클립 재생
/// </summary>
private void PlayEndClip(AnimationClip clip)
{
if (baseSkillClip == null)
{
Debug.LogError("[SkillController] Base Skill Clip is not assigned!");
return;
}
var overrideController = new AnimatorOverrideController(baseController);
overrideController[baseSkillClip] = clip;
animator.runtimeAnimatorController = overrideController;
// 애니메이터 완전 리셋 후 재생
animator.Rebind();
animator.Update(0f);
animator.Play(SKILL_STATE_NAME, 0, 0f);
}
/// <summary>
/// 기본 컨트롤러로 복원
/// </summary>
private void RestoreBaseController()
{
if (animator != null && baseController != null)
{
animator.runtimeAnimatorController = baseController;
}
}
/// <summary>
/// 애니메이션 이벤트에서 호출. Effect 리스트의 index번째 효과를 발동합니다.
/// Animation Event: Function = OnEffect, Int Parameter = effect index (0-based)
/// </summary>
public void OnEffect(int index)
{
if (currentSkill == null)
{
if (debugMode) Debug.LogWarning("[Effect] No skill executing");
return;
}
// 사망 상태면 효과 발동 중단
var damageable = GetComponent<Colosseum.Combat.IDamageable>();
if (damageable != null && damageable.IsDead)
{
if (debugMode) Debug.Log($"[Effect] Cancelled - owner is dead");
return;
}
var effects = currentSkill.Effects;
if (index < 0 || index >= effects.Count)
{
if (debugMode) Debug.LogWarning($"[Effect] Invalid index: {index}");
return;
}
var effect = effects[index];
if (debugMode) Debug.Log($"[Effect] {effect.name} (index {index})");
// 공격 범위 시각화
if (showAreaDebug)
{
effect.DrawDebugRange(gameObject, debugDrawDuration);
}
effect.ExecuteOnCast(gameObject);
}
/// <summary>
/// 애니메이션 이벤트에서 호출. 스킬 종료를 요청합니다.
/// 애니메이션은 끝까지 재생된 후 종료됩니다.
/// Animation Event: Function = OnSkillEnd
/// </summary>
public void OnSkillEnd()
{
if (currentSkill == null)
{
if (debugMode) Debug.LogWarning("[SkillEnd] No skill executing");
return;
}
skillEndRequested = true;
if (debugMode) Debug.Log($"[Skill] End requested: {currentSkill.SkillName} (will complete after animation)");
}
public void CancelSkill()
{
if (currentSkill != null)
{
if (debugMode) Debug.Log($"Skill cancelled: {currentSkill.SkillName}");
RestoreBaseController();
currentSkill = null;
skillEndRequested = false;
waitingForEndAnimation = false;
}
}
public bool IsOnCooldown(SkillData skill)
{
if (!cooldownTracker.ContainsKey(skill))
return false;
return Time.time < cooldownTracker[skill];
}
public float GetRemainingCooldown(SkillData skill)
{
if (!cooldownTracker.ContainsKey(skill))
return 0f;
float remaining = cooldownTracker[skill] - Time.time;
return Mathf.Max(0f, remaining);
}
private void StartCooldown(SkillData skill)
{
cooldownTracker[skill] = Time.time + skill.Cooldown;
}
public void ResetCooldown(SkillData skill)
{
cooldownTracker.Remove(skill);
}
public void ResetAllCooldowns()
{
cooldownTracker.Clear();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 59b4feaa06ce4c74f97ed5b57ddd74d1

View File

@@ -0,0 +1,50 @@
using UnityEngine;
using System.Collections.Generic;
namespace Colosseum.Skills
{
/// <summary>
/// 스킬 데이터. 스킬의 기본 정보와 효과 목록을 관리합니다.
/// </summary>
[CreateAssetMenu(fileName = "NewSkill", menuName = "Colosseum/Skill")]
public class SkillData : ScriptableObject
{
[Header("기본 정보")]
[SerializeField] private string skillName;
[TextArea(2, 4)]
[SerializeField] private string description;
[SerializeField] private Sprite icon;
[Header("애니메이션")]
[Tooltip("기본 Animator Controller의 'Skill' 상태에 덮어씌워질 클립")]
[SerializeField] private AnimationClip skillClip;
[Tooltip("종료 애니메이션 (선택)")]
[SerializeField] private AnimationClip endClip;
[Header("루트 모션")]
[Tooltip("애니메이션의 이동/회전 데이터를 캐릭터에 적용")]
[SerializeField] private bool useRootMotion = false;
[Tooltip("루트 모션 적용 시 Y축 이동 무시 (중력과 충돌)")]
[SerializeField] private bool ignoreRootMotionY = true;
[Header("쿨타임 & 비용")]
[Min(0f)] [SerializeField] private float cooldown = 1f;
[Min(0f)] [SerializeField] private float manaCost = 0f;
[Header("효과 목록")]
[Tooltip("애니메이션 이벤트 OnEffect(index)로 발동. 리스트 순서 = 이벤트 인덱스")]
[SerializeField] private List<SkillEffect> effects = new List<SkillEffect>();
// Properties
public string SkillName => skillName;
public string Description => description;
public Sprite Icon => icon;
public AnimationClip SkillClip => skillClip;
public AnimationClip EndClip => endClip;
public float Cooldown => cooldown;
public float ManaCost => manaCost;
public bool UseRootMotion => useRootMotion;
public bool IgnoreRootMotionY => ignoreRootMotionY;
public IReadOnlyList<SkillEffect> Effects => effects;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 94f0a76cebcac2f4fb5daf1b675fd79f

View File

@@ -0,0 +1,271 @@
using System.Collections.Generic;
using UnityEngine;
using Colosseum;
using Colosseum.Weapons;
namespace Colosseum.Skills
{
/// <summary>
/// 스킬 효과의 기본 클래스.
/// 모든 효과는 이 클래스를 상속받아 구현합니다.
/// 효과 발동 타이밍은 애니메이션 이벤트(OnEffect)로 제어합니다.
/// </summary>
public abstract class SkillEffect : ScriptableObject
{
[Header("대상 설정")]
[Tooltip("Self: 시전자, Area: 범위 내 대상")]
[SerializeField] protected TargetType targetType = TargetType.Self;
[Header("Area Settings (TargetType이 Area일 때)")]
[Tooltip("범위 내에서 공격할 대상 필터")]
[SerializeField] protected TargetTeam targetTeam = TargetTeam.Enemy;
[SerializeField] protected AreaCenterType areaCenter = AreaCenterType.Caster;
[SerializeField] protected AreaShapeType areaShape = AreaShapeType.Sphere;
[SerializeField] protected LayerMask targetLayers;
[Header("Sphere Settings")]
[Min(0.1f)] [SerializeField] protected float areaRadius = 3f;
[Header("Fan Settings")]
[Tooltip("부채꼴 원점이 캐릭터로부터 떨어진 거리")]
[Min(0f)] [SerializeField] protected float fanOriginDistance = 1f;
[Tooltip("부채꼴 반지름")]
[Min(0.1f)] [SerializeField] protected float fanRadius = 3f;
[Tooltip("부채꼴 좌우 각도 (각 방향으로 이 각도만큼 벌어짐, 총 각도 = 2배)")]
[Range(0f, 180f)] [SerializeField] protected float fanHalfAngle = 45f;
// Properties
public TargetType TargetType => targetType;
public TargetTeam TargetTeam => targetTeam;
public AreaShapeType AreaShape => areaShape;
public float AreaRadius => areaRadius;
public float FanOriginDistance => fanOriginDistance;
public float FanRadius => fanRadius;
public float FanHalfAngle => fanHalfAngle;
/// <summary>
/// 스킬 시전 시 호출
/// </summary>
public void ExecuteOnCast(GameObject caster)
{
switch (targetType)
{
case TargetType.Self:
ApplyEffect(caster, caster);
break;
case TargetType.Area:
ExecuteArea(caster);
break;
}
}
/// <summary>
/// 투사체 충돌 시 호출
/// </summary>
public void ExecuteOnHit(GameObject caster, GameObject hitTarget)
{
if (IsValidTarget(caster, hitTarget))
{
ApplyEffect(caster, hitTarget);
}
}
/// <summary>
/// 실제 효과 적용 (상속받은 클래스에서 구현)
/// </summary>
protected abstract void ApplyEffect(GameObject caster, GameObject target);
/// <summary>
/// 충돌한 대상이 유효한 타겟인지 확인
/// </summary>
public bool IsValidTarget(GameObject caster, GameObject target)
{
if (target == null) return false;
// 레이어 체크
if (targetLayers.value != 0 && (targetLayers.value & (1 << target.layer)) == 0)
return false;
// 팀 체크
return IsCorrectTeam(caster, target);
}
private bool IsCorrectTeam(GameObject caster, GameObject target)
{
bool isSameTeam = Team.IsSameTeam(caster, target);
return targetTeam switch
{
TargetTeam.Enemy => !isSameTeam,
TargetTeam.Ally => isSameTeam,
TargetTeam.All => true,
_ => true
};
}
private void ExecuteArea(GameObject caster)
{
Vector3 center = GetAreaCenter(caster);
Collider[] hits = Physics.OverlapSphere(center, Mathf.Max(areaRadius, fanRadius), targetLayers);
// 같은 GameObject가 여러 콜라이더를 가질 수 있으므로 중복 제거
HashSet<GameObject> processedTargets = new HashSet<GameObject>();
foreach (var hit in hits)
{
if (hit.gameObject == caster) continue;
if (!IsCorrectTeam(caster, hit.gameObject)) continue;
if (processedTargets.Contains(hit.gameObject)) continue;
// 부채꼴 판정
if (areaShape == AreaShapeType.Fan)
{
if (!IsInFanShape(caster, hit.transform.position))
continue;
}
processedTargets.Add(hit.gameObject);
ApplyEffect(caster, hit.gameObject);
}
}
/// <summary>
/// 타겟이 부채꼴 범위 내에 있는지 확인
/// </summary>
private bool IsInFanShape(GameObject caster, Vector3 targetPosition)
{
Vector3 casterPos = caster.transform.position;
Vector3 casterForward = caster.transform.forward;
// 부채꼴 원점 계산
Vector3 fanOrigin = casterPos + casterForward * fanOriginDistance;
// 원점에서 타겟까지의 방향과 거리
Vector3 toTarget = targetPosition - fanOrigin;
float distance = toTarget.magnitude;
// 거리 체크
if (distance > fanRadius)
return false;
// 각도 체크 (Y축 무시)
Vector3 toTargetFlat = new Vector3(toTarget.x, 0f, toTarget.z).normalized;
Vector3 casterForwardFlat = new Vector3(casterForward.x, 0f, casterForward.z).normalized;
float angle = Vector3.Angle(casterForwardFlat, toTargetFlat);
return angle <= fanHalfAngle;
}
private Vector3 GetAreaCenter(GameObject caster)
{
if (caster == null) return Vector3.zero;
return areaCenter switch
{
AreaCenterType.Caster => caster.transform.position,
AreaCenterType.CasterForward => caster.transform.position + caster.transform.forward * areaRadius,
_ => caster.transform.position
};
}
#region Debug Visualization
/// <summary>
/// 공격 범위 시각화 (런타임 디버그용)
/// </summary>
public void DrawDebugRange(GameObject caster, float duration = 1f)
{
if (targetType != TargetType.Area) return;
Vector3 casterPos = caster.transform.position;
Vector3 forward = caster.transform.forward;
if (areaShape == AreaShapeType.Sphere)
{
Vector3 center = GetAreaCenter(caster);
DebugDrawSphere(center, areaRadius, Color.red, duration);
}
else if (areaShape == AreaShapeType.Fan)
{
DebugDrawFan(casterPos, forward, fanOriginDistance, fanRadius, fanHalfAngle, Color.red, duration);
}
}
private void DebugDrawSphere(Vector3 center, float radius, Color color, float duration)
{
int segments = 32;
float step = 360f / segments;
// XZ 평면 원
Vector3 prevPoint = center + new Vector3(radius, 0, 0);
for (int i = 1; i <= segments; i++)
{
float angle = i * step * Mathf.Deg2Rad;
Vector3 newPoint = center + new Vector3(Mathf.Cos(angle) * radius, 0, Mathf.Sin(angle) * radius);
Debug.DrawLine(prevPoint, newPoint, color, duration);
prevPoint = newPoint;
}
// 수직선 (높이 표시)
Debug.DrawLine(center + Vector3.up * 0.1f, center + Vector3.up * 2f, color, duration);
}
private void DebugDrawFan(Vector3 casterPos, Vector3 forward, float originDistance, float radius, float halfAngle, Color color, float duration)
{
Vector3 fanOrigin = casterPos + forward * originDistance;
Vector3 forwardFlat = new Vector3(forward.x, 0f, forward.z).normalized;
// 부채꼴의 양끝 방향 계산
Quaternion leftRot = Quaternion.Euler(0, -halfAngle, 0);
Quaternion rightRot = Quaternion.Euler(0, halfAngle, 0);
Vector3 leftDir = leftRot * forwardFlat;
Vector3 rightDir = rightRot * forwardFlat;
// 부채꼴 호 그리기
int arcSegments = Mathf.Max(8, Mathf.CeilToInt(halfAngle * 2 / 5f)); // 5도당 1세그먼트
Vector3 prevPoint = fanOrigin + leftDir * radius;
for (int i = 1; i <= arcSegments; i++)
{
float t = (float)i / arcSegments;
float angle = -halfAngle + t * halfAngle * 2;
Quaternion rot = Quaternion.Euler(0, angle, 0);
Vector3 dir = rot * forwardFlat;
Vector3 newPoint = fanOrigin + dir * radius;
Debug.DrawLine(prevPoint, newPoint, color, duration);
prevPoint = newPoint;
}
// 부채꼴 경계선
Debug.DrawLine(fanOrigin, fanOrigin + leftDir * radius, color, duration);
Debug.DrawLine(fanOrigin, fanOrigin + rightDir * radius, color, duration);
// 원점 표시
Debug.DrawLine(fanOrigin + Vector3.up * 0.1f, fanOrigin + Vector3.up * 1.5f, color, duration);
}
#endregion
}
public enum TargetType
{
Self,
Area
}
public enum TargetTeam
{
Enemy,
Ally,
All
}
public enum AreaCenterType
{
Caster,
CasterForward
}
public enum AreaShapeType
{
Sphere, // 원형 범위
Fan // 부채꼴 범위
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bd8fab5faadbfff49ae5117890787807

View File

@@ -0,0 +1,89 @@
using UnityEngine;
namespace Colosseum.Skills
{
/// <summary>
/// 스킬 투사체. 충돌 시 연결된 효과를 적용합니다.
/// </summary>
[RequireComponent(typeof(Rigidbody))]
public class SkillProjectile : MonoBehaviour
{
[Header("이동 설정")]
[Min(0f)] [SerializeField] private float speed = 15f;
[Min(0f)] [SerializeField] private float lifetime = 5f;
[Header("관통 설정")]
[SerializeField] private bool penetrate = false;
[SerializeField] private int maxPenetration = 1;
[Header("충돌 이펙트")]
[SerializeField] private GameObject hitEffect;
[SerializeField] private float hitEffectDuration = 2f;
private GameObject caster;
private SkillEffect sourceEffect;
private int penetrationCount;
private Rigidbody rb;
private bool initialized;
/// <summary>
/// 투사체 초기화
/// </summary>
public void Initialize(GameObject caster, SkillEffect sourceEffect)
{
this.caster = caster;
this.sourceEffect = sourceEffect;
initialized = true;
rb = GetComponent<Rigidbody>();
if (rb != null)
{
rb.useGravity = false;
rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
}
}
private void Start()
{
Destroy(gameObject, lifetime);
}
private void FixedUpdate()
{
if (!initialized || rb == null) return;
rb.linearVelocity = transform.forward * speed;
}
private void OnTriggerEnter(Collider other)
{
if (!initialized || sourceEffect == null) return;
if (other.gameObject == caster) return;
// 유효한 타겟인지 확인
if (!sourceEffect.IsValidTarget(caster, other.gameObject))
return;
// 충돌 이펙트
if (hitEffect != null)
{
var effect = Instantiate(hitEffect, transform.position, transform.rotation);
Destroy(effect, hitEffectDuration);
}
// 효과 적용
sourceEffect.ExecuteOnHit(caster, other.gameObject);
penetrationCount++;
if (!penetrate || penetrationCount >= maxPenetration)
{
Destroy(gameObject);
}
}
public void SetDirection(Vector3 direction)
{
transform.rotation = Quaternion.LookRotation(direction.normalized);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6e2a203fbf7bc39449b13bec67e94150