Пример #1
0
 public static void RefreshRestrain(UserDailyRestrain restrain)
 {
     if (restrain.RefreshDate.Date != DateTime.Now.Date)
     {
         restrain.RestrainProperty.Init();
         restrain.RefreshDate = DateTime.Now;
     }
 }
Пример #2
0
        private GameUser CreateRole()
        {
            GameUser user = new GameUser(UserId);
            user.SessionID = Sid;
            user.Pid = Pid;
            user.HeadIcon = HeadID;
            user.RetailId = RetailID;
            user.NickName = UserName;
            user.RealName = "";
            user.Hobby = "";
            user.Profession = "";
            user.Sex = Sex.ToBool();
            user.UserLv = (short)ConfigEnvSet.GetInt("User.Level", 1);
            user.GiftGold = ConfigEnvSet.GetInt("User.GiftGold", 100);
            user.GameCoin = ConfigEnvSet.GetInt("User.GameCoin", 1000);
            user.VipLv = ConfigEnvSet.GetInt("User.VipLv");
            user.UserStatus = UserStatus.Normal;
            user.MsgState = true;
            user.MobileType = MobileType;
            user.ScreenX = ScreenX;
            user.ScreenY = ScreenY;
            user.ClientAppVersion = ReqAppVersion;
            user.LoginDate = DateTime.Now;
            user.CreateDate = DateTime.Now;
            user.TitleId = 1001;
            user.Property.GameId = GameID;
            user.Property.ServerId = ServerID;
            user.Birthday = new DateTime(1970, 1, 1);
            var cacheSet = new GameDataCacheSet<GameUser>();
            cacheSet.Add(user);
            cacheSet.Update();

            //增加初始背包、玩家任务表、玩家成就表
            var itemCacheSet = new GameDataCacheSet<UserItemPackage>();
            itemCacheSet.Add(new UserItemPackage(UserId));
            itemCacheSet.Update();
            var taskCacheSet = new GameDataCacheSet<UserTask>();
            taskCacheSet.Add(new UserTask(UserId));
            taskCacheSet.Update();
            var achieveCacheSet = new GameDataCacheSet<UserAchieve>();
            achieveCacheSet.Add(new UserAchieve(UserId));
            achieveCacheSet.Update();
            UserDailyRestrain restrain = new UserDailyRestrain(UserId);
            restrain.RefreshDate = DateTime.Now.AddDays(-1);
            var restrainCacheSet = new GameDataCacheSet<UserDailyRestrain>();
            restrainCacheSet.Add(restrain);
            restrainCacheSet.Update();
            return user;
        }