Project_WL/Assets/Script/Character/Projectile/Skill/Skill_ManaBurst.cs

95 lines
3.0 KiB
C#
Raw Normal View History

2024-12-15 01:39:39 +00:00
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<ParticleSystem, float> dic_ps = new Dictionary<ParticleSystem, float>();
public override void Set(ProjectileData _data)
{
if (dic_ps.Count == 0)
{
var pss = GetComponentsInChildren<ParticleSystem>();
for (int i = 0; i < pss.Length; i++)
dic_ps.Add(pss[i], pss[i].main.duration);
}
2024-12-18 01:22:39 +00:00
_data.eStartPos = eProjectileStartPos.Custom;
_data.v3_StartPos = _data.shooter.Get_PositionFoward();
2024-12-15 01:39:39 +00:00
base.Set(_data);
2024-12-18 01:22:39 +00:00
transform.eulerAngles = _data.shooter.transform.eulerAngles;
2024-12-15 01:39:39 +00:00
StartCoroutine(Co_Update());
}
IEnumerator Co_Update()
{
var box = m_ProjectileHitChecker.Get_Collider();
2024-12-18 01:22:39 +00:00
box.enabled = false;
2024-12-15 01:39:39 +00:00
var Ltime = lifeTime;
if (IsStep(1))
{
var addTime = Get_AwakenData(1, 1);
Ltime += addTime;
var pss = GetComponentsInChildren<ParticleSystem>();
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<ParticleSystem>();
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);
2024-12-18 01:22:39 +00:00
yield return new WaitForSeconds(1f);
2024-12-15 01:39:39 +00:00
while (Ltime > 0f)
{
Ltime -= TotalGap;
box.enabled = true;
yield return null;
box.enabled = false;
2025-05-12 01:47:18 +00:00
yield return new WaitForSeconds(TotalGap);
2024-12-15 01:39:39 +00:00
}
Off(true);
}
}