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:
89
Assets/_Game/Scripts/Skills/SkillProjectile.cs
Normal file
89
Assets/_Game/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