Files
FutureMen2/Assets/_FutureMen2/Scripts/Weapons/EnemyBullet/BossBullet.cs
2026-01-05 11:00:50 +08:00

37 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using DragonLi.Frame;
using UnityEngine;
public class BossBullet : EnemyBullet
{
public bool isRotate;
private Vector3 direction;
private float speed;
public void SetTarget(Vector3 targetPos, float bulletSpeed)
{
direction = (targetPos - transform.position).normalized;
speed = bulletSpeed;
transform.rotation = Quaternion.LookRotation(direction); // 让子弹面朝方向
}
public override void Update()
{
base.Update();
transform.position += direction * speed * Time.deltaTime;
}
internal override void FixedUpdate()
{
base.FixedUpdate();
float sqrDist = (transform.position - GameManager.Ins.player.transform.position).sqrMagnitude;
if (sqrDist <= 1 * 1)
{
int randomDamage = GetDamage(out var isCriticalHit);
GameManager.Ins.player.GetComponent<IDamagable>().ApplyDamage(randomDamage, isCriticalHit, transform);
}
}
}