private List <RadingDamageData> getRadingDamage(int area, RadingKind kind, Mst_radingrate rateRecord, List <Mem_ship> targetShips, out int deckPow, out List <Mem_ship> deleteShips)
        {
            List <Mem_ship> list = Enumerable.ToList <Mem_ship>(targetShips);
            int             ec   = 0;
            double          ad1  = 0.0;
            double          ad2  = 0.0;

            list.ForEach(delegate(Mem_ship ship)
            {
                if (ship.IsEscortDeffender())
                {
                    ec++;
                }
                Ship_GrowValues battleBaseParam = ship.GetBattleBaseParam();
                int num11 = ship.Taiku - battleBaseParam.Taiku;
                ad1       = ad1 + Math.Sqrt((double)battleBaseParam.Taiku) + (double)num11;
                int num12 = ship.Taisen - battleBaseParam.Taisen;
                ad2       = ad2 + Math.Sqrt((double)battleBaseParam.Taisen) + (double)num12;
            });
            int[]  radingValues = rateRecord.GetRadingValues(kind);
            double num          = (kind != RadingKind.AIR_ATTACK) ? ad2 : ad1;
            int    num2         = radingValues[0];
            int    num3         = radingValues[1];

            deckPow     = (int)num;
            deleteShips = new List <Mem_ship>();
            if (list.get_Count() == 0)
            {
                return(new List <RadingDamageData>());
            }
            RadingResultData radingResultData = new RadingResultData();

            radingResultData.DeckAttackPow = (int)num;
            double num4 = (double)num3 - Math.Sqrt((double)ec);
            int    num5 = (num4 >= 1.0) ? ((int)Utils.GetRandDouble(0.0, num4, 0.1, 1)) : 0;
            List <RadingDamageData>       list2      = new List <RadingDamageData>();
            Dictionary <int, DamageState> dictionary = Enumerable.ToDictionary(Enumerable.Select(list, (Mem_ship x) => new
            {
                rid   = x.Rid,
                state = x.Get_DamageState()
            }), key => key.rid, val => val.state);

            for (int i = 0; i < num5; i++)
            {
                if (list.get_Count() == 0)
                {
                    return(list2);
                }
                RadingDamageData radingDamageData = new RadingDamageData();
                double           num6             = (double)(num3 * 5) - num / 5.0 - Math.Sqrt(num);
                int      num7     = (int)Utils.GetRandDouble(0.0, (double)(list.get_Count() - 1), 1.0, 1);
                Mem_ship mem_ship = list.get_Item(num7);
                radingDamageData.Rid = mem_ship.Rid;
                if (num6 <= 0.0)
                {
                    radingDamageData.Damage      = false;
                    radingDamageData.DamageState = DamagedStates.None;
                }
                else
                {
                    int taik = Mst_DataManager.Instance.Mst_ship.get_Item(mem_ship.Ship_id).Taik;
                    int num8 = (int)((double)taik * Utils.GetRandDouble(1.0, num6, 1.0, 1) / 100.0) + 1;
                    int num9 = mem_ship.Nowhp - num8;
                    if (num9 <= 0)
                    {
                        if (this.basicInstance.Difficult != DifficultKind.SHI)
                        {
                            num9 = 1;
                        }
                        else if (dictionary.get_Item(mem_ship.Rid) != DamageState.Taiha)
                        {
                            num9 = 1;
                        }
                        else
                        {
                            num9 = 0;
                        }
                    }
                    int num10 = mem_ship.Nowhp - num9;
                    if (num10 > 0)
                    {
                        DamageState damageState = mem_ship.Get_DamageState();
                        radingDamageData.Damage = true;
                        if (num9 == 0)
                        {
                            int[] array = mem_ship.FindRecoveryItem();
                            if (array[0] == -1)
                            {
                                radingDamageData.DamageState = DamagedStates.Gekichin;
                                list.Remove(mem_ship);
                                deleteShips.Add(mem_ship);
                            }
                            else
                            {
                                mem_ship.SubHp(num10);
                                mem_ship.UseRecoveryItem(array, false);
                                radingDamageData.DamageState = ((array[1] != 43) ? DamagedStates.Youin : DamagedStates.Megami);
                                dictionary.set_Item(mem_ship.Rid, DamageState.Normal);
                            }
                        }
                        else
                        {
                            mem_ship.SubHp(num10);
                            DamageState damageState2 = mem_ship.Get_DamageState();
                            if (damageState != damageState2)
                            {
                                if (damageState2 == DamageState.Taiha)
                                {
                                    radingDamageData.DamageState = DamagedStates.Taiha;
                                }
                                else if (damageState2 == DamageState.Shouha)
                                {
                                    radingDamageData.DamageState = DamagedStates.Shouha;
                                }
                                else if (damageState2 == DamageState.Tyuuha)
                                {
                                    radingDamageData.DamageState = DamagedStates.Tyuuha;
                                }
                            }
                            else
                            {
                                radingDamageData.DamageState = DamagedStates.None;
                            }
                        }
                    }
                    else
                    {
                        radingDamageData.Damage      = false;
                        radingDamageData.DamageState = DamagedStates.None;
                    }
                }
                list2.Add(radingDamageData);
            }
            return(list2);
        }
Example #2
0
        private List <RadingDamageData> getRadingDamage(int area, RadingKind kind, Mst_radingrate rateRecord, List <Mem_ship> targetShips, out int deckPow, out List <Mem_ship> deleteShips)
        {
            List <Mem_ship> list = targetShips.ToList();
            int             ec   = 0;
            double          ad3  = 0.0;
            double          ad2  = 0.0;

            list.ForEach(delegate(Mem_ship ship)
            {
                if (ship.IsEscortDeffender())
                {
                    ec++;
                }
                Ship_GrowValues battleBaseParam = ship.GetBattleBaseParam();
                int num9  = ship.Taiku - battleBaseParam.Taiku;
                ad3       = ad3 + Math.Sqrt(battleBaseParam.Taiku) + (double)num9;
                int num10 = ship.Taisen - battleBaseParam.Taisen;
                ad2       = ad2 + Math.Sqrt(battleBaseParam.Taisen) + (double)num10;
            });
            int[]  radingValues = rateRecord.GetRadingValues(kind);
            double num          = (kind != RadingKind.AIR_ATTACK) ? ad2 : ad3;
            int    num11        = radingValues[0];
            int    num2         = radingValues[1];

            deckPow     = (int)num;
            deleteShips = new List <Mem_ship>();
            if (list.Count == 0)
            {
                return(new List <RadingDamageData>());
            }
            RadingResultData radingResultData = new RadingResultData();

            radingResultData.DeckAttackPow = (int)num;
            double num3 = (double)num2 - Math.Sqrt(ec);
            int    num4 = (!(num3 < 1.0)) ? ((int)Utils.GetRandDouble(0.0, num3, 0.1, 1)) : 0;
            List <RadingDamageData>       list2      = new List <RadingDamageData>();
            Dictionary <int, DamageState> dictionary = (from x in list
                                                        select new
            {
                rid = x.Rid,
                state = x.Get_DamageState()
            }).ToDictionary(key => key.rid, val => val.state);

            for (int i = 0; i < num4; i++)
            {
                if (list.Count == 0)
                {
                    return(list2);
                }
                RadingDamageData radingDamageData = new RadingDamageData();
                double           num5             = (double)(num2 * 5) - num / 5.0 - Math.Sqrt(num);
                int      index    = (int)Utils.GetRandDouble(0.0, list.Count - 1, 1.0, 1);
                Mem_ship mem_ship = list[index];
                radingDamageData.Rid = mem_ship.Rid;
                if (num5 <= 0.0)
                {
                    radingDamageData.Damage      = false;
                    radingDamageData.DamageState = DamagedStates.None;
                }
                else
                {
                    int taik = Mst_DataManager.Instance.Mst_ship[mem_ship.Ship_id].Taik;
                    int num6 = (int)((double)taik * Utils.GetRandDouble(1.0, num5, 1.0, 1) / 100.0) + 1;
                    int num7 = mem_ship.Nowhp - num6;
                    if (num7 <= 0)
                    {
                        num7 = ((basicInstance.Difficult != DifficultKind.SHI) ? 1 : ((dictionary[mem_ship.Rid] != DamageState.Taiha) ? 1 : 0));
                    }
                    int num8 = mem_ship.Nowhp - num7;
                    if (num8 > 0)
                    {
                        DamageState damageState = mem_ship.Get_DamageState();
                        radingDamageData.Damage = true;
                        if (num7 == 0)
                        {
                            int[] array = mem_ship.FindRecoveryItem();
                            if (array[0] == -1)
                            {
                                radingDamageData.DamageState = DamagedStates.Gekichin;
                                list.Remove(mem_ship);
                                deleteShips.Add(mem_ship);
                            }
                            else
                            {
                                mem_ship.SubHp(num8);
                                mem_ship.UseRecoveryItem(array, flagShipRecovery: false);
                                radingDamageData.DamageState = ((array[1] != 43) ? DamagedStates.Youin : DamagedStates.Megami);
                                dictionary[mem_ship.Rid]     = DamageState.Normal;
                            }
                        }
                        else
                        {
                            mem_ship.SubHp(num8);
                            DamageState damageState2 = mem_ship.Get_DamageState();
                            if (damageState != damageState2)
                            {
                                switch (damageState2)
                                {
                                case DamageState.Taiha:
                                    radingDamageData.DamageState = DamagedStates.Taiha;
                                    break;

                                case DamageState.Shouha:
                                    radingDamageData.DamageState = DamagedStates.Shouha;
                                    break;

                                case DamageState.Tyuuha:
                                    radingDamageData.DamageState = DamagedStates.Tyuuha;
                                    break;
                                }
                            }
                            else
                            {
                                radingDamageData.DamageState = DamagedStates.None;
                            }
                        }
                    }
                    else
                    {
                        radingDamageData.Damage      = false;
                        radingDamageData.DamageState = DamagedStates.None;
                    }
                }
                list2.Add(radingDamageData);
            }
            return(list2);
        }