コード例 #1
0
ファイル: Action5106.cs プロジェクト: zxx0367/Scut-samples
        public override bool TakeAction()
        {
            UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);

            if (RankingHelper.IsGainSportsReward(ContextUser.UserID) && dailyRestrain != null && dailyRestrain.UserExtend != null)
            {
                var envSet = ServerEnvSet.Get(ServerEnvKey.JingJiChangReward, "");
                SportsRewardInfo sportsInfo = new ConfigCacheSet <SportsRewardInfo>().FindKey(dailyRestrain.UserExtend.UserRankID);
                { if (envSet != null && sportsInfo != null)
                  {
                      if (envSet.ToDateTime().Date > dailyRestrain.Funtion11.Date && dailyRestrain.UserExtend.UserRankID > 0)
                      {
                          dailyRestrain.Funtion11             = DateTime.Now;
                          dailyRestrain.UserExtend.UserRankID = 0;
                          //dailyRestrain.Update();

                          ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, sportsInfo.RewardObtian, int.MaxValue);
                          ContextUser.GameCoin  = MathUtils.Addition(ContextUser.GameCoin, sportsInfo.RewardGoin, int.MaxValue);
                          //ContextUser.Update();
                          UserHelper.Contribution(ContextUser.UserID, sportsInfo.RewardObtian);
                          ErrorInfo = string.Format(LanguageManager.GetLang().St5106_JingJiChangRankReward, sportsInfo.RewardObtian, sportsInfo.RewardGoin);
                      }
                  }
                }
            }
            return(true);
        }
コード例 #2
0
 public override bool TakeAction()
 {
     if (_isCurr == 0)
     {
         var bossFirst = ServerEnvSet.Get(ServerEnvKey.FirstHalfBoss, 0);
         if (!string.IsNullOrEmpty(bossFirst))
         {
             int total;
             var tempList = JsonUtils.Deserialize <List <BossUser> >(bossFirst);
             if (tempList != null && tempList.Count > 0)
             {
                 _bossUserList = tempList.GetPaging(1, Top, out total);
                 _rankingNo    = tempList.FindIndex(m => m.UserId == Uid) + 1;
                 var killUserId = ServerEnvSet.GetInt(ServerEnvKey.KillBossUserID, 0);
                 var killUser   = tempList.Find(t => t.UserId == killUserId.ToString());
                 if (killUser != null)
                 {
                     _damageNum = killUser.DamageNum;
                     _nickName  = killUser.NickName;
                     var userEntity = new PersonalCacheStruct <GameUser>().FindKey(killUserId.ToString());
                     if (userEntity != null)
                     {
                         _userLv = userEntity.UserLv;
                     }
                 }
             }
         }
     }
     else if (_isCurr == 1)
     {
         BossCombat bossCombat = new BossCombat(_activeId);
         GameActive gameActive = bossCombat.GameActive;
         if (gameActive == null)
         {
             return(true);
         }
         CombatStatus combatStatus = gameActive.CombatStatus;
         if (combatStatus == CombatStatus.Wait || combatStatus == CombatStatus.Combat)
         {
             int total;
             var tempList = bossCombat.RefreshRanking();
             _bossUserList = tempList.GetPaging(1, Top, out total);
             _rankingNo    = tempList.FindIndex(m => m.UserId == Uid) + 1;
             var killUserId = ServerEnvSet.GetInt(ServerEnvKey.KillBossUserID, 0);
             var killUser   = tempList.Find(t => t.UserId == killUserId.ToString());
             if (killUser != null)
             {
                 _damageNum = killUser.DamageNum;
                 _nickName  = killUser.NickName;
                 var userEntity = new PersonalCacheStruct <GameUser>().FindKey(killUserId.ToString());
                 if (userEntity != null)
                 {
                     _userLv = userEntity.UserLv;
                 }
             }
         }
     }
     return(true);
 }
コード例 #3
0
        /// <summary>
        /// 世界boss是否已杀
        /// </summary>
        /// <returns></returns>
        public static bool IsBossKill(int activeId)
        {
            GameActive activeInfo = new ShareCacheStruct <GameActive>().FindKey(activeId);
            string     envSet     = ServerEnvSet.Get(ServerEnvKey.BossKillDate, "");

            if (envSet != null && activeInfo != null)
            {
                DateTime killDate = envSet.ToDateTime();
                string[] list     = activeInfo.EnablePeriod.Split(new char[] { ',' });
                //有多个时间段
                foreach (string item in list)
                {
                    DateTime beginTime = item.ToDateTime(DateTime.MinValue);
                    DateTime endTime   = beginTime.AddMinutes(activeInfo.Minutes);
                    if (beginTime < killDate && endTime > killDate)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #4
0
ファイル: RankingHelper.cs プロジェクト: dongliang/Scut
        /// <summary>
        /// 竞技场奖励下次领取时间
        /// </summary>
        /// <returns></returns>
        public static DateTime GetNextReceiveDate()
        {
            DateTime nextReceiveDate = new DateTime();                             //下次领取时间
            DateTime initialDate     = ConfigEnvSet.GetString("Sports.ReceiveBonusTime").ToDateTime();
            int      intervalDate    = ConfigEnvSet.GetInt("Sports.IntervalDate"); //间隔时间 (小时)
            int      intervalHours   = (int)((DateTime.Now - initialDate).TotalHours);
            int      dividedNum      = intervalHours / intervalDate;
            int      totalHuors      = (MathUtils.Addition(dividedNum, 1, int.MaxValue) * intervalDate);

            nextReceiveDate = initialDate.AddHours(totalHuors);
            DateTime nowDate = initialDate.AddHours((dividedNum * intervalDate));

            var date = ServerEnvSet.Get(ServerEnvKey.JingJiChangReward, "");

            if (nowDate != date.ToDateTime().Date)
            {
                ServerEnvSet.Set(ServerEnvKey.JingJiChangReward, nowDate.ToString());
            }
            else
            {
                ServerEnvSet.Set(ServerEnvKey.JingJiChangReward, nextReceiveDate.AddDays(-3).ToString());
            }
            return(nextReceiveDate.Date);
        }