Exemplo n.º 1
0
        public static List <ItemBoxInfo> FindItemBoxAward(int DataId)
        {
            List <ItemBoxInfo> list  = ItemBoxMgr.FindItemBox(DataId);
            List <ItemBoxInfo> list2 = new List <ItemBoxInfo>();

            foreach (ItemBoxInfo current in list)
            {
                if (current.TemplateId > 0)
                {
                    list2.Add(current);
                }
                else
                {
                    int templateId = current.TemplateId;
                    if (templateId <= -300)
                    {
                        if (templateId != -1100)
                        {
                            if (templateId == -300)
                            {
                                current.TemplateId = 11420;
                                current.ItemCount  = 1;
                            }
                        }
                        else
                        {
                            current.TemplateId = 11213;
                            current.ItemCount  = 1;
                        }
                    }
                    else
                    {
                        if (templateId != -200)
                        {
                            if (templateId != -100)
                            {
                                if (templateId == 11408)
                                {
                                    current.TemplateId = 11420;
                                    current.ItemCount  = 1;
                                }
                            }
                            else
                            {
                                current.TemplateId = 11233;
                                current.ItemCount  = 1;
                            }
                        }
                        else
                        {
                            current.TemplateId = 112244;
                            current.ItemCount  = 1;
                        }
                    }
                    list2.Add(current);
                }
            }
            return(list2);
        }
Exemplo n.º 2
0
        public static List <SqlDataProvider.Data.ItemInfo> GetAllItemBoxAward(int DataId)
        {
            List <ItemBoxInfo> itemBox = ItemBoxMgr.FindItemBox(DataId);
            List <SqlDataProvider.Data.ItemInfo> list = new List <SqlDataProvider.Data.ItemInfo>();

            foreach (ItemBoxInfo itemBoxInfo in itemBox)
            {
                SqlDataProvider.Data.ItemInfo fromTemplate = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(itemBoxInfo.TemplateId), itemBoxInfo.ItemCount, 105);
                fromTemplate.IsBinds   = itemBoxInfo.IsBind;
                fromTemplate.ValidDate = itemBoxInfo.ItemValid;
                list.Add(fromTemplate);
            }
            return(list);
        }
Exemplo n.º 3
0
        public static List <ItemInfo> GetItemBoxAward(int DataId)
        {
            List <ItemBoxInfo> list  = ItemBoxMgr.FindItemBox(DataId);
            List <ItemInfo>    list2 = new List <ItemInfo>();

            foreach (ItemBoxInfo current in list)
            {
                ItemInfo itemInfo = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(current.TemplateId), current.ItemCount, 105);
                itemInfo.IsBinds   = current.IsBind;
                itemInfo.ValidDate = current.ItemValid;
                list2.Add(itemInfo);
            }
            return(list2);
        }
Exemplo n.º 4
0
 public static bool ReLoad()
 {
     try
     {
         ItemBoxInfo[] array = ItemBoxMgr.LoadItemBoxDb();
         Dictionary <int, List <ItemBoxInfo> > value = ItemBoxMgr.LoadItemBoxs(array);
         if (array != null)
         {
             Interlocked.Exchange <ItemBoxInfo[]>(ref ItemBoxMgr.m_itemBox, array);
             Interlocked.Exchange <Dictionary <int, List <ItemBoxInfo> > >(ref ItemBoxMgr.m_itemBoxs, value);
         }
     }
     catch (Exception exception)
     {
         if (ItemBoxMgr.log.IsErrorEnabled)
         {
             ItemBoxMgr.log.Error("ReLoad", exception);
         }
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
 public static bool ReLoad()
 {
     try
     {
         ItemBoxInfo[] itemBoxs = ItemBoxMgr.LoadItemBoxDb();
         Dictionary <int, List <ItemBoxInfo> > dictionary = ItemBoxMgr.LoadItemBoxs(itemBoxs);
         if (itemBoxs != null)
         {
             Interlocked.Exchange <ItemBoxInfo[]>(ref ItemBoxMgr.m_itemBox, itemBoxs);
             Interlocked.Exchange <Dictionary <int, List <ItemBoxInfo> > >(ref ItemBoxMgr.m_itemBoxs, dictionary);
         }
     }
     catch (Exception ex)
     {
         if (ItemBoxMgr.log.IsErrorEnabled)
         {
             ItemBoxMgr.log.Error((object)"ReLoad", ex);
         }
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
        public static bool ReLoad()
        {
            bool result;

            try
            {
                ItemBoxInfo[] tempItemBox = ItemBoxMgr.LoadItemBoxDb();
                Dictionary <int, List <ItemBoxInfo> > tempItemBoxs = ItemBoxMgr.LoadItemBoxs(tempItemBox);
                if (tempItemBox != null)
                {
                    Interlocked.Exchange <ItemBoxInfo[]>(ref ItemBoxMgr.m_itemBox, tempItemBox);
                    Interlocked.Exchange <Dictionary <int, List <ItemBoxInfo> > >(ref ItemBoxMgr.m_itemBoxs, tempItemBoxs);
                }
            }
            catch (Exception e)
            {
                ItemBoxMgr.log.Error("ReLoad", e);

                result = false;
                return(result);
            }
            result = true;
            return(result);
        }
Exemplo n.º 7
0
 public static bool Init()
 {
     return(ItemBoxMgr.ReLoad());
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }