Files
Colosseum/Assets/_Game/Scripts/Skills/Effects/SpawnEffect.cs
dal4segno c265f980db 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>
2026-03-16 19:08:27 +09:00

69 lines
2.4 KiB
C#

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
}
}