OneShotOneKill/Assets/Script/InGame/Actor/SupporterActor.cs

41 lines
1.0 KiB
C#

using UnityEngine;
public class SupporterActor : MonoBehaviour
{
public float MaxAttackCoolTime = 2f;
public int Damage = 5;
float attackCoolTime;
ProjectileData m_PD = new ProjectileData();
private void OnEnable()
{
attackCoolTime = MaxAttackCoolTime;
m_PD.IsPC = true;
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);
UpdateAngle(mob.transform.position);
m_PD.tf_Start = transform;
ProjectileMgr.Ins.Shoot_Projectile(m_PD);
}
}
void UpdateAngle(Vector2 targetWorldPos)
{
Vector2 dir = targetWorldPos - (Vector2)transform.position;
if (dir.sqrMagnitude < 0.0001f)
return;
transform.up = dir.normalized;
}
}