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

67 lines
2.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Skill_EnergyBall : ProjectileBase
{
[Header("에너지볼 프리팹")]
public GameObject go_projectile;
[Header("에너지볼 생성 갯수")]
public int amount = 5;
[Header("에너지볼 생성 간격")]
public float gapTime = 0.1f;
List<Transform> list_energyball = new List<Transform>();
public override void Set(ProjectileData _data)
{
_data.eStartPos = eProjectileStartPos.Custom;
_data.v3_StartPos = _data.shooter.Get_Center_position();
base.Set(_data);
StartCoroutine(Co_Shoot());
}
IEnumerator Co_Shoot()
{
var count = amount;
if (IsStep(1)) count += (int)Get_AwakenData(1, 1);
if (IsStep(2)) count += (int)Get_AwakenData(2, 1);
if (IsStep(3)) count += (int)Get_AwakenData(3, 1);
if (list_energyball.Count < count)
{
int additionalCount = count - list_energyball.Count;
for (int i = 0; i < additionalCount; i++)
{
var temp = DSUtil.Get_Clone(go_projectile, transform);
list_energyball.Add(temp.transform);
}
}
Set_Checkers();
float angleStep = 360f / list_energyball.Count;
for (int i = 0; i < list_energyball.Count; i++)
{
float angle = i * angleStep;
list_energyball[i].eulerAngles = new Vector3(0f, angle, 0f); // 방사형으로 회전 적용
list_energyball[i].gameObject.SetActive(false);
list_energyball[i].localPosition = Vector3.zero;
}
for (int i = 0; i < count; i++)
list_energyball[i].gameObject.SetActive(true);
// 에너지볼 이동
while (m_LifeTime > 0f)
{
if (DSUtil.CheckNull(m_ProjectTileData.shooter)) break;
for (int i = 0; i < count; i++)
list_energyball[i].Translate(m_ProjectTileData.Speed * Time.deltaTime * list_energyball[i].forward);
m_LifeTime -= Time.deltaTime;
yield return null;
}
Off();
}
}