整理武器配置和重构
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// 闪电的瞄准状态。
|
||||
/// </summary>
|
||||
public sealed class WeaponLightningAimState : WeaponStateBase
|
||||
{
|
||||
private WeaponLightning _weapon;
|
||||
|
||||
public override WeaponStateType State => WeaponStateType.Aim;
|
||||
|
||||
public override void OnInit(WeaponBase weapon) => _weapon = (WeaponLightning)weapon;
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
if (_weapon.CanAttack)
|
||||
{
|
||||
_weapon.TransitionTo(WeaponStateType.Attack);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
_weapon.Check();
|
||||
_weapon.RotateToTarget(elapseSeconds);
|
||||
|
||||
if (_weapon.Target == null || !_weapon.Target.Available)
|
||||
{
|
||||
_weapon.TransitionTo(WeaponStateType.Idle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_weapon.IsInRange(_weapon.Target, _weapon.SqrRange))
|
||||
{
|
||||
_weapon.TransitionTo(WeaponStateType.Seek);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_weapon.CanAttack)
|
||||
{
|
||||
_weapon.TransitionTo(WeaponStateType.Attack);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLeave()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user