Пример #1
0
        public ECFireCombat(OldBattle battle, sortie_battle_old.fire api)
        {
            var result = new List <Attack>();

            for (int i = 0; i < api.api_df_list.Length; i++)
            {
                int  sourceidx = api.api_at_list[i + 1];
                bool direction = api.api_at_eflag[i + 1] == 0;
                var  source    = direction ?
                                 FindShip(sourceidx, battle.Fleet1, battle.Fleet2) :
                                 FindShip(sourceidx, battle.EnemyFleet, battle.EnemyFleet2);
                for (int j = 0; j < api.api_df_list[i].Length; j++)
                {
                    int destidx = api.api_df_list[i][j];
                    var dest    = direction ?
                                  FindShip(destidx, battle.EnemyFleet, battle.EnemyFleet2) :
                                  FindShip(destidx, battle.Fleet1, battle.Fleet2);
                    var damage = Attack.ParseDamage(api.api_damage[i][j]);
                    (var friend, var enemy) = direction ? (source, dest) : (dest, source);
                    result.Add(new Attack
                    {
                        Friend     = friend,
                        Enemy      = enemy,
                        Direction  = direction,
                        Damage     = damage.damage,
                        IsCritical = api.api_cl_list[i][j] == 2,
                        Shield     = damage.shield
                    });
                }
            }
            ApplyAttacks(result);
        }
Пример #2
0
        public FireCombat(sortie_battle_old.fire api, ShipInBattle[] friends, ShipInBattle[] enemies)
        {
            var result = new List <Attack>();

            for (int i = 0; i < api.api_df_list.Length; i++)
            {
                int  sourceidx = api.api_at_list[i + 1];
                bool direction = sourceidx <= 6;
                var  source    = FindShip(sourceidx, friends, enemies);
                for (int j = 0; j < api.api_df_list[i].Length; j++)
                {
                    int destidx = api.api_df_list[i][0];
                    var dest    = FindShip(destidx, friends, enemies);
                    var damage  = Attack.ParseDamage(api.api_damage[i][j]);
                    (var friend, var enemy) = direction ? (source, dest) : (dest, source);
                    result.Add(new Attack
                    {
                        Friend     = friend,
                        Enemy      = enemy,
                        Direction  = direction,
                        Damage     = damage.damage,
                        IsCritical = api.api_cl_list[i][j] == 2,
                        Shield     = damage.shield
                    });
                }
            }
            ApplyAttacks(result);
        }