public static bool VIPRewardDrop(int level, ref List <ItemInfo> info) { int dropId = DropInventory.GetDropCondiction(eDropType.VIP, level.ToString(), "1"); bool result; if (dropId > 0) { List <DropItem> unFiltItems = DropMgr.FindDropItem(dropId); for (int i = 0; i < unFiltItems.Count; i++) { int itemCount = DropInventory.random.Next(unFiltItems[i].BeginData, unFiltItems[i].EndData); ItemTemplateInfo temp = ItemMgr.FindItemTemplate(unFiltItems[i].ItemId); ItemInfo item = ItemInfo.CreateFromTemplate(temp, itemCount, level); if (item != null) { item.IsBinds = unFiltItems[i].IsBind; item.ValidDate = unFiltItems[i].ValueDate; item.IsTips = unFiltItems[i].IsTips; item.IsLogs = unFiltItems[i].IsLogs; if (info == null) { info = new List <ItemInfo>(); } info.Add(item); } } result = true; } else { result = false; } return(result); }
private static bool GetDropItems(eDropType type, int dropId, ref List <ItemInfo> itemInfos) { if (dropId == 0) { return(false); } try { int num = 1; List <DropItem> source = DropMgr.FindDropItem(dropId); int maxRound = ThreadSafeRandom.NextStatic(( from s in source select s.Random).Max()); List <DropItem> list = ( from s in source where s.Random >= maxRound select s).ToList <DropItem>(); int num2 = list.Count <DropItem>(); bool result; if (num2 == 0) { result = false; return(result); } num = ((num > num2) ? num2 : num); int[] randomUnrepeatArray = DropInventory.GetRandomUnrepeatArray(0, num2 - 1, num); int[] array = randomUnrepeatArray; for (int i = 0; i < array.Length; i++) { int index = array[i]; int count = ThreadSafeRandom.NextStatic(list[index].BeginData, list[index].EndData); ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(list[index].ItemId); ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, count, 101); if (itemInfo != null) { itemInfo.IsBinds = list[index].IsBind; itemInfo.ValidDate = list[index].ValueDate; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } if (DropInfoMgr.CanDrop(itemTemplateInfo.TemplateID)) { itemInfos.Add(itemInfo); } } } result = true; return(result); } catch (Exception ex) { if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } return(false); }
private static bool GetDropItems(eDropType type, int dropId, ref List <ItemInfo> itemInfos) { bool result; if (dropId == 0) { result = false; } else { try { int dropItemCount = 1; List <DropItem> unFiltItems = DropMgr.FindDropItem(dropId); int maxRound = DropInventory.random.Next(( from s in unFiltItems select s.Random).Max()); List <DropItem> filtItems = ( from s in unFiltItems where s.Random >= maxRound select s).ToList <DropItem>(); int maxItems = filtItems.Count <DropItem>(); if (maxItems == 0) { result = false; return(result); } dropItemCount = ((dropItemCount > maxItems) ? maxItems : dropItemCount); int[] randomArray = DropInventory.GetRandomUnrepeatArray(0, maxItems - 1, dropItemCount); int[] array = randomArray; for (int j = 0; j < array.Length; j++) { int i = array[j]; int itemCount = DropInventory.random.Next(filtItems[i].BeginData, filtItems[i].EndData); ItemTemplateInfo temp = ItemMgr.FindItemTemplate(filtItems[i].ItemId); ItemInfo item = ItemInfo.CreateFromTemplate(temp, itemCount, 101); if (item != null) { item.IsBinds = filtItems[i].IsBind; item.ValidDate = filtItems[i].ValueDate; item.IsTips = filtItems[i].IsTips; item.IsLogs = filtItems[i].IsLogs; if (itemInfos == null) { itemInfos = new List <ItemInfo>(); } switch (type) { case eDropType.Cards: case eDropType.Box: case eDropType.NPC: case eDropType.Boss: case eDropType.Special: if (DropInfoMgr.CanDrop(temp.TemplateID)) { itemInfos.Add(item); } break; default: itemInfos.Add(item); break; } } } if (itemInfos != null && itemInfos.Count > 0) { result = true; return(result); } } catch (Exception ex) { //if (DropInventory.log.IsErrorEnabled) { DropInventory.log.Error(string.Concat(new object[] { "Drop Error:", type, " @ ", ex })); } } result = false; } return(result); }