Example #1
0
 public static void RefreshLimitCount()
 {
     try
     {
         Dictionary <int, ShopItemInfo> tempShop     = ShopMgr.m_shop;
         Dictionary <int, int>          tempMaxLimit = new Dictionary <int, int>();
         int[] keys = tempShop.Keys.ToArray <int>();
         for (int i = 0; i < keys.Length; i++)
         {
             if (!tempMaxLimit.ContainsKey(keys[i]))
             {
                 tempMaxLimit.Add(keys[i], tempShop[keys[i]].LimitCount);
             }
         }
         if (tempMaxLimit.Count > 0)
         {
             Interlocked.Exchange <Dictionary <int, int> >(ref ShopMgr.m_LimitCount, tempMaxLimit);
             ShopMgr.InitNotice();
         }
     }
     catch (Exception e)
     {
         ShopMgr.log.Error("ShopInfoMgr", e);
     }
 }
Example #2
0
 public static bool ReLoad()
 {
     try
     {
         Dictionary <int, ShopItemInfo> dictionary = ShopMgr.LoadFromDatabase();
         if (dictionary.Count > 0)
         {
             Interlocked.Exchange <Dictionary <int, ShopItemInfo> >(ref ShopMgr.m_shop, dictionary);
         }
         return(true);
     }
     catch (Exception exception)
     {
         ShopMgr.log.Error("ShopInfoMgr", exception);
     }
     return(false);
 }
Example #3
0
        public static bool ReLoad()
        {
            bool result;

            try
            {
                Dictionary <int, ShopItemInfo> tempShop        = ShopMgr.LoadFromDatabase();
                Dictionary <int, int>          tempMaxLimit    = new Dictionary <int, int>();
                Dictionary <int, List <int> >  tempNoticeInfos = new Dictionary <int, List <int> >();
                foreach (int key in tempShop.Keys)
                {
                    if (!tempMaxLimit.ContainsKey(key))
                    {
                        tempMaxLimit.Add(key, tempShop[key].LimitCount);
                    }
                    if (!tempNoticeInfos.ContainsKey(key) && tempShop[key].LimitCount != -1)
                    {
                        tempNoticeInfos.Add(key, ShopMgr.InitNotice());
                    }
                }
                if (tempShop.Count > 0)
                {
                    Interlocked.Exchange <Dictionary <int, ShopItemInfo> >(ref ShopMgr.m_shop, tempShop);
                    Interlocked.Exchange <Dictionary <int, int> >(ref ShopMgr.m_LimitCount, tempMaxLimit);
                    Interlocked.Exchange <Dictionary <int, List <int> > >(ref ShopMgr.m_isNoticeInfos, tempNoticeInfos);
                }
                result = true;
                return(result);
            }
            catch (Exception e)
            {
                ShopMgr.log.Error("ShopInfoMgr", e);
            }
            result = false;
            return(result);
        }
Example #4
0
 public static bool Init()
 {
     return(ShopMgr.ReLoad());
 }
Example #5
0
        public static List <int> GetShopItemBuyConditions(ShopItemInfo shop, int type, ref int gold, ref int money, ref int offer, ref int gifttoken)
        {
            int iTemplateID = 0;
            int iCount      = 0;

            gold      = 0;
            money     = 0;
            offer     = 0;
            gifttoken = 0;
            List <int> itemsInfo = new List <int>();

            if (!ShopMgr.isTypeIn(shop, type))
            {
                throw new ArgumentNullException("type isn't in!");
            }
            if (type == 1)
            {
                ShopMgr.GetItemPrice(shop.APrice1, shop.AValue1, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
                ShopMgr.GetItemPrice(shop.APrice2, shop.AValue2, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
                ShopMgr.GetItemPrice(shop.APrice3, shop.AValue3, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
            }
            if (type == 2)
            {
                ShopMgr.GetItemPrice(shop.BPrice1, shop.BValue1, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
                ShopMgr.GetItemPrice(shop.BPrice2, shop.BValue2, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
                ShopMgr.GetItemPrice(shop.BPrice3, shop.BValue3, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
            }
            if (type == 3)
            {
                ShopMgr.GetItemPrice(shop.CPrice1, shop.CValue1, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
                ShopMgr.GetItemPrice(shop.CPrice2, shop.CValue2, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
                ShopMgr.GetItemPrice(shop.CPrice3, shop.CValue3, shop.Beat, ref gold, ref money, ref offer, ref gifttoken, ref iTemplateID, ref iCount);
                if (iTemplateID > 0)
                {
                    itemsInfo.Add(iTemplateID);
                    itemsInfo.Add(iCount);
                }
            }
            return(itemsInfo);
        }