示例#1
0
        public static bool CanDrop(int templateId)
        {
            bool result;

            if (DropInfoMgr.DropInfo == null)
            {
                result = true;
            }
            else
            {
                DropInfoMgr.m_lock.AcquireWriterLock(-1);
                try
                {
                    if (DropInfoMgr.DropInfo.ContainsKey(templateId))
                    {
                        MacroDropInfo mdi = DropInfoMgr.DropInfo[templateId];
                        if (mdi.DropCount < mdi.MaxDropCount || mdi.SelfDropCount >= mdi.DropCount)
                        {
                            mdi.SelfDropCount++;
                            mdi.DropCount++;
                            result = true;
                            return(result);
                        }
                        result = false;
                        return(result);
                    }
                }
                catch (Exception e)
                {
                    //if (DropInfoMgr.log.IsErrorEnabled)
                    {
                        DropInfoMgr.log.Error("DropInfoMgr CanDrop", e);
                    }
                }
                finally
                {
                    DropInfoMgr.m_lock.ReleaseWriterLock();
                }
                result = true;
            }
            return(result);
        }
示例#2
0
 public static bool CanDrop(int templateId)
 {
     if (DropInfo == null)
     {
         return(true);
     }
     m_lock.AcquireWriterLock(Timeout.Infinite);
     try
     {
         if (DropInfo.ContainsKey(templateId))
         {
             MacroDropInfo mdi = DropInfo[templateId];
             if (mdi.DropCount < mdi.MaxDropCount || mdi.SelfDropCount >= mdi.DropCount)
             {
                 mdi.SelfDropCount++;
                 mdi.DropCount++;
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("DropInfoMgr CanDrop", e);
         }
     }
     finally
     {
         m_lock.ReleaseWriterLock();
     }
     //不包含该物品,直接返回true
     return(true);
 }
示例#3
0
 public static bool CanDrop(int templateId)
 {
     if (DropInfoMgr.DropInfo == null)
     {
         return(true);
     }
     DropInfoMgr.m_lock.AcquireWriterLock(15000);
     try
     {
         if (DropInfoMgr.DropInfo.ContainsKey(templateId))
         {
             MacroDropInfo macroDropInfo = DropInfoMgr.DropInfo[templateId];
             bool          result;
             if (macroDropInfo.DropCount < macroDropInfo.MaxDropCount || macroDropInfo.SelfDropCount >= macroDropInfo.DropCount)
             {
                 macroDropInfo.SelfDropCount++;
                 macroDropInfo.DropCount++;
                 result = true;
                 return(result);
             }
             result = false;
             return(result);
         }
     }
     catch (Exception exception)
     {
         if (DropInfoMgr.log.IsErrorEnabled)
         {
             DropInfoMgr.log.Error("DropInfoMgr CanDrop", exception);
         }
     }
     finally
     {
         DropInfoMgr.m_lock.ReleaseWriterLock();
     }
     return(true);
 }
 public void HandleMacroDrop(GSPacketIn pkg)
 {
     Dictionary<int, MacroDropInfo> temp = new Dictionary<int, MacroDropInfo>();
     int count = pkg.ReadInt();
     for (int i = 0; i < count; i++)
     {
         int templateId = pkg.ReadInt();
         int dropcount = pkg.ReadInt();
         int maxCount = pkg.ReadInt();
         MacroDropInfo mdi = new MacroDropInfo(dropcount, maxCount);
         temp.Add(templateId, mdi);
     }
     MacroDropMgr.UpdateDropInfo(temp);
 }