| | | 1 | | using System; |
| | | 2 | | using CounterDrone.Core.Models; |
| | | 3 | | |
| | | 4 | | namespace CounterDrone.Core.Algorithms |
| | | 5 | | { |
| | | 6 | | /// <summary>吸入式爆炸 — 指数累积型:暴露时间越长伤害越高</summary> |
| | | 7 | | public class ActiveFuelDamageModel : IDamageModel |
| | | 8 | | { |
| | | 9 | | private const float EffectiveThreshold = 0.03f; // 有效浓度阈值 |
| | | 10 | | private const float BaseRate = 0.02f; // 基础速率 |
| | | 11 | | private const float ExpFactor = 0.3f; // 指数增长因子 |
| | | 12 | | |
| | | 13 | | public float CalculateDamage(TargetType droneType, PowerType powerType, |
| | | 14 | | AerosolType aerosolType, float cloudDensity, float exposureTime, float deltaTime) |
| | 4 | 15 | | { |
| | 4 | 16 | | if (aerosolType != AerosolType.ActiveFuel) return 0f; |
| | 4 | 17 | | if (cloudDensity < EffectiveThreshold) return 0f; |
| | | 18 | | |
| | | 19 | | // 伤害 = 基础速率 × e^(暴露时间 × 因子) × deltaTime |
| | | 20 | | // 在云团中待得越久伤害指数增长 |
| | 4 | 21 | | var exponential = (float)System.Math.Exp(exposureTime * ExpFactor); |
| | 4 | 22 | | var damage = BaseRate * exponential * deltaTime; |
| | | 23 | | |
| | | 24 | | // 高速目标更脆弱 |
| | 4 | 25 | | var sensitivity = droneType == TargetType.HighSpeed ? 1.5f : 1.0f; |
| | 4 | 26 | | return damage * sensitivity; |
| | 4 | 27 | | } |
| | | 28 | | |
| | | 29 | | public DamageStage GetDamageStage(float accumulatedDamage) |
| | 0 | 30 | | { |
| | 0 | 31 | | if (accumulatedDamage >= 1.0f) return DamageStage.Destroyed; |
| | 0 | 32 | | if (accumulatedDamage >= 0.6f) return DamageStage.AttitudeLoss; |
| | 0 | 33 | | if (accumulatedDamage >= 0.3f) return DamageStage.EngineAnomaly; |
| | 0 | 34 | | return DamageStage.Normal; |
| | 0 | 35 | | } |
| | | 36 | | } |
| | | 37 | | } |