本文整理汇总了C#中GameDataCacheSet.Add方法的典型用法代码示例。如果您正苦于以下问题:C# GameDataCacheSet.Add方法的具体用法?C# GameDataCacheSet.Add怎么用?C# GameDataCacheSet.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameDataCacheSet
的用法示例。
在下文中一共展示了GameDataCacheSet.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TakeAction
public override bool TakeAction()
{
var cacheSet = new GameDataCacheSet<GameUser>();
GameUser user = cacheSet.FindKey(_useridreq);
if (null != user)
{
if ((user.UserName != _username)
|| (user.UserType != _usertype))
{
return false;
}
/*更新客户端上报的存档信息*/
user.ClientArchive = _clientarchive;
cacheSet.Add(user);
cacheSet.Update();
return true;
}
else
{
return false;
}
}
示例2: ProcessCmd
protected override void ProcessCmd(string[] args)
{
int magicID = args.Length > 0 ? args[0].Trim().ToInt() : 0;
short magicLv = args.Length > 1 ? args[1].Trim().ToShort() : (short)1;
var cacheSet = new GameDataCacheSet<UserMagic>();
var userMagic = cacheSet.FindKey(UserID, magicID);
MagicInfo magic = new ConfigCacheSet<MagicInfo>().FindKey(magicID);
if (magic == null)
{
return;
}
if (userMagic == null)
{
userMagic = new UserMagic()
{
UserID = UserID,
MagicID = magicID,
MagicLv = magicLv,
IsEnabled = false,
MagicType = magic.MagicType,
};
cacheSet.Add(userMagic);
}
else
{
userMagic.MagicLv = magicLv;
}
}
示例3: CreateUserGeneral
public static short _currMaxLv = GameConfigSet.CurrMaxLv.ToShort(); //玩家最大等级
#endregion Fields
#region Methods
/// <summary>
/// 创建佣兵或佣兵灵魂
/// </summary>
/// <param name="userID"></param>
/// <param name="general"></param>
/// <param name="type"></param>
/// <param name="num"></param>
public static void CreateUserGeneral(string userID, GeneralInfo general, GeneralType type, int num)
{
var cacheSet = new GameDataCacheSet<UserGeneral>();
int generalID = 0;
CareerInfo careerInfo = null;
if (type == GeneralType.YongBing)
{
generalID = general.GeneralID;
careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(general.CareerID);
}
else if (type == GeneralType.Soul)
{
generalID = general.SoulID;
}
if (generalID > 0)
{
UserGeneral userGeneral = new UserGeneral();
userGeneral.UserID = userID;
userGeneral.GeneralID = generalID;
userGeneral.GeneralName = general.GeneralName;
userGeneral.HeadID = general.HeadID;
userGeneral.PicturesID = general.PicturesID;
userGeneral.GeneralLv = 1;
userGeneral.GeneralType = type;
userGeneral.CareerID = general.CareerID;
userGeneral.PowerNum = general.PowerNum;
userGeneral.SoulNum = general.SoulNum;
userGeneral.IntellectNum = general.IntellectNum;
userGeneral.TrainingPower = 0;
userGeneral.TrainingSoul = 0;
userGeneral.TrainingIntellect = 0;
userGeneral.AbilityID = general.AbilityID;
userGeneral.Momentum = 0;
userGeneral.Description = string.Empty;
userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum");
userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong;
userGeneral.CurrExperience = 0;
userGeneral.Experience1 = 0;
userGeneral.Experience2 = 0;
if (careerInfo != null)
{
userGeneral.LifeNum = MathUtils.Addition(general.LifeNum, careerInfo.LifeIncreaseNum * (MathUtils.Subtraction(careerInfo.Lv, (short)1, (short)0)), int.MaxValue);
}
if (type == GeneralType.Soul)
{
userGeneral.AtmanNum = num;
}
userGeneral.HeritageType = HeritageType.Normal;
userGeneral.AbilityNum = 3;
cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod);
}
}
示例4: SendAllowTask
/// <summary>
/// 下发任务
/// </summary>
/// <param name="user"></param>
/// <param name="taskID"></param>
public static List<UserTask> SendAllowTask(GameUser user, int taskID)
{
List<UserTask> userTaskList = new List<UserTask>();
var cacheSet = new GameDataCacheSet<UserTask>();
UserTask preTask = cacheSet.FindKey(user.UserID, taskID);
if (taskID > 0 && preTask != null && (preTask.TaskState != TaskState.Close || preTask.TaskType == TaskType.Offset))
{
return userTaskList;
}
if (taskID == 0 && cacheSet.FindAll(user.UserID, m => m.TaskType < TaskType.Daily).Count > 0)
{
return userTaskList;
}
IList<StoryTaskInfo> taskList = StoryTaskInfo.GetNextTask(taskID);
bool isSend = true;
foreach (StoryTaskInfo taskInfo in taskList)
{
if (taskInfo.CountryID != CountryType.None && user.CountryID != taskInfo.CountryID)
{
continue;
}
UserTask userTask = cacheSet.FindKey(user.UserID, taskInfo.TaskID);
if (userTask == null)
{
userTask = new UserTask
{
TaskID = taskInfo.TaskID,
UserID = user.UserID,
TaskType = taskInfo.TaskType,
TaskState = taskInfo.TaskLv <= user.UserLv ? TaskState.AllowTake : TaskState.NoTake,
CompleteNum = 0,
CreateDate = DateTime.Now
};
cacheSet.Add(userTask);
userTask = cacheSet.FindKey(user.UserID, taskInfo.TaskID);
userTaskList.Add(userTask);
}
else
{
//判断是否已下发过
isSend = false;
break;
}
}
if (isSend)
{
return userTaskList;
}
return new List<UserTask>();
}
示例5: CreateGameuser
/// <summary>
/// 创建用户
/// </summary>
public GameUser CreateGameuser()
{
GameUser newuser = new GameUser(_buserinfo.UserId);
newuser.UserName = _userinfo.UserName;
newuser.UserType = _userinfo.UserType;
newuser.ClientOS = _userinfo.ClientOS;
newuser.ClientVersion = _userinfo.ClientVersion;
newuser.UserMagic = _userinfo.UserMagic;
newuser.UserBirthday = _userinfo.UserBirthday;
var cacheSet = new GameDataCacheSet<GameUser>();
cacheSet.Add(newuser);
cacheSet.Update();
return _userinfo;
}
示例6: Process
private void Process(string userID, int fun)
{
FunctionEnum funEnum = fun.ToEnum<FunctionEnum>();
var cacheSet = new GameDataCacheSet<UserFunction>();
UserFunction userFunction = cacheSet.FindKey(UserID, funEnum);
if (userFunction == null)
{
userFunction = new UserFunction()
{
UserID = userID,
FunEnum = funEnum,
CreateDate = DateTime.Now
};
cacheSet.Add(userFunction, GameEnvironment.CacheUserPeriod);
}
}
示例7: CheckDialNum
/// <summary>
/// 检查每日抽奖次数
/// </summary>
/// <param name="userID"></param>
public static void CheckDialNum(string userID)
{
UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID);
if (userDial != null && userDial.RefreshDate.Date != DateTime.Now.Date)
{
userDial.DialNum = 0;
userDial.RefreshDate = DateTime.Now;
}
if (userDial == null)
{
var cacheSet = new GameDataCacheSet<UserDial>();
userDial = new UserDial();
userDial.UserID = userID;
userDial.HeadID = string.Empty;
userDial.ReturnRatio = 0;
userDial.DialNum = 0;
cacheSet.Add(userDial);
}
}
示例8: Process
private void Process(string userID, int generalID)
{
GeneralInfo generalInfo = new ConfigCacheSet<GeneralInfo>().FindKey(generalID);
if (generalInfo != null)
{
var cacheSet = new GameDataCacheSet<UserGeneral>();
var usergeneral = cacheSet.FindKey(userID, generalID);
if (usergeneral == null)
{
usergeneral = new UserGeneral()
{
UserID = userID,
GeneralID = generalID,
GeneralName = generalInfo.GeneralName,
HeadID = generalInfo.HeadID,
PicturesID = generalInfo.PicturesID,
GeneralLv = generalInfo.GeneralLv,
LifeNum = generalInfo.LifeNum,
GeneralType = GeneralType.YongBing,
CareerID = generalInfo.CareerID,
PowerNum = generalInfo.PowerNum,
SoulNum = generalInfo.SoulNum,
IntellectNum = generalInfo.IntellectNum,
TrainingPower = 0,
TrainingSoul = 0,
TrainingIntellect = 0,
AbilityID = generalInfo.AbilityID,
Momentum = 25,
HitProbability = 85,
GeneralStatus = GeneralStatus.DuiWuZhong,
Experience1 = 0,
Experience2 = 0,
CurrExperience = 0,
Description = string.Empty,
};
cacheSet.Add(usergeneral);
}
}
}
示例9: ProcessCmd
protected override void ProcessCmd(string[] args)
{
int taskID = args.Length > 0 ? args[0].Trim().ToInt() : 0;
GameUser user = new GameDataCacheSet<GameUser>().FindKey(UserID);
if (user == null)
{
UserCacheGlobal.Load(UserID);
user = new GameDataCacheSet<GameUser>().FindKey(UserID);
}
var taskList = StoryTaskInfo.GetNextTask(taskID);
foreach (StoryTaskInfo taskInfo in taskList)
{
if (taskInfo.CountryID != CountryType.None && user.CountryID != taskInfo.CountryID)
{
continue;
}
var cacheSet = new GameDataCacheSet<UserTask>();
UserTask userTask = cacheSet.FindKey(UserID, taskInfo.TaskID);
if (userTask == null)
{
userTask = new UserTask
{
TaskID = taskInfo.TaskID,
UserID = UserID,
TaskType = taskInfo.TaskType,
TaskState = TaskState.AllowTake,
CreateDate = DateTime.Now
};
cacheSet.Add(userTask);
}
else
{
userTask.TaskState = TaskState.AllowTake;
}
}
}
示例10: AddUserAbility
/// <summary>
/// 添加玩家魂技
/// </summary>
/// <param name="abilityId"></param>
/// <param name="userId"></param>
private void AddUserAbility(int abilityId, int userId, int generalID, int position)
{
GameDataCacheSet<UserAbility> _cacheSetAbility = new GameDataCacheSet<UserAbility>();
var userAbility = _cacheSetAbility.FindKey(userId.ToString());
var ability = userAbility != null && userAbility.AbilityList != null
? userAbility.AbilityList.Find(s => s.AbilityID == abilityId)
: null;
var abilityLv = new ConfigCacheSet<AbilityLvInfo>().FindKey(abilityId, 1);
int experienceNum = abilityLv != null ? abilityLv.Experience : 0;
if (userAbility == null)
{
userAbility = new UserAbility(userId);
ability = new Ability();
userAbility.CreateDate = DateTime.Now;
ability.UserItemID = Guid.NewGuid().ToString();
ability.AbilityID = abilityId;
ability.AbilityLv = 1;
ability.GeneralID = generalID;
ability.ExperienceNum = experienceNum;
ability.Position = position;
userAbility.AbilityList.Add(ability);
_cacheSetAbility.Add(userAbility);
}
else
{
ability = new Ability();
ability.UserItemID = Guid.NewGuid().ToString();
userAbility.CreateDate = DateTime.Now;
ability.AbilityID = abilityId;
ability.AbilityLv = 1;
ability.GeneralID = generalID;
ability.Position = position;
ability.ExperienceNum = experienceNum;
userAbility.AbilityList.Add(ability);
}
}
示例11: DoGiff
/// <summary>
/// 处理礼包
/// </summary>
/// <param name="userID"></param>
/// <param name="order"></param>
private static void DoGiff(string userID, OrderInfo order)
{
int packType = 0;
List<PackageReceive> packageReceivess = new List<PackageReceive>();
UserRechargeLog rechargeLog = new UserRechargeLog
{
LogID = Guid.NewGuid().ToString(),
UserID = userID,
OrderNo = order.OrderNO,
ChargeAmount = order.Amount,
PayGold = order.GameCoins,
ReargeDate = DateTime.Now
};
var sender = DataSyncManager.GetDataSender();
sender.Send(rechargeLog);
UserRecharge recharge = new GameDataCacheSet<UserRecharge>().FindKey(userID);
if (recharge == null)
{
recharge = new UserRecharge() { UserID = userID };
}
//处理充值活动
recharge.LastNum = order.GameCoins;
TriggerFestivalPack(recharge, order.GameCoins);
if (IsCurrentWeek(recharge.ChargeDate))
{
recharge.WeekNum = MathUtils.Addition(recharge.WeekNum, order.GameCoins, int.MaxValue);
}
else
{
recharge.WeekNum = order.GameCoins;
}
if (recharge.ChargeDate.Month == DateTime.Now.Month)
{
recharge.MonthNum = MathUtils.Addition(recharge.MonthNum, order.GameCoins, int.MaxValue);
}
else
{
recharge.MonthNum = order.GameCoins;
}
recharge.TotalGoldNum = MathUtils.Addition(recharge.TotalGoldNum, order.GameCoins, int.MaxValue);
recharge.ChargeDate = DateTime.Now;
var rechargeCacheSet = new GameDataCacheSet<UserRecharge>();
if (rechargeCacheSet.FindKey(userID) == null)
{
packType = 1;
recharge.FirstNum = order.GameCoins;
TriggerReceivePack(userID, packType, recharge.FirstNum);
rechargeCacheSet.Add(recharge, GameEnvironment.CacheUserPeriod);
FestivalHelper.GetFirstReward(userID, FestivalType.FirstReward);
GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(userID);
if (userInfo != null)
{
FestivalHelper.GetPayReward(userInfo, order.GameCoins, FestivalType.FirstPayDoubleSpar);
}
}
//触发总累计充值礼包
packType = 2;
TriggerReceivePack(userID, packType, recharge.TotalGoldNum);
List<RechargePacks> rechargePackseArray = new ConfigCacheSet<RechargePacks>().FindAll(m => m.PacksType == packType);
foreach (RechargePacks rechargePackse in rechargePackseArray)
{
RemoveCharge(userID, rechargePackse.PacksID);
}
TriggerWeekPack(userID, recharge.WeekNum); //每周礼包
TriggerMonthPack(userID, recharge.MonthNum); //每月礼包
}
示例12: AppendSparePart
public void AppendSparePart(UserSparePart sparePart)
{
var cacheSet = new GameDataCacheSet<UserSparePackage>();
UserSparePackage package = null;
if (cacheSet.FindKey(UserID) == null)
{
package = new UserSparePackage() { UserID = UserID };
cacheSet.Add(package, GameEnvironment.CacheUserPeriod);
}
package = cacheSet.FindKey(UserID);
package.SparePackage.Add(sparePart);
//package.Update();
}
示例13: TriggerWeekPack
public static void TriggerWeekPack(string userID, int gameCoin)
{
int packType = 3;
List<RechargePacks> rechargePackseArray = new ConfigCacheSet<RechargePacks>().FindAll(m => m.PacksType == packType);
foreach (RechargePacks rechargePackse in rechargePackseArray)
{
if (rechargePackse.RechargeNum <= gameCoin)
{
var packCacheSet = new GameDataCacheSet<PackageReceive>();
List<PackageReceive> packageReceivess = packCacheSet.FindAll(userID, m => m.PacksID == rechargePackse.PacksID);
if (packageReceivess.Count == 0)
{
PackageReceive receive = new PackageReceive();
receive.ReceiveID = Guid.NewGuid().ToString();
receive.PacksID = rechargePackse.PacksID;
receive.UserID = userID;
receive.IsReceive = false;
receive.ReceiveDate = DateTime.Now;
packCacheSet.Add(receive, GameEnvironment.CacheUserPeriod);
}
else if (!IsHaveWeek(packageReceivess))
{
PackageReceive receive = packageReceivess[0];
if (receive.IsReceive)
{
receive.IsReceive = false;
receive.ReceiveDate = DateTime.Now;
//receive.Update();
}
for (int i = 1; i <= packageReceivess.Count - 1; i++)
{
packCacheSet.Delete(packageReceivess[i]);
}
}
}
}
}
示例14: TakeAction
public override bool TakeAction()
{
var cacheSet = new GameDataCacheSet<UserGeneral>();
if (recruitType == RecruitType.SoulRecruit)
{
general = new ConfigCacheSet<GeneralInfo>().FindKey(soulID);
if (general == null)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
return false;
}
UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, soulID);
if (soulID == 0 || userGeneral != null)
{
UserItemHelper.AddUserItem(ContextUser.UserID, general.ItemID, 1);
}
else
{
userGeneral = new UserGeneral();
userGeneral.UserID = ContextUser.UserID;
cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod);
userGeneral.GeneralID = general.GeneralID;
userGeneral.GeneralName = general.GeneralName;
userGeneral.HeadID = general.HeadID;
userGeneral.PicturesID = general.PicturesID;
userGeneral.GeneralLv = (short)general.GeneralLv;
userGeneral.LifeNum = general.LifeNum;
userGeneral.GeneralType = GeneralType.YongBing;
userGeneral.CareerID = general.CareerID;
userGeneral.PowerNum = general.PowerNum;
userGeneral.SoulNum = general.SoulNum;
userGeneral.IntellectNum = general.IntellectNum;
userGeneral.TrainingPower = 0;
userGeneral.TrainingSoul = 0;
userGeneral.TrainingIntellect = 0;
userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum");
userGeneral.AbilityID = general.AbilityID;
userGeneral.Momentum = 0;
userGeneral.Description = general.Description;
userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong;
userGeneral.CurrExperience = 0;
userGeneral.Experience1 = 0;
userGeneral.Experience2 = 0;
}
}
else
{
RecruitRule recruitRule = new ConfigCacheSet<RecruitRule>().FindKey(recruitType);
if (recruitRule == null)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
return false;
}
int surplusNum = GeneralHelper.SurplusNum(ContextUser.UserID, recruitRule.FreeNum,
recruitRule.RecruitType.ToEnum<RecruitType>());
if (surplusNum > 0 && !GeneralHelper.GeneralRecruitColdTime(ContextUser.UserID, recruitType))
{
GeneralHelper.UpdateDailyRecruitNum(ContextUser.UserID, recruitType);
GeneralHelper.UpdateRecruitColdTime(ContextUser.UserID, recruitRule);
}
else
{
if (ContextUser.GoldNum < recruitRule.GoldNum)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
return false;
}
ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, recruitRule.GoldNum);
}
CacheList<RecruitInfo> recruitInfos = recruitRule.GeneralQuality;
double[] probability = new double[recruitInfos.Count];
for (int i = 0; i < recruitInfos.Count; i++)
{
probability[i] = (double)recruitInfos[i].Probability;
}
int index2 = RandomUtils.GetHitIndex(probability);
GeneralQuality quality = recruitInfos[index2].Quality;
var generalList = new ConfigCacheSet<GeneralInfo>().FindAll(s => s.GeneralQuality == quality);
if (generalList.Count > 0)
{
int indexradom = RandomUtils.GetRandom(0, generalList.Count);
if (indexradom < 0 || indexradom >= generalList.Count)
{
return false;
}
general = generalList[indexradom];
UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, general.GeneralID);
if (userGeneral != null && userGeneral.GeneralStatus != GeneralStatus.YinCang)
{
currSoulID = general.SoulID;
gainNum = general.DemandNum;
userGeneral = cacheSet.FindKey(ContextUser.UserID, currSoulID);
if (userGeneral != null)
{
userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, gainNum);
generalType = GeneralType.Soul;
//.........这里部分代码省略.........
示例15: CreateRole
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;
}