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()
        {
            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);
        }