public Battle(sortie_battle api, CombinedFleetType fleettype, MapNodeType battletype, ShipInBattle[] fleet1, ShipInBattle[] fleet2) { FleetType = fleettype; BattleType = battletype; Fleet1 = fleet1; Fleet2 = fleet2; bool isEnemyCombined = battletype == MapNodeType.Combined || battletype == MapNodeType.CombinedBOSS; if (api.api_formation != null) { FriendFormation = (Formation)api.api_formation[0]; EnemyFormation = (Formation)api.api_formation[1]; Direction = (Direction)api.api_formation[2]; } if (api.api_search != null) { FriendSearching = api.api_search[0]; EnemySearching = api.api_search[1]; } EnemyFleet = api.api_ship_ke .Select((x, i) => new ShipInBattle { Index = i + 1, IsEnemy = true, ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv[i], Equipments = api.api_eSlot[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).Select(y => new EquipInBattle(y)).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? .Select((x, i) => new ShipInBattle { Index = i + 7, IsEnemy = true, ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv_combined[i], Equipments = api.api_eSlot_combined[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).Select(y => new EquipInBattle(y)).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.ConcatNotNull(api.api_ship_ke_combined).ToArray(); SetHPs(Fleet1, api.api_f_nowhps, api.api_f_maxhps); SetHPs(EnemyFleet, api.api_e_nowhps, api.api_e_maxhps); SetHPs(Fleet2, api.api_f_nowhps_combined, api.api_f_maxhps_combined); SetHPs(EnemyFleet2, api.api_e_nowhps_combined, api.api_e_maxhps_combined); api.api_escape_idx?.ForEach(x => Fleet1[x - 1].IsEscaped = true); api.api_escape_idx_combined?.ForEach(x => Fleet2[x - 1].IsEscaped = true); if (api.api_n_support_info != null) { Support = new SupportAttack(this, api.api_n_support_info, api.api_n_support_flag); } if (api.api_n_hougeki1 != null) { NightToDay1 = new FireCombat(this, api.api_n_hougeki1); } if (api.api_n_hougeki2 != null) { NightToDay2 = new FireCombat(this, api.api_n_hougeki2); } if (api.api_air_base_injection != null) { AirBaseJet = new JetPlaneAttack(this, api.api_air_base_injection, true); } if (api.api_injection_kouku != null) { Jet = new JetPlaneAttack(this, api.api_injection_kouku, false); } if (api.api_air_base_attack != null) { AirBaseAttacks = api.api_air_base_attack.Select(x => new AirBaseAttack(this, x)).ToArray(); } if (api.api_kouku != null) { AirCombat1 = new AerialCombat(this, api.api_kouku); } if (api.api_kouku2 != null) { AirCombat2 = new AerialCombat(this, api.api_kouku2); } if (api.api_support_flag != 0) { Support = new SupportAttack(this, api.api_support_info, api.api_support_flag); } if (api.api_opening_taisen != null) { OpeningASW = new FireCombat(this, api.api_opening_taisen); } if (api.api_opening_atack != null) { OpeningTorpedo = new TorpedoCombat(this, api.api_opening_atack); } if (isEnemyCombined) { switch (fleettype) { case CombinedFleetType.None: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } break; case CombinedFleetType.Surface: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } break; } } else { switch (fleettype) { case CombinedFleetType.None: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } break; case CombinedFleetType.Surface: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } break; } } if (api.api_hougeki != null || api.api_friendly_info != null) { NightBattle(api); } else { EndApplyBattle(); } }
public Battle(sortie_battle api, CombinedFleetType fleettype, MapNodeType battletype, ShipInBattle[] fleet1, ShipInBattle[] fleet2) { FleetType = fleettype; BattleType = battletype; Fleet1 = fleet1; Fleet2 = fleet2; if (api.api_formation != null) { FriendFormation = (Formation)api.api_formation[0]; EnemyFormation = (Formation)api.api_formation[1]; Direction = (Direction)api.api_formation[2]; } if (api.api_search != null) { FriendSearching = api.api_search[0]; EnemySearching = api.api_search[1]; } 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 { Index = i + 1, IsEnemy = true, 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).Select(y => new EquipInBattle(y)).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 { Index = i + 7, IsEnemy = true, 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).Select(y => new EquipInBattle(y)).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(); void SetHPs(ShipInBattle[] fleet, int index, int[] hps, int[] maxhps) { if (fleet == null) { return; } for (int i = 0; i < fleet.Length; i++) { var ship = fleet[i]; ship.MaxHP = maxhps[i + index]; ship.FromHP = ship.ToHP = hps[i + index]; } } SetHPs(Fleet1, 1, api.api_nowhps, api.api_maxhps); SetHPs(EnemyFleet, 7, api.api_nowhps, api.api_maxhps); SetHPs(Fleet2, 1, api.api_nowhps_combined, api.api_maxhps_combined); SetHPs(EnemyFleet2, 7, api.api_nowhps_combined, api.api_maxhps_combined); api.api_escape_idx?.ForEach(x => Fleet1[x - 1].IsEscaped = true); api.api_escape_idx_combined?.ForEach(x => Fleet2[x - 1].IsEscaped = true); if (api.api_air_base_injection != null) { AirBaseJet = new JetPlaneAttack(this, api.api_air_base_injection, true); } if (api.api_injection_kouku != null) { Jet = new JetPlaneAttack(this, api.api_injection_kouku, false); } if (api.api_air_base_attack != null) { AirBaseAttacks = api.api_air_base_attack.Select(x => new AirBaseAttack(this, x)).ToArray(); } if (api.api_kouku != null) { AirCombat1 = new AerialCombat(this, api.api_kouku); } if (api.api_kouku2 != null) { AirCombat2 = new AerialCombat(this, api.api_kouku2); } if (api.api_support_flag != 0) { Support = new SupportAttack(this, api.api_support_info, api.api_support_flag); } if (isenemycombined) { if (api.api_opening_taisen != null) { OpeningASW = new ECFireCombat(this, api.api_opening_taisen); } if (api.api_opening_atack != null) { OpeningTorpedo = new ECTorpedoCombat(this, api.api_opening_atack); } if (api.api_hougeki1 != null) { FireStage1 = new ECFireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new ECFireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new ECFireCombat(this, api.api_hougeki3); } if (api.api_raigeki != null) { TorpedoStage = new ECTorpedoCombat(this, api.api_raigeki); } } else { if (api.api_opening_taisen != null) { OpeningASW = new FireCombat(api.api_opening_taisen, NightOrTorpedo, EnemyFleet); } if (api.api_opening_atack != null) { OpeningTorpedo = new TorpedoCombat(api.api_opening_atack, NightOrTorpedo, EnemyFleet); } switch (fleettype) { case CombinedFleetType.None: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(api.api_hougeki1, Fleet1, EnemyFleet); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(api.api_hougeki2, Fleet1, EnemyFleet); } break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(api.api_hougeki1, Fleet2, EnemyFleet); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(api.api_hougeki2, Fleet1, EnemyFleet); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(api.api_hougeki3, Fleet1, EnemyFleet); } break; case CombinedFleetType.Surface: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(api.api_hougeki1, Fleet1, EnemyFleet); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(api.api_hougeki2, Fleet1, EnemyFleet); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(api.api_hougeki3, Fleet2, EnemyFleet); } break; } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(api.api_raigeki, NightOrTorpedo, EnemyFleet); } } if (api.api_hougeki != null) { NightBattle(api); } else { EndApplyBattle(); } }