Exemplo n.º 1
0
        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);

            AirCombat1 = AirBattle(api.api_kouku, false);
            AirCombat2 = AirBattle(api.api_kouku2, false);
            AirBaseAttack(api.api_air_base_attack);
            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);
        }
Exemplo n.º 2
0
 private void FireAttack(sortie_battle.fire api, ShipInBattle[] fleet, ShipInBattle[] enemy)
 {
     if (api == null) return;
     api.api_df_list.ZipEach(api.api_damage, (x, y) => x.ZipEach(y, (a, b) => Delegates.SetDamage(FindShip(a, fleet, enemy), b)));
     api.api_damage.ArrayZip(api.api_at_list, 1, (x, y) => x.ForEach(d => Delegates.SetGiveDamage(FindShip(y, fleet, enemy), d)));
 }
Exemplo n.º 3
0
 private void ECFireAttack(sortie_battle.fire api)
 {
     if (api == null) return;
     for (int i = 1; i < api.api_at_eflag.Length; i++)
     {
         if (api.api_at_eflag[i] == 0)
         {
             api.api_df_list[i - 1].ZipEach(api.api_damage[i - 1], (x, y) => Delegates.SetDamage(FindEnemy(x), y));
             Delegates.SetGiveDamage(FindFriend(api.api_at_list[i]), api.api_damage[i - 1].Sum());
         }
         else
         {
             api.api_df_list[i - 1].ZipEach(api.api_damage[i - 1], (x, y) => Delegates.SetDamage(FindFriend(x), y));
             Delegates.SetGiveDamage(FindEnemy(api.api_at_list[i]), api.api_damage[i - 1].Sum());
         }
     }
 }
Exemplo n.º 4
0
 private void ECTorpedoAttack(sortie_battle.torpedo api)
 {
     if (api == null) return;
     AllFriends.ZipEach(api.api_fdam.Skip(1), Delegates.SetDamage);
     AllEnemies.ZipEach(api.api_edam.Skip(1), Delegates.SetDamage);
     AllFriends.ZipEach(api.api_fydam.Skip(1), Delegates.SetGiveDamage);
     AllEnemies.ZipEach(api.api_eydam.Skip(1), Delegates.SetGiveDamage);
 }
Exemplo n.º 5
0
 private void FireAttack(sortie_battle.fire api, ShipInBattle[] fleet) => FireAttack(api, fleet, EnemyFleet);
Exemplo n.º 6
0
 private void AirBaseAttack(sortie_battle.air_base_attack[] api)
 {
     if (api == null) return;
     foreach (var attack in api)
     {
         if (attack.api_stage3 != null)
             EnemyFleet.ArrayZip(attack.api_stage3.api_edam, 1, Delegates.SetDamage);
         if (attack.api_stage3_combined != null)
             EnemyFleet2.ArrayZip(attack.api_stage3_combined.api_edam, 1, Delegates.SetDamage);
     }
 }
Exemplo n.º 7
0
 private void TorpedoAttack(sortie_battle.torpedo api)
 {
     if (api == null) return;
     NightOrTorpedo.ArrayZip(api.api_fdam, 1, Delegates.SetDamage);
     EnemyFleet.ArrayZip(api.api_edam, 1, Delegates.SetDamage);
     NightOrTorpedo.ArrayZip(api.api_fydam, 1, Delegates.SetGiveDamage);
     EnemyFleet.ArrayZip(api.api_eydam, 1, Delegates.SetGiveDamage);
 }
Exemplo n.º 8
0
 private void SupportAttack(sortie_battle.support api)
 {
     if (api == null) return;
     AirBattle(api.api_support_airatack, true);
     if (api.api_support_hourai != null)
         AllEnemies.ZipEach(api.api_support_hourai.api_damage.Skip(1), Delegates.SetDamage);
 }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
 public void NightBattle(sortie_battle api)
 {
     if (api.api_active_deck != null)
     {
         if (api.api_active_deck[1] == 1)
             FireAttack(api.api_hougeki, NightOrTorpedo, EnemyFleet);
         else FireAttack(api.api_hougeki, NightOrTorpedo, EnemyFleet2);
     }
     else FireAttack(api.api_hougeki, NightOrTorpedo);
     EndApplyBattle();
 }
Exemplo n.º 11
0
 private void NightBattle(sortie_battle api) =>
     (CurrentBattle as Battle).NightBattle(api);
Exemplo n.º 12
0
 private void StartBattle(sortie_battle api) =>
     CurrentBattle = new Battle(api, CurrentFleetType ?? CombinedFleetType.None, CurrentNode?.Type ?? MapNodeType.Battle, this);