using System; using ActiveProtect.SimulationEnvironment; namespace ActiveProtect.Models { /// /// 红外成像末制导导弹 /// public class InfraredImagingTerminalGuidedMissile : MissileBase { /// /// 红外成像末制导导弹阶段 /// private enum IRTG_Stage { Launch, Cruise, TerminalGuidance, Explode, SelfDestruct } private IRTG_Stage 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 = IRTG_Stage.Launch; guidanceSystem = new InfraredImagingGuidanceSystem(config.MaxAcceleration, config.ProportionalNavigationCoefficient, manager); } /// /// 更新红外成像末制导导弹 /// public override void Update(double deltaTime) { base.Update(deltaTime); switch (currentStage) { case IRTG_Stage.Launch: UpdateLaunchStage(deltaTime); break; case IRTG_Stage.Cruise: UpdateCruiseStage(deltaTime); break; case IRTG_Stage.TerminalGuidance: UpdateTerminalGuidanceStage(deltaTime); break; case IRTG_Stage.Explode: Explode(); break; case IRTG_Stage.SelfDestruct: SelfDestruct(); break; } if (ShouldSelfDestruct()) { currentStage = IRTG_Stage.SelfDestruct; } } /// /// 更新发射阶段 /// private void UpdateLaunchStage(double deltaTime) { // 实现发射阶段逻辑 if (FlightTime > 0.1) // 假设发射阶段持续0.1秒 { currentStage = IRTG_Stage.Cruise; } } /// /// 更新巡航阶段 /// private void UpdateCruiseStage(double deltaTime) { // 实现巡航阶段逻辑 if (DistanceToTarget <= TERMINAL_GUIDANCE_DISTANCE) { currentStage = IRTG_Stage.TerminalGuidance; } } /// /// 更新末制导阶段 /// private void UpdateTerminalGuidanceStage(double deltaTime) { guidanceSystem.Update(deltaTime, Position, Velocity); GuidanceAcceleration = guidanceSystem.GetGuidanceAcceleration(); if (DistanceToTarget <= ExplosionRadius) { currentStage = IRTG_Stage.Explode; } } /// /// 爆炸 /// protected override void Explode() { base.Explode(); currentStage = IRTG_Stage.Explode; } /// /// 获取导弹状态 /// public override string GetStatus() { return base.GetStatus() + $"\n 当前阶段: {currentStage}" + guidanceSystem.GetStatus(); } } }