Exemple #1
0
 public static bool ReLoad()
 {
     try
     {
         Dictionary <int, FightRateInfo> dictionary = new Dictionary <int, FightRateInfo>();
         if (FightRateMgr.LoadFightRate(dictionary))
         {
             FightRateMgr.m_lock.AcquireWriterLock(15000);
             try
             {
                 FightRateMgr._fightRate = dictionary;
                 return(true);
             }
             catch
             {
             }
             finally
             {
                 FightRateMgr.m_lock.ReleaseWriterLock();
             }
         }
     }
     catch (Exception exception)
     {
         if (FightRateMgr.log.IsErrorEnabled)
         {
             FightRateMgr.log.Error("AwardMgr", exception);
         }
     }
     return(false);
 }
Exemple #2
0
        public static bool ReLoad()
        {
            bool result;

            try
            {
                Dictionary <int, FightRateInfo> tempfightRate = new Dictionary <int, FightRateInfo>();
                if (FightRateMgr.LoadFightRate(tempfightRate))
                {
                    FightRateMgr.m_lock.AcquireWriterLock(-1);
                    try
                    {
                        FightRateMgr._fightRate = tempfightRate;
                        result = true;
                        return(result);
                    }
                    catch
                    {
                    }
                    finally
                    {
                        FightRateMgr.m_lock.ReleaseWriterLock();
                    }
                }
            }
            catch (Exception e)
            {
                //if (FightRateMgr.log.IsErrorEnabled)
                {
                    FightRateMgr.log.Error("AwardMgr", e);
                }
            }
            result = false;
            return(result);
        }
Exemple #3
0
        public static bool CanChangeStyle(BaseRoom game, GSPacketIn pkg)
        {
            FightRateInfo[] infos = FightRateMgr.GetAllFightRateInfo();
            bool            result;

            try
            {
                FightRateInfo[] array = infos;
                for (int i = 0; i < array.Length; i++)
                {
                    FightRateInfo info = array[i];
                    if (info.BeginDay.Year <= DateTime.Now.Year && DateTime.Now.Year <= info.EndDay.Year)
                    {
                        if (info.BeginDay.DayOfYear <= DateTime.Now.DayOfYear && DateTime.Now.DayOfYear <= info.EndDay.DayOfYear)
                        {
                            if (info.BeginTime.TimeOfDay <= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= info.EndTime.TimeOfDay)
                            {
                                if (FightRateMgr.random.Next(1000000) < info.Rate)
                                {
                                    result = true;
                                    return(result);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
            pkg.WriteBoolean(false);
            result = false;
            return(result);
        }
Exemple #4
0
        public static bool Init()
        {
            bool result;

            try
            {
                FightRateMgr.m_lock     = new ReaderWriterLock();
                FightRateMgr._fightRate = new Dictionary <int, FightRateInfo>();
                result = FightRateMgr.LoadFightRate(FightRateMgr._fightRate);
            }
            catch (Exception exception)
            {
                if (FightRateMgr.log.IsErrorEnabled)
                {
                    FightRateMgr.log.Error("AwardMgr", exception);
                }
                result = false;
            }
            return(result);
        }
Exemple #5
0
 public static bool CanChangeStyle(BaseRoom game, GSPacketIn pkg)
 {
     FightRateInfo[] allFightRateInfo = FightRateMgr.GetAllFightRateInfo();
     try
     {
         FightRateInfo[] array = allFightRateInfo;
         for (int i = 0; i < array.Length; i++)
         {
             FightRateInfo fightRateInfo = array[i];
             if (fightRateInfo.BeginDay.Year <= DateTime.Now.Year && DateTime.Now.Year <= fightRateInfo.EndDay.Year && fightRateInfo.BeginDay.DayOfYear <= DateTime.Now.DayOfYear && DateTime.Now.DayOfYear <= fightRateInfo.EndDay.DayOfYear && fightRateInfo.BeginTime.TimeOfDay <= DateTime.Now.TimeOfDay && DateTime.Now.TimeOfDay <= fightRateInfo.EndTime.TimeOfDay && ThreadSafeRandom.NextStatic(1000000) < fightRateInfo.Rate)
             {
                 return(true);
             }
         }
     }
     catch
     {
     }
     pkg.WriteBoolean(false);
     return(false);
 }