private void JetAttack(sortie_battle.airbattle api) { if (api == null) { return; } ShipInBattle friendattack = null, enemyattack = null; if (api.api_plane_from[0]?.Length == 1 && api.api_plane_from[0][0] > 0) { friendattack = Fleet1[api.api_plane_from[0][0] - 1]; } if (api.api_plane_from.Length >= 2 && api.api_plane_from[1]?.Length == 1 && api.api_plane_from[1][0] > 0) { enemyattack = EnemyFleet[api.api_plane_from[1][0] - 1]; } if (api.api_stage3 != null) { if (api.api_stage3.api_edam != null) { EnemyFleet.ArrayZip(api.api_stage3.api_edam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_edam.Length; i++) { if (friendattack != null) { friendattack.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_edam[i]; } } } if (api.api_stage3.api_fdam != null) { Fleet1.ArrayZip(api.api_stage3.api_fdam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_fdam.Length; i++) { if (enemyattack != null) { enemyattack.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } } } if (api.api_stage3_combined != null) { if (api.api_stage3_combined.api_fdam != null) { Fleet2?.ArrayZip(api.api_stage3.api_fdam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_fdam.Length; i++) { if (enemyattack != null) { enemyattack.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } } if (api.api_stage3_combined.api_edam != null) { EnemyFleet2?.ArrayZip(api.api_stage3.api_edam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3.api_edam.Length; i++) { if (friendattack != null) { friendattack.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_edam[i]; } } } } }
private AirCombat AirBattle(sortie_battle.airbattle api, bool issupport) { if (api == null) { return(null); } AirCombat combat = new AirCombat(); ShipInBattle friendtorpedo = null, friendbomb = null, enemytorpedo = null, enemybomb = null; if (!issupport) { if (api.api_stage1 != null)//stage1一直都有吧 { combat.AirControl = (AirControl)api.api_stage1.api_disp_seiku; combat.FriendStage1 = new LimitedValue(api.api_stage1.api_f_count - api.api_stage1.api_f_lostcount, api.api_stage1.api_f_count); combat.EnemyStage1 = new LimitedValue(api.api_stage1.api_e_count - api.api_stage1.api_e_lostcount, api.api_stage1.api_e_count); } if (api.api_stage2 != null) { combat.FriendStage2 = new LimitedValue(api.api_stage2.api_f_count - api.api_stage2.api_f_lostcount, api.api_stage2.api_f_count); combat.EnemyStage2 = new LimitedValue(api.api_stage2.api_e_count - api.api_stage2.api_e_lostcount, api.api_stage2.api_e_count); } friendtorpedo = Fleet1.Where(x => x.CanAerialTorpedo).TakeIfSingle(); friendbomb = Fleet1.Where(x => x.CanAerialBomb).TakeIfSingle(); enemytorpedo = EnemyFleet.Where(x => x.CanAerialTorpedo).TakeIfSingle(); enemybomb = EnemyFleet.Where(x => x.CanAerialBomb).TakeIfSingle(); } if (api.api_stage3 != null) { if (!issupport) { Fleet1.ArrayZip(api.api_stage3.api_fdam, 1, Delegates.SetDamage); } EnemyFleet.ArrayZip(api.api_stage3.api_edam, 1, Delegates.SetDamage); if (!issupport) { for (int i = 1; i < api.api_stage3.api_fdam.Length; i++) { if (api.api_stage3.api_frai_flag[i] != 0) { if (api.api_stage3.api_fbak_flag[i] != 0) { if (enemytorpedo == enemybomb && enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } else if (enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } else if (api.api_stage3.api_fbak_flag[i] != 0) { if (enemybomb != null) { enemybomb.DamageGiven += (int)api.api_stage3.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3.api_fdam[i]; } } } for (int i = 1; i < api.api_stage3.api_edam.Length; i++) { if (api.api_stage3.api_erai_flag[i] != 0) { if (api.api_stage3.api_ebak_flag[i] != 0) { if (friendtorpedo == friendbomb && friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3.api_edam[i]; } } else if (friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3.api_edam[i]; } } else if (api.api_stage3.api_ebak_flag[i] != 0) { if (friendbomb != null) { friendbomb.DamageGiven += (int)api.api_stage3.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3.api_edam[i]; } } } } } if (api.api_stage3_combined != null) { if (api.api_stage3_combined.api_fdam != null) { Fleet2?.ArrayZip(api.api_stage3_combined.api_fdam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3_combined.api_fdam.Length; i++) { if (api.api_stage3_combined.api_frai_flag[i] != 0) { if (api.api_stage3_combined.api_fbak_flag[i] != 0) { if (enemytorpedo == enemybomb && enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3_combined.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3_combined.api_fdam[i]; } } else if (enemytorpedo != null) { enemytorpedo.DamageGiven += (int)api.api_stage3_combined.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3_combined.api_fdam[i]; } } else if (api.api_stage3_combined.api_fbak_flag[i] != 0) { if (enemybomb != null) { enemybomb.DamageGiven += (int)api.api_stage3_combined.api_fdam[i]; } else { AnonymousEnemyDamage += (int)api.api_stage3_combined.api_fdam[i]; } } } } if (api.api_stage3_combined.api_edam != null) { EnemyFleet2?.ArrayZip(api.api_stage3_combined.api_edam, 1, Delegates.SetDamage); for (int i = 1; i < api.api_stage3_combined.api_edam.Length; i++) { if (api.api_stage3_combined.api_erai_flag[i] != 0) { if (api.api_stage3_combined.api_ebak_flag[i] != 0) { if (friendtorpedo == friendbomb && friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3_combined.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3_combined.api_edam[i]; } } else if (friendtorpedo != null) { friendtorpedo.DamageGiven += (int)api.api_stage3_combined.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3_combined.api_edam[i]; } } else if (api.api_stage3_combined.api_ebak_flag[i] != 0) { if (friendbomb != null) { friendbomb.DamageGiven += (int)api.api_stage3_combined.api_edam[i]; } else { AnonymousFriendDamage += (int)api.api_stage3_combined.api_edam[i]; } } } } } return(combat); }
public Battle(sortie_battle api, CombinedFleetType fleettype, MapNodeType battletype, BattleManager source) { FleetType = fleettype; BattleType = battletype; Fleet1 = (source.SortieFleet1?.Ships ?? Staff.Current.Homeport.Fleets[api.api_deck_id + api.api_dock_id].Ships) .Select(x => new ShipInBattle(x)).ToArray(); Fleet2 = source.SortieFleet2?.Ships .Select(x => new ShipInBattle(x)).ToArray(); if (source.SortieFleet1 == null)//演习 { Staff.Current.Homeport.Fleets[api.api_deck_id + api.api_dock_id].Ships.ForEach(x => x.IgnoreNextCondition()); } if (api.api_formation != null) { FriendFormation = (Formation)api.api_formation[0]; EnemyFormation = (Formation)api.api_formation[1]; Direction = (Direction)api.api_formation[2]; } bool iscombined = fleettype != CombinedFleetType.None; bool isenemycombined = battletype == MapNodeType.Combined || battletype == MapNodeType.CombinedBOSS; EnemyFleet = api.api_ship_ke.Where(x => x != -1) .Select((x, i) => new ShipInBattle { ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv[i + 1], Equipments = api.api_eSlot[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).ToArray(), Firepower = api.api_eParam[i][0], Torpedo = api.api_eParam[i][1], AA = api.api_eParam[i][2], Armor = api.api_eParam[i][3] }) .ToArray(); EnemyFleet2 = api.api_ship_ke_combined?.Where(x => x != -1) .Select((x, i) => new ShipInBattle { ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv_combined[i + 1], Equipments = api.api_eSlot_combined[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).ToArray(), Firepower = api.api_eParam_combined[i][0], Torpedo = api.api_eParam_combined[i][1], AA = api.api_eParam_combined[i][2], Armor = api.api_eParam_combined[i][3] }) .ToArray(); EnemyShipIds = api.api_ship_ke.Skip(1).ConcatNotNull(api.api_ship_ke_combined?.Skip(1)).ToArray(); Fleet1.ArrayZip(api.api_maxhps, 1, Delegates.SetMaxHP); Fleet2?.ArrayZip(api.api_maxhps_combined, 1, Delegates.SetMaxHP); EnemyFleet.ArrayZip(api.api_maxhps, 7, Delegates.SetMaxHP); EnemyFleet2?.ArrayZip(api.api_maxhps_combined, 7, Delegates.SetMaxHP); Fleet1.ArrayZip(api.api_nowhps, 1, Delegates.SetStartHP); Fleet2?.ArrayZip(api.api_nowhps_combined, 1, Delegates.SetStartHP); EnemyFleet.ArrayZip(api.api_nowhps, 7, Delegates.SetStartHP); EnemyFleet2?.ArrayZip(api.api_nowhps_combined, 7, Delegates.SetStartHP); api.api_escape_idx?.ForEach(x => Fleet1[x - 1].IsEscaped = true); api.api_escape_idx_combined?.ForEach(x => Fleet2[x - 1].IsEscaped = true); JetAttack(api.api_air_base_injection); JetAttack(api.api_injection_kouku); AirBaseAttack(api.api_air_base_attack); AirCombat1 = AirBattle(api.api_kouku, false); AirCombat2 = AirBattle(api.api_kouku2, false); SupportAttack(api.api_support_info); FireAttack(api.api_opening_taisen, NightOrTorpedo); if (isenemycombined) { ECTorpedoAttack(api.api_opening_atack); } else { TorpedoAttack(api.api_opening_atack); } if (isenemycombined) { ECFireAttack(api.api_hougeki1); ECFireAttack(api.api_hougeki2); ECFireAttack(api.api_hougeki3); } else { switch (fleettype) { case CombinedFleetType.None: FireAttack(api.api_hougeki1, Fleet1); FireAttack(api.api_hougeki2, Fleet1); break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: FireAttack(api.api_hougeki1, Fleet2); FireAttack(api.api_hougeki2, Fleet1); FireAttack(api.api_hougeki3, Fleet1); break; case CombinedFleetType.Surface: FireAttack(api.api_hougeki1, Fleet1); FireAttack(api.api_hougeki2, Fleet1); FireAttack(api.api_hougeki3, Fleet2); break; } } if (isenemycombined) { ECTorpedoAttack(api.api_raigeki); } else { TorpedoAttack(api.api_raigeki); } NightBattle(api); }