private int takeBonusDevKit() { Dictionary <int, Mst_maparea> .ValueCollection values = Mst_DataManager.Instance.Mst_maparea.Values; Comm_UserDatas instance = Comm_UserDatas.Instance; int num = 0; foreach (Mst_maparea item in values) { int mapinfo_no = Mst_maparea.MaxMapNum(Comm_UserDatas.Instance.User_basic.Difficult, item.Id); int key = Mst_mapinfo.ConvertMapInfoId(item.Id, mapinfo_no); Mem_mapclear value = null; if (instance.User_mapclear.TryGetValue(key, out value) && value.State == MapClearState.Cleard) { num++; } } int num2 = num + 4; int value2 = Comm_UserDatas.Instance.User_material[enumMaterialCategory.Dev_Kit].Value; int num3 = value2 + num2; int materialLimit = Mst_DataManager.Instance.Mst_item_limit[1].GetMaterialLimit(Mst_DataManager.Instance.Mst_item_limit, enumMaterialCategory.Dev_Kit); if (num3 > materialLimit) { num2 = materialLimit - value2; if (num2 < 0) { num2 = 0; } } Comm_UserDatas.Instance.User_material[enumMaterialCategory.Dev_Kit].Add_Material(num2); return(num2); }
private bool isLastDance(DifficultKind kind) { if (mst_mapinfo.Maparea_id != 17) { return(false); } int num = Mst_maparea.MaxMapNum(kind, 17); if (mst_mapinfo.No == num && mst_enemy.Boss != 0) { return(true); } return(false); }
public static bool IsGameClear() { Dictionary <int, Mem_mapclear> user_mapclear = Comm_UserDatas.Instance.User_mapclear; if (user_mapclear == null) { return(false); } int num = 17; DifficultKind difficult = Comm_UserDatas.Instance.User_basic.Difficult; int mapinfo_no = Mst_maparea.MaxMapNum(difficult, num); int num2 = Mst_mapinfo.ConvertMapInfoId(num, mapinfo_no); return(user_mapclear.ContainsKey(num2) && user_mapclear.get_Item(num2).Cleared); }
public void LostArea(int maparea_id, List <int> sortieDeckRid) { Comm_UserDatas commInstance = Comm_UserDatas.Instance; if (sortieDeckRid == null) { sortieDeckRid = new List <int>(); } List <int> lostArea = getLostArea(maparea_id); lostArea.ForEach(delegate(int lostAreaId) { Dictionary <int, Mem_mapclear> dictionary = (from x in commInstance.User_mapclear.Values where x.Maparea_id == lostAreaId select x).ToDictionary((Mem_mapclear x) => x.Mapinfo_no, (Mem_mapclear y) => y); int num = Mst_maparea.MaxMapNum(commInstance.User_basic.Difficult, lostAreaId); for (int i = 1; i <= num; i++) { if (!dictionary.ContainsKey(i)) { int mapinfo_id = Mst_mapinfo.ConvertMapInfoId(lostAreaId, i); Mem_mapclear mem_mapclear = new Mem_mapclear(mapinfo_id, lostAreaId, i, MapClearState.InvationClose); mem_mapclear.Insert(); dictionary.Add(i, mem_mapclear); } } lostMapClear(dictionary.Values.ToList(), Mst_DataManager.Instance.Mst_maparea[lostAreaId].Neighboring_area); Comm_UserDatas.Instance.User_rebellion_point.Remove(lostAreaId); List <Mem_tanker> areaTanker = Mem_tanker.GetAreaTanker(lostAreaId); lostTanker(areaTanker); IEnumerable <Mem_deck> memDeck = from x in commInstance.User_deck.Values where x.Area_id == lostAreaId select x; goBackDeck(memDeck, sortieDeckRid); Mem_esccort_deck escort = commInstance.User_EscortDeck[lostAreaId]; goBackEscortDeck(escort); List <Mem_ndock> ndock = (from x in commInstance.User_ndock.Values where x.Area_id == lostAreaId select x).ToList(); lostNdock(ndock); Dictionary <enumMaterialCategory, Mem_material> user_material = commInstance.User_material; lostMaterial(user_material); if (lostAreaId == 1) { lostKdock(); } }); }
private void lostMapClear(List <Mem_mapclear> ownMapClear, List <int> neighboringArea) { ownMapClear.ForEach(delegate(Mem_mapclear x) { x.StateChange(MapClearState.InvationClose); }); neighboringArea.ForEach(delegate(int area) { int mapinfo_no = Mst_maparea.MaxMapNum(Comm_UserDatas.Instance.User_basic.Difficult, area); int key = Mst_mapinfo.ConvertMapInfoId(area, mapinfo_no); if (Comm_UserDatas.Instance.User_mapclear.TryGetValue(key, out Mem_mapclear value) && value.State != MapClearState.InvationClose) { value.StateChange(MapClearState.InvationNeighbor); } }); }
private void updateHistory(bool winFlag, List <int> openMaps, bool takeAwayBattle) { int total_turn = Comm_UserDatas.Instance.User_turn.Total_turn; foreach (int openMap in openMaps) { if (Mem_history.IsFirstOpenArea(openMap)) { Mem_history mem_history = new Mem_history(); mem_history.SetAreaOpen(total_turn, openMap); Comm_UserDatas.Instance.Add_History(mem_history); } } Mem_history mem_history2 = null; if (winFlag) { int mapClearNum = Mem_history.GetMapClearNum(mst_mapinfo.Id); int num = Mst_maparea.MaxMapNum(Comm_UserDatas.Instance.User_basic.Difficult, mst_mapinfo.Maparea_id); if (mst_mapinfo.Maparea_id == 17 && mst_mapinfo.No == num) { mem_history2 = new Mem_history(); mem_history2.SetGameClear(total_turn); } else if (mapClearNum == 1) { mem_history2 = new Mem_history(); mem_history2.SetMapClear(total_turn, mst_mapinfo.Id, mapClearNum, F_Data.ShipData[0].Ship_id); } else if (mapClearNum <= 3 && takeAwayBattle) { mem_history2 = new Mem_history(); mem_history2.SetMapClear(total_turn, mst_mapinfo.Id, mapClearNum, F_Data.ShipData[0].Ship_id); } } if (mem_history2 != null) { Comm_UserDatas.Instance.Add_History(mem_history2); } }
private int takeBonusDevKit() { Dictionary <int, Mst_maparea> .ValueCollection values = Mst_DataManager.Instance.Mst_maparea.get_Values(); Comm_UserDatas instance = Comm_UserDatas.Instance; int num = 0; using (Dictionary <int, Mst_maparea> .ValueCollection.Enumerator enumerator = values.GetEnumerator()) { while (enumerator.MoveNext()) { Mst_maparea current = enumerator.get_Current(); int mapinfo_no = Mst_maparea.MaxMapNum(Comm_UserDatas.Instance.User_basic.Difficult, current.Id); int num2 = Mst_mapinfo.ConvertMapInfoId(current.Id, mapinfo_no); Mem_mapclear mem_mapclear = null; if (instance.User_mapclear.TryGetValue(num2, ref mem_mapclear)) { if (mem_mapclear.State == MapClearState.Cleard) { num++; } } } } int num3 = num + 4; int value = Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Dev_Kit).Value; int num4 = value + num3; int materialLimit = Mst_DataManager.Instance.Mst_item_limit.get_Item(1).GetMaterialLimit(Mst_DataManager.Instance.Mst_item_limit, enumMaterialCategory.Dev_Kit); if (num4 > materialLimit) { num3 = materialLimit - value; if (num3 < 0) { num3 = 0; } } Comm_UserDatas.Instance.User_material.get_Item(enumMaterialCategory.Dev_Kit).Add_Material(num3); return(num3); }
public bool MapReOpen(Mem_mapclear clearData, out List <int> reOpenMap) { reOpenMap = new List <int>(); if (clearData.State != 0) { return(false); } Dictionary <int, Mem_mapclear> dictionary = (from data in Comm_UserDatas.Instance.User_mapclear.Values where data.State == MapClearState.InvationClose && data.Mapinfo_no == 1 select data).ToDictionary((Mem_mapclear key) => key.Rid, (Mem_mapclear value) => value); if (dictionary.Count == 0) { return(true); } Dictionary <int, Mst_maparea> mst_maparea = Mst_DataManager.Instance.Mst_maparea; int maparea_id = clearData.Maparea_id; int num = Mst_maparea.MaxMapNum(Comm_UserDatas.Instance.User_basic.Difficult, clearData.Maparea_id); bool flag = (clearData.Mapinfo_no == num) ? true : false; new Dictionary <int, List <int> >(); Dictionary <int, List <int> > dictionary2 = new Dictionary <int, List <int> >(); foreach (Mem_mapclear value3 in dictionary.Values) { Mst_mapinfo mst_mapinfo = Mst_DataManager.Instance.Mst_mapinfo[value3.Rid]; if (mst_mapinfo.Required_ids.Contains(clearData.Rid)) { dictionary2.Add(value3.Maparea_id, mst_mapinfo.Required_ids); } else if (flag && mst_maparea[value3.Maparea_id].Neighboring_area.Contains(maparea_id)) { if (value3.Maparea_id == 7 || value3.Maparea_id == 8) { dictionary2.Add(value3.Maparea_id, new List <int> { Mst_mapinfo.ConvertMapInfoId(1, 4) }); } else { List <int> list = mst_mapinfo.Required_ids.ToList(); list.Add(clearData.Rid); dictionary2.Add(value3.Maparea_id, list); } } } if (dictionary2.Count == 0) { return(true); } bool result = false; foreach (KeyValuePair <int, List <int> > item in dictionary2) { int areaId = item.Key; List <int> value2 = item.Value; if (value2.Count == 0) { throw new Exception(); } if (mapReOpenCheck(value2)) { result = true; IEnumerable <Mem_mapclear> enumerable = from x in Comm_UserDatas.Instance.User_mapclear.Values where x.Maparea_id == areaId select x; foreach (Mem_mapclear item2 in enumerable) { item2.StateChange(MapClearState.InvationOpen); reOpenMap.Add(item2.Rid); } } } return(result); }
private BattleResultFmt getData() { BattleResultFmt ret = new BattleResultFmt(); if (!practiceFlag) { ret.QuestName = mst_mapinfo.Name; } ret.EnemyName = E_Data.Enemy_Name; E_Data.ShipData.ForEach(delegate(Mem_ship x) { ret.EnemyId.Add(x.Ship_id); }); ret.WinRank = getWinRank(); if (isMvpGet(ret.WinRank)) { Dictionary <int, BattleShipSubInfo> subInfoDict = F_SubInfo.Values.ToDictionary((BattleShipSubInfo key) => key.DeckIdx, (BattleShipSubInfo value) => value); int mvp = getMvp(ret.WinRank, subInfoDict); ret.MvpShip = mvp; } Mem_record user_record = Comm_UserDatas.Instance.User_record; int addValue; if (!practiceFlag) { int num = Mst_maparea.MaxMapNum(Comm_UserDatas.Instance.User_basic.Difficult, mst_mapinfo.Maparea_id); ret.GetBaseExp = mst_enemy.Experience; ret.GetShipExp = getShipExpSortie(ret.WinRank, ret.MvpShip, ret.GetBaseExp); addValue = getUserExpSortie(ret.WinRank); SerializableDictionary <int, List <int> > lvupInfo = null; updateShip(ret.WinRank, ret.MvpShip, ret.GetShipExp, out lvupInfo); ret.LevelUpInfo = lvupInfo; bool flag = Utils.IsBattleWin(ret.WinRank); bool takeAwayBattle = false; if (cleard != null && (cleard.State == MapClearState.InvationNeighbor || cleard.State == MapClearState.InvationOpen)) { takeAwayBattle = true; } if (flag) { List <ItemGetFmt> list = new List <ItemGetFmt>(); ItemGetFmt getShip = null; bool flag2 = isLastDance(Comm_UserDatas.Instance.User_basic.Difficult); if (!flag2) { getRewardShip(ret.WinRank, out getShip); if (getShip != null) { if (Comm_UserDatas.Instance.User_turn.Total_turn <= 100 && Comm_UserDatas.Instance.User_ship.Values.Any((Mem_ship x) => x.Ship_id == getShip.Id)) { getRewardShip(ret.WinRank, out getShip); } if (getShip != null && Comm_UserDatas.Instance.User_ship.Values.Any((Mem_ship x) => x.Ship_id == getShip.Id)) { getRewardShip(ret.WinRank, out getShip); } } } else { getClearShip(Comm_UserDatas.Instance.User_basic.Difficult, ret.WinRank, out getShip); } if (getShip != null) { addShip(getShip.Id, flag2); list.Add(getShip); } if (list.Count > 0) { ret.GetItem = list; } if (!isRebellionBattle) { List <int> diffMapOpen = null; List <int> reOpenMap = null; ret.FirstClear = updateMapComp(out diffMapOpen, out reOpenMap); ret.NewOpenMapId = diffMapOpen; ret.ReOpenMapId = reOpenMap; if (ret.FirstClear && Utils.IsGameClear()) { user_record.AddClearDifficult(Comm_UserDatas.Instance.User_basic.Difficult); } else if (ret.FirstClear && mst_mapinfo.No == num) { ItemGetFmt itemGetFmt = new ItemGetFmt(); itemGetFmt.Id = 57; itemGetFmt.Count = 1; itemGetFmt.Category = ItemGetKinds.UseItem; ret.AreaClearRewardItem = itemGetFmt; Comm_UserDatas.Instance.Add_Useitem(itemGetFmt.Id, itemGetFmt.Count); } if (mst_enemy.Boss != 0) { ret.FirstAreaComplete = updateAreaCompHisory(num); } } if (mst_enemy.Boss != 0 && airCellItems != null) { ret.GetAirReconnaissanceItems = airCellItems; } } else if (mst_enemy.Boss != 0 && airCellItems != null) { ret.GetAirReconnaissanceItems = new List <MapItemGetFmt>(); } if (isRebellionBattle) { updateRebellion(ret.WinRank); ret.FirstClear = false; } bool rebellionBoss = (isRebellionBattle && mst_enemy.Boss != 0) ? true : false; user_record.UpdateSortieCount(ret.WinRank, rebellionBoss); if (ret.FirstClear) { ret.GetSpoint = mst_mapinfo.Clear_spoint; Comm_UserDatas.Instance.User_basic.AddPoint(ret.GetSpoint); } deleteLostShip(); if (mst_enemy.Boss != 0) { updateHistory(flag, ret.NewOpenMapId, takeAwayBattle); } } else { ret.GetBaseExp = getBaseExpPractice(ret.WinRank); ret.GetShipExp = getShipExpPractice(ret.WinRank, ret.MvpShip, ret.GetBaseExp); addValue = getUserExpPractice(ret.WinRank, Comm_UserDatas.Instance.User_record.Level, E_Data.ShipData[0].Level); SerializableDictionary <int, List <int> > lvupInfo2 = null; updateShip(ret.WinRank, ret.MvpShip, ret.GetShipExp, out lvupInfo2); updateShipPracticeEnemy(ret.GetShipExp, ref lvupInfo2); ret.LevelUpInfo = lvupInfo2; user_record.UpdatePracticeCount(ret.WinRank, practiceBattle: true); } Comm_UserDatas.Instance.UpdateShipBookBrokenClothState(clothBrokenIds); ret.BasicLevel = user_record.UpdateExp(addValue, Mst_DataManager.Instance.Get_MstLevel(shipTable: false)); return(ret); }