public static Dictionary <int, List <ItemBoxInfo> > LoadItemBoxs(ItemBoxInfo[] itemBoxs) { Dictionary <int, List <ItemBoxInfo> > dictionary = new Dictionary <int, List <ItemBoxInfo> >(); for (int index = 0; index < itemBoxs.Length; ++index) { ItemBoxInfo info = itemBoxs[index]; if (!Enumerable.Contains <int>((IEnumerable <int>)dictionary.Keys, info.DataId)) { IEnumerable <ItemBoxInfo> source = Enumerable.Where <ItemBoxInfo>((IEnumerable <ItemBoxInfo>)itemBoxs, (Func <ItemBoxInfo, bool>)(s => s.DataId == info.DataId)); dictionary.Add(info.DataId, Enumerable.ToList <ItemBoxInfo>(source)); } } return(dictionary); }
public static XElement CreateItemBox(ItemBoxInfo m) { return(new XElement("Item", new object[] { new XAttribute("ID", m.DataId), new XAttribute("TemplateId", m.TemplateId), new XAttribute("StrengthenLevel", m.StrengthenLevel), new XAttribute("IsBind", m.IsBind), new XAttribute("ItemCount", m.ItemCount), new XAttribute("LuckCompose", m.LuckCompose), new XAttribute("DefendCompose", m.DefendCompose), new XAttribute("AttackCompose", m.AttackCompose), new XAttribute("AgilityCompose", m.AgilityCompose), new XAttribute("ItemValid", m.ItemValid) })); }
public ItemBoxInfo InitItemBoxInfo(SqlDataReader reader) { ItemBoxInfo info = new ItemBoxInfo(); info.Id = (int)reader["id"]; info.DataId = (int)reader["DataId"]; info.TemplateId = (int)reader["TemplateId"]; info.IsSelect = (bool)reader["IsSelect"]; info.IsBind = (bool)reader["IsBind"]; info.ItemValid = (int)reader["ItemValid"]; info.ItemCount = (int)reader["ItemCount"]; info.StrengthenLevel = (int)reader["StrengthenLevel"]; info.AttackCompose = (int)reader["AttackCompose"]; info.DefendCompose = (int)reader["DefendCompose"]; info.AgilityCompose = (int)reader["AgilityCompose"]; info.LuckCompose = (int)reader["LuckCompose"]; info.Random = (int)reader["Random"]; return(info); }
public static ItemBoxInfo FindSpecialItemBox(int DataId) { ItemBoxInfo itemBoxInfo = new ItemBoxInfo(); if (DataId <= -300) { if (DataId != -1100) { if (DataId == -300) { itemBoxInfo.TemplateId = 11420; itemBoxInfo.ItemCount = 1; } } else { itemBoxInfo.TemplateId = 11213; itemBoxInfo.ItemCount = 1; } } else if (DataId != -200) { if (DataId != -100) { if (DataId == 11408) { itemBoxInfo.TemplateId = 11420; itemBoxInfo.ItemCount = 1; } } else { itemBoxInfo.TemplateId = 11233; itemBoxInfo.ItemCount = 1; } } else { itemBoxInfo.TemplateId = 112244; itemBoxInfo.ItemCount = 1; } return(itemBoxInfo); }
//public void SaveJsonData() //{ // JsonData jsonUnitydata; // LoadJson(out jsonUnitydata, PlayerJsonData); // int num = GameData.Instance.hasCards; // int loof = 0; // //주의 key 값이 ID와 일치함.순서 0,1,2가 아님 // foreach (KeyValuePair<int, Card> pair in GameData.Instance.hasCard) // { // do // { // jsonUnitydata["hasCard"][loof]["item_id"] = pair.Value.ID; // jsonUnitydata["hasCard"][loof]["hasNum"] = pair.Value.hasCard; // jsonUnitydata["hasCard"][loof]["hasLevel"] = pair.Value.level; // loof++; // break; // } // while ( loof < num); // } // //선택창의 숫자는 정해져 있어서 그냥씀 // int selDeckNum = jsonUnitydata["SelectDek"].Count; // foreach (KeyValuePair<int, int[]> pair in GameData.Instance.playerSelectDecks) // { // for (int i = 0; i < selDeckNum; i++) // { // if (pair.Key == i) // { // jsonUnitydata["SelectDek"][i]["item_id1"] = pair.Value[0]; // jsonUnitydata["SelectDek"][i]["item_id2"] = pair.Value[1]; // jsonUnitydata["SelectDek"][i]["item_id3"] = pair.Value[2]; // jsonUnitydata["SelectDek"][i]["item_id4"] = pair.Value[3]; // jsonUnitydata["SelectDek"][i]["item_id5"] = pair.Value[4]; // jsonUnitydata["SelectDek"][i]["item_id6"] = pair.Value[5]; // jsonUnitydata["SelectDek"][i]["item_id7"] = pair.Value[6]; // jsonUnitydata["SelectDek"][i]["item_id8"] = pair.Value[7]; // } // } // } // JsonData whitedata = JsonMapper.ToJson(jsonUnitydata); // File.WriteAllText(Application.streamingAssetsPath +"/"+ PlayerJsonData+".json", whitedata.ToString()); //} public void ParsingMarket() { // JsonData jsonUnitydata = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/Resources/Data/MarketJsonData.json")); JsonData jsonUnitydata; LoadJson(out jsonUnitydata, MarketJsonData); int length = (int)jsonUnitydata["Market"]["DaySale"].Count; for (int i = 0; i < length; i++) { MarketInfo day = new MarketInfo(); day.ID = (int)jsonUnitydata["Market"]["DaySale"][i]["item-id1"]; day.Gold = (int)jsonUnitydata["Market"]["DaySale"][i]["PriceCoin"]; day.Jew = (int)jsonUnitydata["Market"]["DaySale"][i]["PriceJew"]; day.EA = (int)jsonUnitydata["Market"]["DaySale"][i]["EA"]; GameData.Instance.dailys.Add(i, day); } int length4 = (int)jsonUnitydata["Market"]["NorSale"].Count; for (int i = 0; i < length4; i++) { //버튼의또는 케이스의 세팅을위한 Data NorInfo newNor = new NorInfo(); newNor.caseName = (string)jsonUnitydata["Market"]["NorSale"][i]["Type"]; newNor.PriceGold = (int)jsonUnitydata["Market"]["NorSale"][i]["PriceGold"]; GameData.Instance.nors.Add(i, newNor); } int length1 = (int)jsonUnitydata["Market"]["RoyleSale"].Count; for (int i = 0; i < length1; i++) { MarketRoyle royle = new MarketRoyle(); royle.Jew = (int)jsonUnitydata["Market"]["RoyleSale"][i]["PriceJew"]; royle.CaseName = (string)jsonUnitydata["Market"]["RoyleSale"][i]["BoxName"]; royle.CaseIndex = (int)jsonUnitydata["Market"]["RoyleSale"][i]["case"]; GameData.Instance.royles.Add(i, royle); } int length2 = (int)jsonUnitydata["Market"]["ItemBox"].Count; for (int i = 0; i < length2; i++) { MarketItemBoxInfo itemBoxs = new MarketItemBoxInfo(); itemBoxs.Type = (string)jsonUnitydata["Market"]["ItemBox"][i]["Type"]; itemBoxs.PGold = (int)jsonUnitydata["Market"]["ItemBox"][i]["presentCoin"]; itemBoxs.General = (int)jsonUnitydata["Market"]["ItemBox"][i]["generalUnit"]; itemBoxs.Rare = (int)jsonUnitydata["Market"]["ItemBox"][i]["rareUnit"]; itemBoxs.Hero = (int)jsonUnitydata["Market"]["ItemBox"][i]["heroUnit"]; itemBoxs.Legendary = (int)jsonUnitydata["Market"]["ItemBox"][i]["legendaryUnit"]; GameData.Instance.itemBoxs.Add(i, itemBoxs); } // "lunchyCase": // {"Gold":1800,"Jew":2,"generalNum":192,"rareNum":50,"heroNum":8,"lengendaryNum":1} ItemBoxInfo newItemBox = new ItemBoxInfo(); newItemBox.boxName = "lunchyCase"; //newItemBox.Jew = (int)jsonUnitydata["Market"]["lunchyCase"][0]["Jew"]; newItemBox.generalNum = (int)jsonUnitydata["Market"]["lunchyCase"][0]["generalNum"]; newItemBox.RareNum = (int)jsonUnitydata["Market"]["lunchyCase"][0]["rareNum"]; newItemBox.HeroNum = (int)jsonUnitydata["Market"]["lunchyCase"][0]["heroNum"]; newItemBox.LengendaryNum = (int)jsonUnitydata["Market"]["lunchyCase"][0]["lengendaryNum"]; newItemBox.productNum = (int)jsonUnitydata["Market"]["lunchyCase"][0]["product"]; //상품품목의 갯수 //여기 문제 GameData.Instance.dic_SetItems.Add("lunchyCase", newItemBox); ItemBoxInfo newItemBox2 = new ItemBoxInfo(); newItemBox2.boxName = "HeroCase"; newItemBox2.HeroNum = (int)jsonUnitydata["Market"]["HeroCase"][0]["heroNum1"]; newItemBox2.HeroNum = (int)jsonUnitydata["Market"]["HeroCase"][0]["heroNum2"]; newItemBox2.HeroNum = (int)jsonUnitydata["Market"]["HeroCase"][0]["heroNum3"]; newItemBox2.productNum = (int)jsonUnitydata["Market"]["HeroCase"][0]["product"]; GameData.Instance.dic_SetItems.Add("HeroCase", newItemBox2); ItemBoxInfo newItemBox3 = new ItemBoxInfo(); newItemBox3.boxName = "legendaryCase"; newItemBox3.LengendaryNum = (int)jsonUnitydata["Market"]["legendaryCase"][0]["legendaryNum"]; newItemBox3.productNum = (int)jsonUnitydata["Market"]["legendaryCase"][0]["product"]; GameData.Instance.dic_SetItems.Add("legendaryCase", newItemBox3); }
public static bool CreateItemBox(int DateId, List <ItemInfo> itemInfos, ref int gold, ref int point, ref int giftToken, ref int medal) { List <ItemBoxInfo> list = new List <ItemBoxInfo>(); List <ItemBoxInfo> list2 = ItemBoxMgr.FindItemBox(DateId); if (list2 == null) { return(false); } list = ( from s in list2 where s.IsSelect select s).ToList <ItemBoxInfo>(); int num = 1; int maxRound = 0; foreach (ItemBoxInfo current in list2) { if (!current.IsSelect || maxRound >= current.Random) { maxRound = current.Random; } } maxRound = ItemBoxMgr.random.Next(maxRound); List <ItemBoxInfo> list3 = ( from s in list2 where !s.IsSelect && s.Random >= maxRound select s).ToList <ItemBoxInfo>(); int num2 = list3.Count <ItemBoxInfo>(); if (num2 > 0) { num = ((num > num2) ? num2 : num); int[] randomUnrepeatArray = ItemBoxMgr.GetRandomUnrepeatArray(0, num2 - 1, num); int[] array = randomUnrepeatArray; for (int i = 0; i < array.Length; i++) { int index = array[i]; ItemBoxInfo item = list3[index]; if (list == null) { list = new List <ItemBoxInfo>(); } list.Add(item); } } foreach (ItemBoxInfo current2 in list) { if (current2 == null) { return(false); } int templateId = current2.TemplateId; if (templateId <= -800) { if (templateId <= -1000) { if (templateId == -1100) { giftToken += current2.ItemCount; continue; } if (templateId == -1000) { continue; } } else { if (templateId == -900 || templateId == -800) { continue; } } } else { if (templateId <= -200) { if (templateId == -300) { medal += current2.ItemCount; continue; } if (templateId == -200) { point += current2.ItemCount; continue; } } else { if (templateId == -100) { gold += current2.ItemCount; continue; } if (templateId == 11408) { medal += current2.ItemCount; continue; } } } ItemTemplateInfo goods = ItemMgr.FindItemTemplate(current2.TemplateId); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(goods, current2.ItemCount, 101); if (itemInfo != null) { itemInfo.Count = current2.ItemCount; itemInfo.IsBinds = current2.IsBind; itemInfo.ValidDate = current2.ItemValid; itemInfo.StrengthenLevel = current2.StrengthenLevel; itemInfo.AttackCompose = current2.AttackCompose; itemInfo.DefendCompose = current2.DefendCompose; itemInfo.AgilityCompose = current2.AgilityCompose; itemInfo.LuckCompose = current2.LuckCompose; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } itemInfos.Add(itemInfo); } } return(true); }
/// <summary> /// 生成一条箱子里面的物品 /// </summary> /// <param name="DateId">传入箱子物品</param> /// <returns></returns> public static bool CreateItemBox(int DateId, List <ItemInfo> itemInfos, ref int gold, ref int point, ref int giftToken, ref int medal) { #region 生成物品 List <ItemBoxInfo> FiltInfos = new List <ItemBoxInfo>(); List <ItemBoxInfo> unFiltInfos = FindItemBox(DateId); if (unFiltInfos == null) { return(false); } FiltInfos = unFiltInfos.Where(s => s.IsSelect == true).ToList(); int dropItemCount = 1;//设置掉落数量 int maxRound = Bussiness.ThreadSafeRandom.NextStatic(unFiltInfos.Where(s => s.IsSelect == false).Select(s => s.Random).Max()); List <ItemBoxInfo> RoundInfos = unFiltInfos.Where(s => s.IsSelect == false && s.Random >= maxRound).ToList(); int maxItems = RoundInfos.Count(); if (maxItems > 0) { dropItemCount = dropItemCount > maxItems ? maxItems : dropItemCount; int[] randomArray = GetRandomUnrepeatArray(0, maxItems - 1, dropItemCount); foreach (int i in randomArray) { ItemBoxInfo item = RoundInfos[i]; if (FiltInfos == null) { FiltInfos = new List <ItemBoxInfo>(); } FiltInfos.Add(item); } } #endregion #region 输出物品 foreach (ItemBoxInfo info in FiltInfos) { if (info == null) { return(false); } switch (info.TemplateId) { case -100: gold += info.ItemCount; break; case -200: point += info.ItemCount; break; case -300: giftToken += info.ItemCount; break; case 11408: medal += info.ItemCount; break; default: ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(info.TemplateId); ItemInfo item = ItemInfo.CreateFromTemplate(temp, info.ItemCount, 101); if (item == null) { continue; } item.IsBinds = info.IsBind; item.ValidDate = info.ItemValid; item.StrengthenLevel = info.StrengthenLevel; item.AttackCompose = info.AttackCompose; item.DefendCompose = info.DefendCompose; item.AgilityCompose = info.AgilityCompose; item.LuckCompose = info.LuckCompose; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } itemInfos.Add(item); break; } } return(true); #endregion }
public static bool CreateItemBox(int DateId, List <ItemInfo> itemInfos, ref int gold, ref int point, ref int giftToken, ref int gp) { List <ItemBoxInfo> FiltInfos = new List <ItemBoxInfo>(); List <ItemBoxInfo> unFiltInfos = ItemBoxMgr.FindItemBox(DateId); bool result; if (unFiltInfos == null) { result = false; } else { FiltInfos = ( from s in unFiltInfos where s.IsSelect select s).ToList <ItemBoxInfo>(); int dropItemCount = 1; int maxRound = 0; foreach (ItemBoxInfo boxInfo in unFiltInfos) { if (!boxInfo.IsSelect && maxRound < boxInfo.Random) { maxRound = boxInfo.Random; } } maxRound = ItemBoxMgr.random.Next(maxRound); List <ItemBoxInfo> RoundInfos = ( from s in unFiltInfos where !s.IsSelect && s.Random >= maxRound select s).ToList <ItemBoxInfo>(); int maxItems = RoundInfos.Count <ItemBoxInfo>(); if (maxItems > 0) { dropItemCount = ((dropItemCount > maxItems) ? maxItems : dropItemCount); int[] randomArray = ItemBoxMgr.GetRandomUnrepeatArray(0, maxItems - 1, dropItemCount); int[] array = randomArray; for (int j = 0; j < array.Length; j++) { int i = array[j]; ItemBoxInfo item = RoundInfos[i]; if (FiltInfos == null) { FiltInfos = new List <ItemBoxInfo>(); } FiltInfos.Add(item); } } foreach (ItemBoxInfo info in FiltInfos) { if (info == null) { result = false; return(result); } int templateId = info.TemplateId; if (templateId <= -200) { if (templateId == -300) { giftToken += info.ItemCount; continue; } if (templateId == -200) { point += info.ItemCount; continue; } } else { if (templateId == -100) { gold += info.ItemCount; continue; } if (templateId == 11107) { gp += info.ItemCount; continue; } } ItemTemplateInfo temp = ItemMgr.FindItemTemplate(info.TemplateId); ItemInfo item2 = ItemInfo.CreateFromTemplate(temp, info.ItemCount, 101); if (item2 != null) { item2.IsBinds = info.IsBind; item2.ValidDate = info.ItemValid; item2.StrengthenLevel = info.StrengthenLevel; item2.AttackCompose = info.AttackCompose; item2.DefendCompose = info.DefendCompose; item2.AgilityCompose = info.AgilityCompose; item2.LuckCompose = info.LuckCompose; item2.IsTips = info.IsTips; item2.IsLogs = info.IsLogs; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } itemInfos.Add(item2); } } result = true; } return(result); }
public static bool CreateItemBox(int DateId, List <SqlDataProvider.Data.ItemInfo> itemInfos, ref int gold, ref int point, ref int giftToken, ref int medal, ref int exp) { List <ItemBoxInfo> list1 = new List <ItemBoxInfo>(); List <ItemBoxInfo> itemBox = ItemBoxMgr.FindItemBox(DateId); if (itemBox == null) { return(false); } List <ItemBoxInfo> list2 = Enumerable.ToList <ItemBoxInfo>(Enumerable.Where <ItemBoxInfo>((IEnumerable <ItemBoxInfo>)itemBox, (Func <ItemBoxInfo, bool>)(s => s.IsSelect))); int num1 = 1; int maxRound = 0; if (list2.Count < itemBox.Count) { maxRound = ThreadSafeRandom.NextStatic(Enumerable.Max(Enumerable.Select <ItemBoxInfo, int>(Enumerable.Where <ItemBoxInfo>((IEnumerable <ItemBoxInfo>)itemBox, (Func <ItemBoxInfo, bool>)(s => !s.IsSelect)), (Func <ItemBoxInfo, int>)(s => s.Random)))); } List <ItemBoxInfo> list3 = Enumerable.ToList <ItemBoxInfo>(Enumerable.Where <ItemBoxInfo>((IEnumerable <ItemBoxInfo>)itemBox, (Func <ItemBoxInfo, bool>)(s => !s.IsSelect && s.Random >= maxRound))); int num2 = Enumerable.Count <ItemBoxInfo>((IEnumerable <ItemBoxInfo>)list3); if (num2 > 0) { int count = num1 > num2 ? num2 : num1; foreach (int index in ItemBoxMgr.GetRandomUnrepeatArray(0, num2 - 1, count)) { ItemBoxInfo itemBoxInfo = list3[index]; if (list2 == null) { list2 = new List <ItemBoxInfo>(); } list2.Add(itemBoxInfo); } } foreach (ItemBoxInfo itemBoxInfo in list2) { if (itemBoxInfo == null) { return(false); } int templateId = itemBoxInfo.TemplateId; if (templateId <= -900) { if (templateId <= -1100) { if (templateId == -1200 || templateId == -1100) { giftToken += itemBoxInfo.ItemCount; continue; } } else if (templateId == -1000 || templateId == -900) { continue; } } else if (templateId <= -300) { if (templateId != -800) { if (templateId == -300) { medal += itemBoxInfo.ItemCount; continue; } } else { continue; } } else if (templateId == -200) { point += itemBoxInfo.ItemCount; continue; } else if (templateId == -100) { gold += itemBoxInfo.ItemCount; continue; } else if (templateId == 11107) { exp += itemBoxInfo.ItemCount; continue; } SqlDataProvider.Data.ItemInfo fromTemplate = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(itemBoxInfo.TemplateId), itemBoxInfo.ItemCount, 101); if (fromTemplate != null) { fromTemplate.Count = itemBoxInfo.ItemCount; fromTemplate.IsBinds = itemBoxInfo.IsBind; fromTemplate.ValidDate = itemBoxInfo.ItemValid; fromTemplate.StrengthenLevel = itemBoxInfo.StrengthenLevel; fromTemplate.AttackCompose = itemBoxInfo.AttackCompose; fromTemplate.DefendCompose = itemBoxInfo.DefendCompose; fromTemplate.AgilityCompose = itemBoxInfo.AgilityCompose; fromTemplate.LuckCompose = itemBoxInfo.LuckCompose; fromTemplate.IsTips = itemBoxInfo.IsTips != 0; fromTemplate.IsLogs = itemBoxInfo.IsLogs; if (itemInfos == null) { itemInfos = new List <SqlDataProvider.Data.ItemInfo>(); } itemInfos.Add(fromTemplate); } } return(true); }