스킬 시스템 구현

- 애니메이션 이벤트 기반 스킬 시스템 추가
  - SkillData: 스킬 데이터 (클립, 쿨타임, 효과 목록)
  - SkillController: 스킬 실행 및 애니메이션 제어
  - AnimatorOverrideController로 단일 State에서 다양한 스킬 재생

- 스킬 효과 시스템
  - DamageEffect, HealEffect, BuffEffect
  - KnockbackEffect, SoundEffect, SpawnEffect
  - 범위 공격 및 팀 구분 지원

- Team 컴포넌트로 아군/적 구분

- 스킬 중 이동 제한
  - IsPlayingAnimation으로 애니메이션 종료까지 이동 불가
  - OnSkillEnd 호출 시 다음 스킬 시전 가능

- 입력 시스템에 스킬 슬롯 6개 추가

- 애니메이션 에셋 추가 및 정리
  - AnimationSwordCombat 패키지 추가 (검 공격 애니메이션)
  - PlayerAnimationController에 Skill 상태 추가
  - External_Used 폴더 구조 정리

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 12:08:52 +09:00
parent 86903a09f0
commit eff23471d7
719 changed files with 485114 additions and 756 deletions

View File

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

View File

@@ -0,0 +1,32 @@
using UnityEngine;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 버프/디버프 효과
/// </summary>
[CreateAssetMenu(fileName = "BuffEffect", menuName = "Colosseum/Skills/Effects/Buff")]
public class BuffEffect : SkillEffect
{
[Header("Buff Settings")]
[SerializeField] private string buffName = "Buff";
[Min(0f)] [SerializeField] private float duration = 5f;
[Header("Stat Modifiers")]
[Range(0f, 10f)] [SerializeField] private float moveSpeedMultiplier = 1f;
[Range(0f, 10f)] [SerializeField] private float attackPowerMultiplier = 1f;
[Range(0f, 10f)] [SerializeField] private float defenseMultiplier = 1f;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (target == null) return;
// TODO: 실제 버프 시스템 연동
// var buffSystem = target.GetComponent<BuffSystem>();
// buffSystem?.ApplyBuff(new BuffData(buffName, duration, moveSpeedMultiplier, attackPowerMultiplier, defenseMultiplier));
Debug.Log($"[Buff] {buffName} on {target.name} for {duration}s " +
$"(Speed: {moveSpeedMultiplier}x, ATK: {attackPowerMultiplier}x, DEF: {defenseMultiplier}x)");
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 32bab3b586da0d7469f63e03f18ee29f

View File

@@ -0,0 +1,26 @@
using UnityEngine;
namespace Colosseum.Skills.Effects
{
/// <summary>
/// 데미지 효과
/// </summary>
[CreateAssetMenu(fileName = "DamageEffect", menuName = "Colosseum/Skills/Effects/Damage")]
public class DamageEffect : SkillEffect
{
[Header("Damage Settings")]
[Min(0f)] [SerializeField] private float damageAmount = 10f;
[SerializeField] private string damageType = "Physical";
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (target == null) return;
// TODO: 실제 데미지 시스템 연동
// var health = target.GetComponent<Health>();
// health?.TakeDamage(damageAmount, caster, damageType);
Debug.Log($"[Damage] {caster.name} -> {target.name}: {damageAmount} ({damageType})");
}
}
}

View File

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

View File

@@ -0,0 +1,25 @@
using UnityEngine;
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 healAmount = 10f;
protected override void ApplyEffect(GameObject caster, GameObject target)
{
if (target == null) return;
// TODO: 실제 체력 시스템 연동
// var health = target.GetComponent<Health>();
// health?.Heal(healAmount);
Debug.Log($"[Heal] {caster.name} -> {target.name}: {healAmount}");
}
}
}

View File

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

View File

@@ -0,0 +1,32 @@
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);
Debug.Log($"[Knockback] {target.name}: {knockback}");
}
}
}

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,272 @@
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;
// 현재 실행 중인 스킬
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 SkillData CurrentSkill => currentSkill;
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);
if (debugMode)
{
Debug.Log($"[Skill] State: {stateInfo.shortNameHash}, NormalizedTime: {stateInfo.normalizedTime:F2}, IsSkill: {stateInfo.IsName(SKILL_STATE_NAME)}");
}
// 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;
}
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.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.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 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})");
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,42 @@
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("쿨타임 & 비용")]
[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 IReadOnlyList<SkillEffect> Effects => effects;
}
}

View File

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

View File

@@ -0,0 +1,134 @@
using UnityEngine;
using Colosseum;
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;
[Min(0.1f)] [SerializeField] protected float areaRadius = 3f;
[SerializeField] protected LayerMask targetLayers;
// Properties
public TargetType TargetType => targetType;
public TargetTeam TargetTeam => targetTeam;
/// <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, areaRadius, targetLayers);
foreach (var hit in hits)
{
if (hit.gameObject == caster) continue;
if (!IsCorrectTeam(caster, hit.gameObject)) continue;
ApplyEffect(caster, hit.gameObject);
}
}
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
};
}
}
public enum TargetType
{
Self,
Area
}
public enum TargetTeam
{
Enemy,
Ally,
All
}
public enum AreaCenterType
{
Caster,
CasterForward
}
}

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