Exemplo n.º 1
0
 public NightCombat(sortie_battle_old api, ShipInBattle[] friends, ShipInBattle[] enemies)
     : base(api.api_hougeki, friends, enemies)
 {
     if (api.api_touch_plane != null)
     {
         FriendTouch = Staff.Current.MasterData.EquipInfo[api.api_touch_plane[0]];
         EnemyTouch  = Staff.Current.MasterData.EquipInfo[api.api_touch_plane[1]];
     }
     if (api.api_flare_pos != null)
     {
         int pos = api.api_flare_pos[0];
         if (pos >= 1 && pos <= 6)
         {
             FriendFlare = friends[pos - 1];
         }
         pos = api.api_flare_pos[1];
         if (pos >= 1 && pos <= 6)
         {
             EnemyFlare = enemies[pos - 1];
         }
     }
     foreach (var ship in friends)
     {
         if (FriendLight != null)
         {
             break;
         }
         if (ship.IsEscaped)
         {
             continue;
         }
         foreach (var equip in ship.Equipments)
         {
             int id = equip.EquipInfo.EquipType.Id;
             if (id == 29 || id == 42)
             {
                 FriendLight = ship;
                 break;
             }
         }
     }
     foreach (var ship in enemies)
     {
         if (EnemyLight != null)
         {
             break;
         }
         foreach (var equip in ship.Equipments)
         {
             int id = equip.EquipInfo.EquipType.Id;
             if (id == 29 || id == 42)
             {
                 EnemyLight = ship;
                 break;
             }
         }
     }
 }
Exemplo n.º 2
0
 public void NightBattle(sortie_battle_old api)
 {
     if (api.api_active_deck != null)
     {
         Night = new NightCombat(api, NightOrTorpedo, api.api_active_deck[1] == 1 ? EnemyFleet : EnemyFleet2);
     }
     else
     {
         Night = new NightCombat(api, NightOrTorpedo, EnemyFleet);
     }
     EndApplyBattle();
 }
Exemplo n.º 3
0
        public OldBattle(sortie_battle_old 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();
            }
        }