Example #1
0
 /// <summary>
 /// 查询条件后的物品
 /// </summary>
 /// <param name="type"></param>
 /// <param name="para1"></param>
 /// <param name="para2"></param>
 /// <returns></returns>
 public static int FindCondiction(eDropType type, string para1, string para2)
 {
     int itemId = 0;
     string temppara1 = "," + para1 + ",";
     string temppara2 = "," + para2 + ",";
     foreach (DropCondiction drop in m_dropcondiction)
     {
         if ((drop.CondictionType == (int)type) && (drop.Para1.IndexOf(temppara1) !=-1) && (drop.Para2.IndexOf(temppara2) != -1))
             return drop.DropId;
     }
     return 0;
 }
Example #2
0
        /// <summary>
        /// 获取掉落多个物品
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private static bool GetDropItems(eDropType type, int dropId, ref List<ItemInfo> itemInfos)
        {
            #region 定义变量
            if (dropId == 0)
                return false;
            #endregion

            try
            {
                #region 生成随机物品
                int dropItemCount = 1;
                List<DropItem> unFiltItems = Bussiness.Managers.DropMgr.FindDropItem(dropId);
                int maxRound = Bussiness.ThreadSafeRandom.NextStatic(unFiltItems.Select(s => s.Random).Max());
                List<DropItem> filtItems = unFiltItems.Where(s => s.Random >= maxRound).ToList();
                int maxItems = filtItems.Count();
                if (maxItems == 0)
                {
                    return false;
                }
                else
                {
                    dropItemCount = dropItemCount > maxItems ? maxItems : dropItemCount;
                }
                int[] randomArray = GetRandomUnrepeatArray(0, maxItems - 1, dropItemCount);
                #endregion

                #region 设置随机物品属性
                foreach (int i in randomArray)
                {
                    int itemCount = Bussiness.ThreadSafeRandom.NextStatic(filtItems[i].BeginData, filtItems[i].EndData);
                    ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(filtItems[i].ItemId);
                    ItemInfo item = ItemInfo.CreateFromTemplate(temp, itemCount, 101);
                    if (item == null)
                        continue;
                    item.IsBinds = filtItems[i].IsBind;
                    item.ValidDate = filtItems[i].ValueDate;
                    if (itemInfos == null)
                        itemInfos = new List<ItemInfo>();
                    if (DropInfoMgr.CanDrop(temp.TemplateID))//宏观掉落
                    {
                        itemInfos.Add(item);
                    }
                }
                return true;
                #endregion
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                    log.Error("Drop Error:" + type + " @ " + ex);
            }
            return false;
        }
Example #3
0
 /// <summary>
 /// 检测是否满足掉落条件
 /// </summary>
 /// <param name="type">掉落类型</param>
 /// <param name="para1">掉落参数一</param>
 /// <param name="para2">掉落参数二</param>
 /// <returns>返回物品id</returns>
 private static int GetDropCondiction(eDropType type, string para1, string para2)
 {
     try
     {
         int dropId = Bussiness.Managers.DropMgr.FindCondiction(type, para1, para2);
         return dropId;
     }
     catch (Exception ex)
     {
         if (log.IsErrorEnabled)
             log.Error("Drop Error:" + type + " @ " + ex);
     }
     return 0;
 }