2024-12-15 01:39:39 +00:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class MagicMissile : ProjectileBase
|
|
|
|
|
{
|
|
|
|
|
List<Actor> hitmobs = new List<Actor>();
|
|
|
|
|
int BounceCount = 0;
|
|
|
|
|
|
|
|
|
|
public override void Set(ProjectileData _data)
|
|
|
|
|
{
|
|
|
|
|
base.Set(_data);
|
|
|
|
|
hitmobs.Clear();
|
2025-01-19 21:58:12 +00:00
|
|
|
hitmobs.Add(m_ProjecTileData.target);
|
|
|
|
|
if (m_ProjecTileData.shooter.Get_SelectSkill(eEffect.Select_Bounce))
|
2024-12-15 01:39:39 +00:00
|
|
|
{
|
|
|
|
|
BounceCount = 4;
|
2025-01-19 21:58:12 +00:00
|
|
|
if (m_ProjecTileData.shooter.Get_SelectSkill(eEffect.Select_Bounce2))
|
2024-12-15 01:39:39 +00:00
|
|
|
BounceCount = 7;
|
|
|
|
|
//m_ProjectTileData.SkillDamage *= table_selectskill.Ins.Get_Data(eEffect.Select_Bounce).ValueBase;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
BounceCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
2025-01-19 21:58:12 +00:00
|
|
|
if (m_ProjecTileData.target == null)
|
2024-12-15 01:39:39 +00:00
|
|
|
{
|
|
|
|
|
Off();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_LifeTime > 0f)
|
|
|
|
|
{
|
|
|
|
|
m_LifeTime -= Time.deltaTime;
|
|
|
|
|
if (m_LifeTime <= 0f)
|
|
|
|
|
Off(true);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-19 21:58:12 +00:00
|
|
|
var targetpos = m_ProjecTileData.target.Get_Center_position();
|
|
|
|
|
transform.position = Vector3.MoveTowards(transform.position, targetpos, Time.deltaTime * m_ProjecTileData.Speed);
|
2024-12-15 01:39:39 +00:00
|
|
|
var dist = Vector3.Distance(transform.position, targetpos);
|
|
|
|
|
if (dist < 0.2f)
|
|
|
|
|
{
|
|
|
|
|
--BounceCount;
|
2025-01-19 21:58:12 +00:00
|
|
|
hitmobs.Add(m_ProjecTileData.target);
|
|
|
|
|
if (m_ProjecTileData.IsSkill())
|
|
|
|
|
m_ProjecTileData.target.Get_Damage(Get_DamageInfo());
|
2024-12-15 01:39:39 +00:00
|
|
|
else
|
2025-01-19 21:58:12 +00:00
|
|
|
m_ProjecTileData.target.Get_Damage(m_ProjecTileData.shooter.Get_DamageInfo(m_ProjecTileData, m_ProjecTileData.HitDamage));
|
2024-12-15 01:39:39 +00:00
|
|
|
|
|
|
|
|
if (BounceCount > 0)
|
|
|
|
|
{
|
|
|
|
|
var enemies = Get_Enemies().OrderBy(obj => { return Vector3.Distance(transform.position, obj.Get_position()); }).ToList();
|
|
|
|
|
for (int i = 0; i < enemies.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (hitmobs.Find(f => f == enemies[i]) == null)
|
|
|
|
|
{
|
2025-01-19 21:58:12 +00:00
|
|
|
m_ProjecTileData.target = enemies[i];
|
|
|
|
|
m_LifeTime = m_ProjecTileData.LifeTime;
|
2024-12-15 01:39:39 +00:00
|
|
|
Show_HitEffect(false, enemies[i]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Off(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|