102 lines
3.0 KiB
C#
102 lines
3.0 KiB
C#
using System;
|
|
using ActiveProtect.SimulationEnvironment;
|
|
|
|
namespace ActiveProtect.Models
|
|
{
|
|
/// <summary>
|
|
/// 红外成像末制导导弹
|
|
/// </summary>
|
|
public class InfraredImagingTerminalGuidedMissile : MissileBase
|
|
{
|
|
private enum MissileStage
|
|
{
|
|
Launch,
|
|
Cruise,
|
|
TerminalGuidance,
|
|
Explode,
|
|
SelfDestruct
|
|
}
|
|
|
|
private MissileStage currentStage;
|
|
private readonly InfraredImagingGuidanceSystem guidanceSystem;
|
|
private const double TERMINAL_GUIDANCE_DISTANCE = 1000; // 末制导开始距离(米)
|
|
|
|
public InfraredImagingTerminalGuidedMissile(MissileConfig config, ISimulationManager manager)
|
|
: base(config, manager)
|
|
{
|
|
Type = MissileType.InfraredImagingTerminalGuidance;
|
|
currentStage = MissileStage.Launch;
|
|
guidanceSystem = new InfraredImagingGuidanceSystem(manager);
|
|
}
|
|
|
|
public override void Update(double deltaTime)
|
|
{
|
|
base.Update(deltaTime);
|
|
|
|
switch (currentStage)
|
|
{
|
|
case MissileStage.Launch:
|
|
UpdateLaunchStage(deltaTime);
|
|
break;
|
|
case MissileStage.Cruise:
|
|
UpdateCruiseStage(deltaTime);
|
|
break;
|
|
case MissileStage.TerminalGuidance:
|
|
UpdateTerminalGuidanceStage(deltaTime);
|
|
break;
|
|
case MissileStage.Explode:
|
|
Explode();
|
|
break;
|
|
case MissileStage.SelfDestruct:
|
|
SelfDestruct();
|
|
break;
|
|
}
|
|
|
|
if (ShouldSelfDestruct())
|
|
{
|
|
currentStage = MissileStage.SelfDestruct;
|
|
}
|
|
}
|
|
|
|
private void UpdateLaunchStage(double deltaTime)
|
|
{
|
|
// 实现发射阶段逻辑
|
|
if (FlightTime > 5) // 假设发射阶段持续5秒
|
|
{
|
|
currentStage = MissileStage.Cruise;
|
|
}
|
|
}
|
|
|
|
private void UpdateCruiseStage(double deltaTime)
|
|
{
|
|
// 实现巡航阶段逻辑
|
|
if (DistanceToTarget <= TERMINAL_GUIDANCE_DISTANCE)
|
|
{
|
|
currentStage = MissileStage.TerminalGuidance;
|
|
}
|
|
}
|
|
|
|
private void UpdateTerminalGuidanceStage(double deltaTime)
|
|
{
|
|
guidanceSystem.Update(deltaTime, Position, Velocity);
|
|
GuidanceAcceleration = guidanceSystem.GetGuidanceAcceleration();
|
|
|
|
if (DistanceToTarget <= ExplosionRadius)
|
|
{
|
|
currentStage = MissileStage.Explode;
|
|
}
|
|
}
|
|
|
|
protected override void Explode()
|
|
{
|
|
base.Explode();
|
|
currentStage = MissileStage.Explode;
|
|
}
|
|
|
|
public override string GetStatus()
|
|
{
|
|
return base.GetStatus() + $"\n 当前阶段: {currentStage}";
|
|
}
|
|
}
|
|
}
|