protected virtual int setDamageValue(BattleHitStatus hitType, int atkPow, int defPow, Mem_ship attacker, Mem_ship target, List <bool> lostFlag) { switch (hitType) { case BattleHitStatus.Miss: return(0); case BattleHitStatus.Clitical: atkPow = (int)((double)atkPow * 1.5); break; } double num = (double)atkPow - ((double)defPow * 0.7 + (double)randInstance.Next(defPow) * 0.6); double num2 = 100.0; double num3 = Mst_DataManager.Instance.Mst_ship[attacker.Ship_id].Bull_max; if (num3 != 0.0) { num2 = (double)attacker.Bull / num3 * 100.0; } if (num2 < 50.0) { num = Math.Floor(num * num2 / 50.0); } int num4 = (int)num; BattleShipSubInfo battleShipSubInfo; int deckIdx; if (attacker.IsEnemy()) { battleShipSubInfo = E_SubInfo[attacker.Rid]; int deckIdx2 = battleShipSubInfo.DeckIdx; deckIdx = F_SubInfo[target.Rid].DeckIdx; } else { battleShipSubInfo = F_SubInfo[attacker.Rid]; int deckIdx3 = battleShipSubInfo.DeckIdx; deckIdx = E_SubInfo[target.Rid].DeckIdx; } if (num4 < 1) { int num5 = randInstance.Next(target.Nowhp); num4 = (int)((double)target.Nowhp * 0.06 + (double)num5 * 0.08); } if (num4 >= target.Nowhp && !target.IsEnemy() && deckIdx == 0) { num4 = (int)((double)target.Nowhp * 0.5 + (double)randInstance.Next(target.Nowhp) * 0.3); } if (lostFlag != null && num4 >= target.Nowhp && !lostFlag[deckIdx]) { num4 = target.Nowhp - 1; } double lovHoseiDamageKeisu = getLovHoseiDamageKeisu(target, num4); num4 = (int)((double)num4 * lovHoseiDamageKeisu); battleShipSubInfo.TotalDamage += num4; target.SubHp(num4); return(num4); }
private void lostNdock(List <Mem_ndock> ndock) { ndock.ForEach(delegate(Mem_ndock x) { int area_id = x.Area_id; if (x.Ship_id > 0) { Mem_ship mem_ship = Comm_UserDatas.Instance.User_ship.get_Item(x.Ship_id); mem_ship.SubHp(this.getShipDamage(mem_ship.Nowhp)); mem_ship.PortWithdraw(area_id); } Comm_UserDatas.Instance.User_ndock.Remove(x.Rid); }); }
public static void DeckRefresh(int DeckID) { List <Mem_ship> memShip = Comm_UserDatas.Instance.User_deck.get_Item(DeckID).Ship.getMemShip(); using (List <Mem_ship> .Enumerator enumerator = memShip.GetEnumerator()) { while (enumerator.MoveNext()) { Mem_ship current = enumerator.get_Current(); current.SubHp(-(current.Maxhp - current.Nowhp)); Mst_ship mst_ship = Mst_DataManager.Instance.Mst_ship.get_Item(current.Ship_id); current.Set_ChargeData(mst_ship.Bull_max, mst_ship.Fuel_max, Enumerable.ToList <int>(mst_ship.Maxeq)); } } }
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); }
private void repairShipAutoRecovery(DeckShips deck) { int num = 86; int num2 = 19; List <Mem_ship> list = deck.getMemShip(); if (Enumerable.Count <Mem_ship>(list) == 0) { return; } if (list.get_Item(0).Stype != num2) { return; } DamageState damageState = list.get_Item(0).Get_DamageState(); if (damageState == DamageState.Tyuuha || damageState == DamageState.Taiha) { return; } if (list.get_Item(0).ExistsNdock()) { return; } if (list.get_Item(0).IsBlingShip()) { return; } Mem_material mem_material = Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Fuel); Mem_material mem_material2 = Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Steel); if (mem_material.Value == 0 && mem_material2.Value == 0) { return; } Mem_ship arg_C7_0 = list.get_Item(0); HashSet <int> hashSet = new HashSet <int>(); hashSet.Add(num); Dictionary <int, int> mstSlotItemNum_OrderId = arg_C7_0.GetMstSlotItemNum_OrderId(hashSet); int num3 = mstSlotItemNum_OrderId.get_Item(num); list = Enumerable.ToList <Mem_ship>(Enumerable.Take <Mem_ship>(list, num3 + 2)); using (List <Mem_ship> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { Mem_ship current = enumerator.get_Current(); if (current.Nowhp < current.Maxhp) { DamageState damageState2 = current.Get_DamageState(); if (damageState2 != DamageState.Tyuuha && damageState2 != DamageState.Taiha) { if (!current.ExistsNdock()) { if (!current.IsBlingShip()) { int ndockTimeSpan = current.GetNdockTimeSpan(); int num4 = ndockTimeSpan * 30; int num5 = 30; double num6 = (double)num5 / (double)num4; Dictionary <enumMaterialCategory, int> ndockMaterialNum = current.GetNdockMaterialNum(); int num7 = (int)Math.Ceiling((double)ndockMaterialNum.get_Item(enumMaterialCategory.Fuel) * num6); int num8 = (int)Math.Ceiling((double)ndockMaterialNum.get_Item(enumMaterialCategory.Steel) * num6); if (mem_material.Value >= num7 && mem_material2.Value >= num8) { double num9 = (double)(current.Maxhp - current.Nowhp) * num6; int num10 = (num9 >= 1.0) ? ((int)num9) : ((int)Math.Ceiling(num9)); current.SubHp(-num10); mem_material.Sub_Material(num7); mem_material2.Sub_Material(num8); } } } } } } } }
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); }