private void TakeMaterial(ref Dictionary <enumMaterialCategory, int> add_mat, ref Dictionary <enumMaterialCategory, int> summaryBase) { IEnumerable <IGrouping <int, Mem_tanker> > areaEnableTanker = Mem_tanker.GetAreaEnableTanker(Comm_UserDatas.Instance.User_tanker); if (areaEnableTanker.Count() != 0) { foreach (IGrouping <int, Mem_tanker> item in areaEnableTanker) { Mst_maparea mst_maparea = Mst_DataManager.Instance.Mst_maparea[item.Key]; DeckShips ship = Comm_UserDatas.Instance.User_EscortDeck[item.Key].Ship; mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, item.Count(), ref add_mat, randMaxFlag: false, ship); mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, item.Count(), ref summaryBase, randMaxFlag: true, ship); } int materialMaxNum = Comm_UserDatas.Instance.User_basic.GetMaterialMaxNum(); foreach (KeyValuePair <enumMaterialCategory, int> item2 in add_mat) { int num = 0; int num2 = Comm_UserDatas.Instance.User_material[item2.Key].Value + item2.Value; int num3 = materialMaxNum - num2; if (num3 >= 0) { num = item2.Value; } else if (materialMaxNum > Comm_UserDatas.Instance.User_material[item2.Key].Value) { num = materialMaxNum - Comm_UserDatas.Instance.User_material[item2.Key].Value; } Comm_UserDatas.Instance.User_material[item2.Key].Add_Material(num); } } }
public bool Change_TempDeck(int deck_targetIdx, int ship_rid, ref DeckShips deckShip) { DeckShips deckShips = deckShip; if (ship_rid == -2) { deckShips.RemoveRange(1, deckShips.Count() - 1); return(true); } int num = deckShips.Find(ship_rid); int num2 = deckShips[deck_targetIdx]; deckShips[deck_targetIdx] = ship_rid; if (ship_rid == -1 || num == -1) { return(true); } if (num2 != ship_rid) { deckShips[num] = num2; } else { deckShips[num] = -1; } return(true); }
private bool validEscortStypeCheck(DeckShips deckship, int deck_targetIdx) { if (deckship.Count() == 0) { return(true); } return((DeckUtils.IsValidChangeEscort(deckship.getMemShip(), mst_escort_group, deck_targetIdx) == EscortCheckKinds.OK) ? true : false); }
public TemporaryEscortDeckModel(int id, DeckShips deckships, string name, Dictionary <int, ShipModel> ships) : base(null, null) { this._id = id; this._deckships = deckships; this._name = name; if (this._deckships != null) { base._Update(deckships, ships); } }
public static Dictionary <enumMaterialCategory, int> GetAreaResource(int area_id, int tanker_count, EscortDeckManager eManager) { DeckShips deckShip = null; if (eManager != null && eManager.EditDeck != null) { deckShip = ((TemporaryEscortDeckModel)eManager.EditDeck).DeckShips; } return(new Api_req_Transport().GetMaterialNum(area_id, tanker_count, deckShip)); }
private void repairShipAutoRecovery(DeckShips deck) { int num = 86; int num2 = 19; List <Mem_ship> memShip = deck.getMemShip(); if (memShip.Count() == 0 || memShip[0].Stype != num2) { return; } DamageState damageState = memShip[0].Get_DamageState(); if (damageState != DamageState.Tyuuha && damageState != DamageState.Taiha && !memShip[0].ExistsNdock() && !memShip[0].IsBlingShip()) { Mem_material mem_material = Comm_UserDatas.Instance.User_material[enumMaterialCategory.Fuel]; Mem_material mem_material2 = Comm_UserDatas.Instance.User_material[enumMaterialCategory.Steel]; if (mem_material.Value != 0 || mem_material2.Value != 0) { Dictionary <int, int> mstSlotItemNum_OrderId = memShip[0].GetMstSlotItemNum_OrderId(new HashSet <int> { num }); int num3 = mstSlotItemNum_OrderId[num]; memShip = memShip.Take(num3 + 2).ToList(); foreach (Mem_ship item in memShip) { if (item.Nowhp < item.Maxhp) { DamageState damageState2 = item.Get_DamageState(); if (damageState2 != DamageState.Tyuuha && damageState2 != DamageState.Taiha && !item.ExistsNdock() && !item.IsBlingShip()) { int ndockTimeSpan = item.GetNdockTimeSpan(); int num4 = ndockTimeSpan * 30; int num5 = 30; double num6 = (double)num5 / (double)num4; Dictionary <enumMaterialCategory, int> ndockMaterialNum = item.GetNdockMaterialNum(); int num7 = (int)Math.Ceiling((double)ndockMaterialNum[enumMaterialCategory.Fuel] * num6); int num8 = (int)Math.Ceiling((double)ndockMaterialNum[enumMaterialCategory.Steel] * num6); if (mem_material.Value >= num7 && mem_material2.Value >= num8) { double num9 = (double)(item.Maxhp - item.Nowhp) * num6; int num10 = (!(num9 < 1.0)) ? ((int)num9) : ((int)Math.Ceiling(num9)); item.SubHp(-num10); mem_material.Sub_Material(num7); mem_material2.Sub_Material(num8); } } } } } } }
protected void _Update(DeckShips deck_ships, Dictionary <int, ShipModel> ships) { List <int> list = new List <int>(); for (int i = 0; i < deck_ships.Count(); i++) { list.Add(deck_ships[i]); } _ships = new List <ShipModel>(); for (int j = 0; j < list.Count; j++) { ShipModel item = ships[list[j]]; _ships.Add(item); } }
public bool UnsetAllOrganize() { DeckShips deckShip = _edit_deck.DeckShips; if (deckShip.Count() <= 1) { return(false); } if (_api.Change_TempDeck(0, -2, ref deckShip)) { base.UserInfo.__UpdateTemporaryEscortDeck__(_edit_deck); return(true); } return(false); }
public bool UnsetOrganize(int selected_index) { if (!_api.IsValidChange(_edit_deck.Id, selected_index, -1, _edit_deck.DeckShips)) { return(false); } DeckShips deckShip = _edit_deck.DeckShips; if (_api.Change_TempDeck(selected_index, -1, ref deckShip)) { base.UserInfo.__UpdateTemporaryEscortDeck__(_edit_deck); return(true); } return(false); }
protected void _Update(DeckShips deck_ships, Dictionary <int, ShipModel> ships) { List <int> list = new List <int>(); for (int i = 0; i < deck_ships.Count(); i++) { list.Add(deck_ships[i]); } this._ships = new List <ShipModel>(); for (int j = 0; j < list.get_Count(); j++) { ShipModel shipModel = ships.get_Item(list.get_Item(j)); this._ships.Add(shipModel); } }
public Api_Result <Mem_esccort_deck> Change(int deck_rid, DeckShips deckShip) { Api_Result <Mem_esccort_deck> api_Result = new Api_Result <Mem_esccort_deck>(); Mem_esccort_deck deck = null; List <int> lastTempResult = null; deckShip.Clone(out lastTempResult); if (!Comm_UserDatas.Instance.User_EscortDeck.TryGetValue(deck_rid, out deck)) { api_Result.state = Api_Result_State.Parameter_Error; return(api_Result); } List <int> out_ships = null; deck.Ship.Clone(out out_ships); Dictionary <int, Mem_ship> cloneShips = deck.Ship.getMemShip().ToDictionary((Mem_ship rid) => rid.Rid, (Mem_ship obj) => obj); deck.Ship.Clear(); int count = lastTempResult.Count; for (int i = 0; i < count; i++) { deck.Ship[i] = lastTempResult[i]; Comm_UserDatas.Instance.User_ship[deck.Ship[i]].BlingWaitToStop(); } out_ships.ForEach(delegate(int ship_rid) { if (!lastTempResult.Contains(ship_rid) && Comm_UserDatas.Instance.Temp_escortship.Contains(ship_rid)) { cloneShips[ship_rid].BlingWait(deck.Maparea_id, Mem_ship.BlingKind.WaitEscort); } }); if (deck.Ship.Count() > 0 && deck.Disposition_status == DispositionStatus.NONE) { deck.GoArea(deck.Maparea_id); } else if (deck.Ship.Count() == 0) { deck.EscortStop(); } else if (deck.Disposition_status == DispositionStatus.ARRIVAL && deck.GetBlingTurn() == 0 && deck.Ship.getMemShip().All((Mem_ship x) => x.GetBlingTurn() > 0)) { deck.EscortStop(); deck.GoArea(deck.Maparea_id); } api_Result.data = deck; return(api_Result); }
public bool ChangeOrganize(int selected_index, int ship_mem_id) { if (!this._api.IsValidChange(this._edit_deck.Id, selected_index, ship_mem_id, this._edit_deck.DeckShips)) { return(false); } DeckShips deckShips = this._edit_deck.DeckShips; bool flag = this._api.Change_TempDeck(selected_index, ship_mem_id, ref deckShips); if (flag) { base.UserInfo.__UpdateTemporaryEscortDeck__(this._edit_deck); return(true); } return(true); }
public bool UnsetAllOrganize() { DeckShips deckShips = this._edit_deck.DeckShips; if (deckShips.Count() <= 1) { return(false); } bool flag = this._api.Change_TempDeck(0, -2, ref deckShips); if (flag) { base.UserInfo.__UpdateTemporaryEscortDeck__(this._edit_deck); return(true); } return(false); }
public Dictionary <enumMaterialCategory, int> GetMaterialNum(int area_id, int tankerNum, DeckShips deckShip) { Dictionary <enumMaterialCategory, int> addValues = new Dictionary <enumMaterialCategory, int>(); foreach (object value2 in Enum.GetValues(typeof(enumMaterialCategory))) { addValues.Add((enumMaterialCategory)(int)value2, 0); } Mst_maparea value = null; if (!Mst_DataManager.Instance.Mst_maparea.TryGetValue(area_id, out value)) { return(addValues); } DeckShips deckShip2 = (deckShip != null) ? deckShip : Comm_UserDatas.Instance.User_EscortDeck[area_id].Ship; value.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, tankerNum, ref addValues, randMaxFlag: true, deckShip2); return(addValues); }
private void TakeMaterial(ref Dictionary <enumMaterialCategory, int> add_mat, ref Dictionary <enumMaterialCategory, int> summaryBase) { IEnumerable <IGrouping <int, Mem_tanker> > areaEnableTanker = Mem_tanker.GetAreaEnableTanker(Comm_UserDatas.Instance.User_tanker); if (Enumerable.Count <IGrouping <int, Mem_tanker> >(areaEnableTanker) == 0) { return; } using (IEnumerator <IGrouping <int, Mem_tanker> > enumerator = areaEnableTanker.GetEnumerator()) { while (enumerator.MoveNext()) { IGrouping <int, Mem_tanker> current = enumerator.get_Current(); Mst_maparea mst_maparea = Mst_DataManager.Instance.Mst_maparea.get_Item(current.get_Key()); DeckShips ship = Comm_UserDatas.Instance.User_EscortDeck.get_Item(current.get_Key()).Ship; mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, Enumerable.Count <Mem_tanker>(current), ref add_mat, false, ship); mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, Enumerable.Count <Mem_tanker>(current), ref summaryBase, true, ship); } } int materialMaxNum = Comm_UserDatas.Instance.User_basic.GetMaterialMaxNum(); using (Dictionary <enumMaterialCategory, int> .Enumerator enumerator2 = add_mat.GetEnumerator()) { while (enumerator2.MoveNext()) { KeyValuePair <enumMaterialCategory, int> current2 = enumerator2.get_Current(); int num = 0; int num2 = Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Value + current2.get_Value(); int num3 = materialMaxNum - num2; if (num3 >= 0) { num = current2.get_Value(); } else if (materialMaxNum > Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Value) { num = materialMaxNum - Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Value; } Comm_UserDatas.Instance.User_material.get_Item(current2.get_Key()).Add_Material(num); } } }
public Dictionary <enumMaterialCategory, int> GetMaterialNum(int area_id, int tankerNum, DeckShips deckShip) { Dictionary <enumMaterialCategory, int> dictionary = new Dictionary <enumMaterialCategory, int>(); using (IEnumerator enumerator = Enum.GetValues(typeof(enumMaterialCategory)).GetEnumerator()) { while (enumerator.MoveNext()) { object current = enumerator.get_Current(); dictionary.Add((enumMaterialCategory)((int)current), 0); } } Mst_maparea mst_maparea = null; if (!Mst_DataManager.Instance.Mst_maparea.TryGetValue(area_id, ref mst_maparea)) { return(dictionary); } DeckShips deckShip2 = (deckShip != null) ? deckShip : Comm_UserDatas.Instance.User_EscortDeck.get_Item(area_id).Ship; mst_maparea.TakeMaterialNum(Comm_UserDatas.Instance.User_mapclear, tankerNum, ref dictionary, true, deckShip2); return(dictionary); }
public Api_Result <Dictionary <int, Mem_ship> > Ship(int area_id) { List <DeckShips> list = new List <DeckShips>(); Mem_esccort_deck mem_esccort_deck = Enumerable.FirstOrDefault <Mem_esccort_deck>(Comm_UserDatas.Instance.User_EscortDeck.get_Values(), (Mem_esccort_deck x) => x.Maparea_id == area_id); if (mem_esccort_deck != null) { list.Add(mem_esccort_deck.Ship); } IEnumerable <DeckShips> enumerable = Enumerable.Select <Mem_deck, DeckShips>(Enumerable.Where <Mem_deck>(Comm_UserDatas.Instance.User_deck.get_Values(), (Mem_deck deck) => deck.Area_id == area_id), (Mem_deck deck) => deck.Ship); if (Enumerable.Count <DeckShips>(enumerable) > 0) { list.AddRange(enumerable); } if (list.get_Count() == 0) { return(new Api_Result <Dictionary <int, Mem_ship> > { state = Api_Result_State.Parameter_Error }); } List <int> list2 = new List <int>(); using (List <DeckShips> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { DeckShips current = enumerator.get_Current(); List <int> list3 = null; current.Clone(out list3); list2.AddRange(list3); } } return(this.Ship(list2)); }
public bool IsValidChange(int deck_rid, int deck_targetIdx, int ship_rid) { Mem_deck deck = null; if (!Comm_UserDatas.Instance.User_deck.TryGetValue(deck_rid, ref deck)) { return(false); } if (deck.MissionState != MissionStates.NONE || deck.IsActionEnd) { return(false); } List <int> list = new List <int>(); if (ship_rid == -2) { if (deck.Ship.Count() == 0) { return(false); } deck.Ship.Clone(out list); list.RemoveAt(0); } else if (ship_rid == -1) { list.Add(deck.Ship[deck_targetIdx]); } else { list.Add(ship_rid); list.Add(deck.Ship[deck_targetIdx]); bool flag = Enumerable.Any <Mem_ndock>(Comm_UserDatas.Instance.User_ndock.get_Values(), (Mem_ndock x) => x.Ship_id == ship_rid && x.Area_id != deck.Area_id); if (flag) { return(false); } } if (Enumerable.Any <Mem_esccort_deck>(Comm_UserDatas.Instance.User_EscortDeck.get_Values(), (Mem_esccort_deck escort) => escort.Ship.Find(ship_rid) != -1)) { return(false); } if (ship_rid == -2 || (ship_rid == -1 && deck_targetIdx == 0 && deck.Rid == 1)) { return(deck.Ship.Count() > 1); } if (ship_rid == -1) { return(deck.Area_id == 1 || deck.Ship.Count() != 1); } Mem_ship mem_ship = null; if (!Comm_UserDatas.Instance.User_ship.TryGetValue(ship_rid, ref mem_ship)) { return(false); } if (mem_ship.IsBlingShip()) { return(false); } if (mem_ship.BlingType == Mem_ship.BlingKind.WaitEscort) { return(false); } if (mem_ship.BlingType == Mem_ship.BlingKind.WaitDeck && mem_ship.BlingWaitArea != deck.Area_id) { return(false); } DeckShips deckShips = null; deck.Ship.Clone(out deckShips); int[] array = deck.Search_ShipIdx(ship_rid); Func <DeckShips, bool> func = delegate(DeckShips x) { int num = x.Count(); List <string> list2 = new List <string>(); for (int i = 0; i < num; i++) { int ship_id = Comm_UserDatas.Instance.User_ship.get_Item(x[i]).Ship_id; list2.Add(Mst_DataManager.Instance.Mst_ship.get_Item(ship_id).Yomi); } IEnumerable <IGrouping <string, string> > enumerable = Enumerable.GroupBy <string, string>(list2, (string y) => y); return(Enumerable.Count <IGrouping <string, string> >(enumerable) == Enumerable.Count <string>(list2)); }; if (array[0] == deck_rid) { deckShips[array[1]] = deckShips[deck_targetIdx]; } else if (array[0] != -1) { Mem_deck mem_deck = Comm_UserDatas.Instance.User_deck.get_Item(array[0]); if (mem_deck.MissionState != MissionStates.NONE || mem_deck.IsActionEnd) { return(false); } if (mem_deck.Area_id != deck.Area_id) { return(false); } DeckShips deckShips2 = null; mem_deck.Ship.Clone(out deckShips2); deckShips2[array[1]] = deckShips[deck_targetIdx]; if (mem_deck.Rid == 1 && deckShips2.Count() == 0) { return(false); } if (deckShips2.Count() == 0 && mem_deck.Area_id != 1) { return(false); } if (!func.Invoke(deckShips2)) { return(false); } } deckShips[deck_targetIdx] = ship_rid; return(func.Invoke(deckShips) && !deckShips.Equals(deck.Ship)); }
public bool IsValidChange(int deck_rid, int deck_targetIdx, int ship_rid, DeckShips deckShip) { initEscortGroup(); Mem_esccort_deck value = null; if (!Comm_UserDatas.Instance.User_EscortDeck.TryGetValue(deck_rid, out value)) { return(false); } List <int> unsetShips = null; if (ship_rid == -2) { if (deckShip.Count() <= 1) { return(false); } deckShip.Clone(out unsetShips); unsetShips.RemoveAt(0); } else if (ship_rid == -1) { unsetShips = new List <int> { deckShip[deck_targetIdx] }; } else { if (ship_rid == deckShip[deck_targetIdx]) { return(false); } int stype = Comm_UserDatas.Instance.User_ship[ship_rid].Stype; if (Mst_DataManager.Instance.Mst_stype[stype].IsSubmarine()) { return(false); } unsetShips = new List <int> { ship_rid }; } DeckShips out_ships = null; deckShip.Clone(out out_ships); Change_TempDeck(deck_targetIdx, ship_rid, ref out_ships); if (!validEscortStypeCheck(out_ships, -1)) { return(false); } Mem_ndock mem_ndock = Comm_UserDatas.Instance.User_ndock.Values.FirstOrDefault((Mem_ndock x) => unsetShips.Contains(x.Ship_id) ? true : false); if (mem_ndock != null) { return(false); } if (unsetShips.Any(delegate(int bling_rid) { Mem_ship value3 = null; return(Comm_UserDatas.Instance.User_ship.TryGetValue(bling_rid, out value3) && value3.IsBlingShip()); })) { return(false); } if (ship_rid < 0) { return(true); } if (Comm_UserDatas.Instance.User_deck.Values.Any((Mem_deck x) => x.Ship.Find(ship_rid) != -1)) { return(false); } if (Comm_UserDatas.Instance.User_EscortDeck.Values.Any((Mem_esccort_deck x) => x.Rid != deck_rid && x.Ship.Find(ship_rid) != -1)) { return(false); } Func <DeckShips, bool> func = delegate(DeckShips x) { int num = x.Count(); List <string> list = new List <string>(); for (int i = 0; i < num; i++) { int ship_id = Comm_UserDatas.Instance.User_ship[x[i]].Ship_id; list.Add(Mst_DataManager.Instance.Mst_ship[ship_id].Yomi); } IEnumerable <IGrouping <string, string> > source = from y in list group y by y; return((source.Count() == list.Count()) ? true : false); }; Mem_ship value2 = null; if (!Comm_UserDatas.Instance.User_ship.TryGetValue(ship_rid, out value2)) { return(false); } if (value2.IsBlingShip()) { return(false); } if (value2.BlingType == Mem_ship.BlingKind.WaitDeck) { return(false); } if (value2.BlingType == Mem_ship.BlingKind.WaitEscort && value2.BlingWaitArea != value.Maparea_id) { return(false); } if (deckShip.Equals(out_ships)) { return(false); } if (!func(out_ships)) { return(false); } return(true); }
public bool IsValidChange(int deck_rid, int deck_targetIdx, int ship_rid, DeckShips deckShip) { Api_req_Transport.< IsValidChange > c__AnonStorey4BC <IsValidChange> c__AnonStorey4BC = new Api_req_Transport.< IsValidChange > c__AnonStorey4BC();
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); } } } } } } } }