스킬 시스템 구현
- 애니메이션 이벤트 기반 스킬 시스템 추가 - 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:
89
Assets/Scripts/Skills/SkillProjectile.cs
Normal file
89
Assets/Scripts/Skills/SkillProjectile.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user