mycj_demo/mycj/Assets/Game/Scripts/Application/Object/FBFanBullet.cs

88 lines
2.4 KiB
C#
Raw Normal View History

2024-12-02 09:37:47 +08:00
// Felix-BangFBFanBullet
//   へ     /|
//  /7    ∠_/
//  / │    
//  Z _,    /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │
//  / へ   / ノ<|
//  ヽ_ノ  (_  │//
//  7       |
//  ―r ̄ ̄`ー―_
// Describe扇形子弹
// Createtime2018/10/19
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace FBApplication
{
public class FBFanBullet : FBBullet
{
#region
//旋转速度(度/秒)
public float RotateSpeed = 180f;
#endregion
#region
public Vector2 Direction { get; private set; }
#endregion
#region Unity回调
protected override void Update()
{
//已爆炸跳过
if (f_isExploded)
return;
//移动
transform.Translate(Direction * Speed * Time.deltaTime, Space.World);
//旋转
transform.Rotate(Vector3.forward, RotateSpeed * Time.deltaTime, Space.World);
//检测(存活/死亡)
GameObject[] monsterObjects = GameObject.FindGameObjectsWithTag("Monster");
foreach (GameObject monsterObject in monsterObjects)
{
FBMonster monster = monsterObject.GetComponent<FBMonster>();
//忽略已死亡的怪物
if (monster.IsDead)
continue;
if (Vector3.Distance(transform.position, monster.transform.position) <= FBConsts.RangeClosedDistance)
{
//敌人受伤
monster.Damage(this.Attack);
//爆炸
Explode();
//退出(重点)
break;
}
}
//边间检测
if (!f_isExploded && !MapRect.Contains(transform.position))
Explode();
}
#endregion
#region
public void Load(int bulletID,int level,Rect mapRect,Vector3 direction)
{
Load(bulletID, level, mapRect);
Direction = direction;
}
#endregion
}
}