46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using UnityEngine;
|
|
|
|
public class SupporterActor : MonoBehaviour
|
|
{
|
|
public Transform tf_projectile;
|
|
public float MaxAttackCoolTime = 2f;
|
|
public int Damage = 5;
|
|
|
|
float attackCoolTime;
|
|
ProjectileData m_PD = new ProjectileData();
|
|
|
|
private void OnEnable()
|
|
{
|
|
attackCoolTime = MaxAttackCoolTime;
|
|
m_PD.ActorType = eActor.Supporter;
|
|
m_PD.Dmg = Damage;
|
|
m_PD.m_Data = table_projectile.Ins.Get_Data(3201);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
attackCoolTime -= Time.deltaTime;
|
|
if (attackCoolTime < 0)
|
|
{
|
|
attackCoolTime = MaxAttackCoolTime;
|
|
var mob = IngameMgr.Ins.FindNearestMob(transform.position, null);
|
|
if (mob != null)
|
|
{
|
|
UpdateAngle(mob.transform.position);
|
|
m_PD.tf_Start = tf_projectile;
|
|
m_PD.Ignore_WallHP = true;
|
|
ProjectileMgr.Ins.Shoot_Projectile(m_PD);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UpdateAngle(Vector2 targetWorldPos)
|
|
{
|
|
Vector2 dir = targetWorldPos - (Vector2)tf_projectile.position;
|
|
|
|
if (dir.sqrMagnitude < 0.0001f)
|
|
return;
|
|
|
|
tf_projectile.up = dir.normalized;
|
|
}
|
|
} |