using System.Collections; using System.Collections.Generic; using UnityEngine; public class Skill_ManaBurst : ProjectileBase { public ProjectileHitChecker m_ProjectileHitChecker; [Header("스킬 유지 시간")] public float lifeTime = 1.2f; [Header("다단히트 간격")] public float gap = 0.1f; [Header("스킬 크기")] public Vector3 size = new Vector3(0.3f, 0.3f, 0.3f); Dictionary dic_ps = new Dictionary(); public override void Set(ProjectileData _data) { if (dic_ps.Count == 0) { var pss = GetComponentsInChildren(); for (int i = 0; i < pss.Length; i++) dic_ps.Add(pss[i], pss[i].main.duration); } _data.eStartPos = eProjectileStartPos.Custom; _data.v3_StartPos = _data.shooter.Get_PositionFoward(); base.Set(_data); transform.eulerAngles = _data.shooter.transform.eulerAngles; StartCoroutine(Co_Update()); } IEnumerator Co_Update() { var box = m_ProjectileHitChecker.Get_Collider(); box.enabled = false; var Ltime = lifeTime; if (IsStep(1)) { var addTime = Get_AwakenData(1, 1); Ltime += addTime; var pss = GetComponentsInChildren(); for (int i = 0; i < pss.Length; i++) { // Stop the ParticleSystem completely pss[i].Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); // Ensure the system has fully stopped before modifying yield return new WaitForEndOfFrame(); // Modify the main module's duration var main = pss[i].main; main.duration = dic_ps[pss[i]] + addTime; // Restart the ParticleSystem pss[i].Play(); } } else { var pss = GetComponentsInChildren(); for (int i = 0; i < pss.Length; i++) { // Stop the ParticleSystem completely pss[i].Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); // Ensure the system has fully stopped before modifying yield return new WaitForEndOfFrame(); // Modify the main module's duration var main = pss[i].main; main.duration = dic_ps[pss[i]]; // Restart the ParticleSystem pss[i].Play(); } } m_ProjectileHitChecker.transform.localScale = size + (IsStep(2) ? size * Get_AwakenData(2, 1) : Vector3.zero); var TotalGap = gap + (IsStep(3) ? Get_AwakenData(3, 1) : 0); yield return new WaitForSeconds(1f); while (Ltime > 0f) { Ltime -= TotalGap; box.enabled = true; yield return null; box.enabled = false; yield return new WaitForSeconds(TotalGap); } Off(true); } }