129 lines
3.9 KiB
C#
129 lines
3.9 KiB
C#
using System;
|
|
using ActiveProtect.SimulationEnvironment;
|
|
|
|
namespace ActiveProtect.Models
|
|
{
|
|
/// <summary>
|
|
/// 毫米波末制导导弹
|
|
/// </summary>
|
|
public class MillimeterWaveTerminalGuidedMissile : MissileBase
|
|
{
|
|
/// <summary>
|
|
/// 毫米波末制导导弹阶段
|
|
/// </summary>
|
|
private enum MWTG_Stage
|
|
{
|
|
Launch,
|
|
Cruise,
|
|
TerminalGuidance,
|
|
Explode,
|
|
SelfDestruct
|
|
}
|
|
|
|
private MWTG_Stage currentStage;
|
|
private readonly MillimeterWaveGuidanceSystem guidanceSystem;
|
|
private const double TERMINAL_GUIDANCE_DISTANCE = 8000; // 末制导开始距离(米)
|
|
|
|
/// <summary>
|
|
/// 毫米波末制导导弹构造函数
|
|
/// </summary>
|
|
public MillimeterWaveTerminalGuidedMissile(MissileConfig config, ISimulationManager manager)
|
|
: base(config, manager)
|
|
{
|
|
Type = MissileType.MillimeterWaveTerminalGuidance;
|
|
currentStage = MWTG_Stage.Launch;
|
|
guidanceSystem = new MillimeterWaveGuidanceSystem(config.MaxAcceleration, config.ProportionalNavigationCoefficient, manager);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新毫米波末制导导弹
|
|
/// </summary>
|
|
public override void Update(double deltaTime)
|
|
{
|
|
base.Update(deltaTime);
|
|
|
|
switch (currentStage)
|
|
{
|
|
case MWTG_Stage.Launch:
|
|
UpdateLaunchStage(deltaTime);
|
|
break;
|
|
case MWTG_Stage.Cruise:
|
|
UpdateCruiseStage(deltaTime);
|
|
break;
|
|
case MWTG_Stage.TerminalGuidance:
|
|
UpdateTerminalGuidanceStage(deltaTime);
|
|
break;
|
|
case MWTG_Stage.Explode:
|
|
Explode();
|
|
break;
|
|
case MWTG_Stage.SelfDestruct:
|
|
SelfDestruct();
|
|
break;
|
|
}
|
|
|
|
if (ShouldSelfDestruct())
|
|
{
|
|
currentStage = MWTG_Stage.SelfDestruct;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新发射阶段
|
|
/// </summary>
|
|
private void UpdateLaunchStage(double deltaTime)
|
|
{
|
|
// 实现发射阶段逻辑
|
|
if (FlightTime > 3) // 假设发射阶段持续3秒
|
|
{
|
|
currentStage = MWTG_Stage.Cruise;
|
|
Console.WriteLine($"导弹 {Id} 进入巡航阶段");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新巡航阶段
|
|
/// </summary>
|
|
private void UpdateCruiseStage(double deltaTime)
|
|
{
|
|
// 实现巡航阶段逻辑
|
|
if (DistanceToTarget <= TERMINAL_GUIDANCE_DISTANCE)
|
|
{
|
|
currentStage = MWTG_Stage.TerminalGuidance;
|
|
Console.WriteLine($"导弹 {Id} 进入末制导阶段");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新末制导阶段
|
|
/// </summary>
|
|
private void UpdateTerminalGuidanceStage(double deltaTime)
|
|
{
|
|
guidanceSystem.Update(deltaTime, Position, Velocity);
|
|
GuidanceAcceleration = guidanceSystem.GetGuidanceAcceleration();
|
|
|
|
if (DistanceToTarget <= ExplosionRadius)
|
|
{
|
|
currentStage = MWTG_Stage.Explode;
|
|
Console.WriteLine($"导弹 {Id} 进入爆炸阶段");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 爆炸
|
|
/// </summary>
|
|
protected override void Explode()
|
|
{
|
|
base.Explode();
|
|
currentStage = MWTG_Stage.Explode;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取导弹状态
|
|
/// </summary>
|
|
public override string GetStatus()
|
|
{
|
|
return base.GetStatus() + $"\n 当前阶段: {currentStage}, " + guidanceSystem.GetStatus();
|
|
}
|
|
}
|
|
}
|