本文整理汇总了C#中PersonalCacheStruct.FindKey方法的典型用法代码示例。如果您正苦于以下问题:C# PersonalCacheStruct.FindKey方法的具体用法?C# PersonalCacheStruct.FindKey怎么用?C# PersonalCacheStruct.FindKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PersonalCacheStruct
的用法示例。
在下文中一共展示了PersonalCacheStruct.FindKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GeneralStatus
/// <summary>
/// 佣兵状态
/// </summary>
public GeneralStatus GeneralStatus(string userID)
{
var cacheSet = new PersonalCacheStruct<UserGeneral>();
if (cacheSet.FindKey(userID, _item.GeneralID) != null)
{
return _item.IsNotUsed ? Model.GeneralStatus.YinCang : cacheSet.FindKey(userID, _item.GeneralID).GeneralStatus;
}
return Model.GeneralStatus.YinCang;
}
示例2: 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 PersonalCacheStruct<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>();
}
示例3: CheckFestivalRestrain
private static void CheckFestivalRestrain(string userid, int festivalID)
{
var cacheSet = new PersonalCacheStruct<FestivalRestrain>();
FestivalRestrain restrain = cacheSet.FindKey(userid, festivalID);
if (restrain != null)
{
if (restrain.RefreashDate.Date != DateTime.Now.Date)
{
if (restrain.RefreashDate.Date != DateTime.Now.Date)
{
restrain.RefreashDate = DateTime.Now;
restrain.RestrainNum = 0;
//restrain.Update();
}
}
}
else
{
restrain = new FestivalRestrain()
{
UserID = userid,
FestivalID = festivalID,
RestrainNum = 0,
RefreashDate = DateTime.Now
};
cacheSet.Add(restrain);
}
}
示例4: TakeAction
public override bool TakeAction()
{
int useGold = ConfigEnvSet.GetInt("TrumpZodiac.ChangeZodiacUseGold");
if (ops == 1)
{
ErrorCode = ops;
ErrorInfo = string.Format(LanguageManager.GetLang().St1471_ChangeZodiac, useGold);
return false;
}
else if (ops == 2)
{
if (ContextUser.GoldNum < useGold)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
return false;
}
var cacheSet = new PersonalCacheStruct<UserTrump>();
UserTrump userTrump = cacheSet.FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID);
if (userTrump != null)
{
userTrump.Zodiac = TrumpHelper.GetZodiacType(userTrump.Zodiac);
ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue);
}
ErrorCode = ops;
}
return true;
}
示例5: 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 PersonalCacheStruct<UserMagic>();
var userMagic = cacheSet.FindKey(UserID, magicID);
MagicInfo magic = new ShareCacheStruct<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;
}
}
示例6: Process
private void Process(string userID, int generalID, int experience)
{
var cacheSet = new PersonalCacheStruct<UserGeneral>();
var usergeneral = cacheSet.FindKey(userID, generalID);
if(usergeneral!=null)
{
usergeneral.CurrExperience = MathUtils.Addition(usergeneral.CurrExperience, experience);
}
}
示例7: TakeAction
public override bool TakeAction()
{
int upitemNum = 0;
var cacheSet = new PersonalCacheStruct<UserTrump>();
UserTrump userTrump = cacheSet.FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID);
if (userTrump == null)
{
return false;
}
WashConsumeInfo consumeInfo = TrumpHelper.GetWashConsumeInfo(userTrump.MatureNum);
if (consumeInfo == null)
{
return false;
}
upitemNum = TrumpHelper.GetUserItemNum(ContextUser.UserID, consumeInfo.ItemID);
if (ops == 1)
{
string success = ((double)consumeInfo.SuccessNum * 100).ToString();
ErrorCode = ops;
ErrorInfo = string.Format(LanguageManager.GetLang().St1458_UseBackDaysOrb, consumeInfo.ItemNum, consumeInfo.MatureNum, success);
return false;
}
else if (ops == 2)
{
ErrorCode = ops;
if (upitemNum < consumeInfo.ItemNum)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
ErrorInfo = LanguageManager.GetLang().St1458_BackDaysOrbNotEnough;
return false;
}
int maxMatrueNum = ConfigEnvSet.GetInt("Trump.MaxMatrueNum");
if (userTrump.MatureNum >= maxMatrueNum)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
ErrorInfo = LanguageManager.GetLang().St1458_MaxMatrueNumFull;
return false;
}
UserItemHelper.UseUserItem(ContextUser.UserID, consumeInfo.ItemID, consumeInfo.ItemNum);
if (RandomUtils.IsHit(consumeInfo.SuccessNum))
{
userTrump.MatureNum = MathUtils.Addition(userTrump.MatureNum, consumeInfo.MatureNum.ToShort(), maxMatrueNum.ToShort());
ErrorInfo = LanguageManager.GetLang().St1458_XiLianSuccess;
var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID);
if (usergeneral != null)
{
usergeneral.RefreshMaxLife();
}
}
else
{
ErrorInfo = LanguageManager.GetLang().St1458_XiLianFail;
}
}
return true;
}
示例8: GetUserFunction
/// <summary>
/// 已开启的功能
/// </summary>
/// <param name="userID"></param>
/// <param name="funEnum"></param>
/// <returns></returns>
private static UserFunction GetUserFunction(string userID, FunctionEnum funEnum)
{
var cacheSet = new PersonalCacheStruct<UserFunction>();
UserFunction function1 = cacheSet.FindKey(userID, funEnum);
if (function1 != null)
{
return function1;
}
return null;
}
示例9: TakeAction
/// <summary>
/// 业务逻辑处理
/// </summary>
/// <returns>false:中断后面的方式执行并返回Error</returns>
public override bool TakeAction()
{
GameUser user = Current.User as GameUser;
if (user == null) return false;
var roleCache = new PersonalCacheStruct<UserRole>();
_role = roleCache.FindKey(user.PersonalId, user.CurrRoleId);
if (_role == null)
{
return false;
}
return true;
}
示例10: AddBack
/// <summary>
/// 初始化背包
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public static void AddBack(GameUser user)
{
var cacheSet = new PersonalCacheStruct<UserPack>();
var cacheSetBackPack = new ShareCacheStruct<BackpackConfigInfo>();
var userPack = cacheSet.FindKey(user.UserID);
if (userPack == null)
{
userPack = new UserPack();
userPack.UserID = user.UserID.ToInt();
userPack.CreateDate = DateTime.Now;
var backpackConfig = cacheSetBackPack.FindKey(BackpackType.ZhuangBei);
if (backpackConfig != null)
{
var packType = new PackType();
packType.BackpackType = BackpackType.ZhuangBei;
packType.OpenNum = 0;
packType.Position = backpackConfig.DefaultNum;
}
backpackConfig = cacheSetBackPack.FindKey(BackpackType.YongBing);
if (backpackConfig != null)
{
var packType = new PackType();
packType.BackpackType = BackpackType.YongBing;
packType.OpenNum = 0;
packType.Position = backpackConfig.DefaultNum;
}
backpackConfig = cacheSetBackPack.FindKey(BackpackType.HunJi);
if (backpackConfig != null)
{
var packType = new PackType();
packType.BackpackType = BackpackType.HunJi;
packType.OpenNum = 0;
packType.Position = backpackConfig.DefaultNum;
}
backpackConfig = cacheSetBackPack.FindKey(BackpackType.BeiBao);
if (backpackConfig != null)
{
var packType = new PackType();
packType.BackpackType = BackpackType.BeiBao;
packType.OpenNum = 0;
packType.Position = backpackConfig.DefaultNum;
user.GridNum = MathUtils.Addition(user.GridNum, backpackConfig.DefaultNum);
}
}
}
示例11: CheckLoadUser
public static GameUser CheckLoadUser(string userId)
{
var cacheSet = new PersonalCacheStruct<GameUser>();
GameUser gameUser = cacheSet.FindKey(userId);
if (gameUser == null)
{
//bool isAuto = true;
//bool ignoreError = true;
//int periodTime = GameEnvironment.CacheUserPeriod;
//todo 注释掉,由底层自动加载
//GameLoadManager.Add(new GameUserDataLoader<GameUser>(isAuto, "UserID", userId.ToInt(), 1, periodTime), ignoreError);
//GameLoadManager.Add(new GameUserDataLoader<UserGeneral>(isAuto, "UserID", userId.ToInt(), LoadMaxCount, periodTime), ignoreError);
}
return gameUser;
}
示例12: Get
public static UserItemPackage Get(string userId)
{
if (string.IsNullOrEmpty(userId))
{
throw new ArgumentNullException("UserID��");
}
var cacheSet = new PersonalCacheStruct<UserItemPackage>();
var data = cacheSet.FindKey(userId);
if (data != null)
{
return data;
}
BaseLog log = new BaseLog();
log.SaveLog(new NullReferenceException(string.Format("User:{0} item package is null.", userId)));
return null;
}
示例13: Process
private void Process(string userID, int fun)
{
FunctionEnum funEnum = fun.ToEnum<FunctionEnum>();
var cacheSet = new PersonalCacheStruct<UserFunction>();
UserFunction userFunction = cacheSet.FindKey(UserID, funEnum);
if (userFunction == null)
{
userFunction = new UserFunction()
{
UserID = userID,
FunEnum = funEnum,
CreateDate = DateTime.Now
};
cacheSet.Add(userFunction);
}
}
示例14: TakeAction
/// <summary>
/// 业务逻辑处理
/// </summary>
/// <returns>false:中断后面的方式执行并返回Error</returns>
public override bool TakeAction()
{
var user = PersonalCacheStruct.Get<GameUser>(UserId.ToString());
if (user == null)
{
ErrorCode = Language.Instance.ErrorCode;
return false;
}
var roleCache = new PersonalCacheStruct<UserRole>();
_role = roleCache.FindKey(user.PersonalId, user.CurrRoleId, user.UserId);
if (_role == null)
{
ErrorCode = Language.Instance.ErrorCode;
return false;
}
return true;
}
示例15: BuildPacket
public override void BuildPacket()
{
string sportsName = string.Empty;
var userGeneralCacheSet = new PersonalCacheStruct<UserGeneral>();
PushIntoStack(userRankArray.Count);
foreach (UserRank rank in userRankArray)
{
sportsName = UserHelper.SportTitleName(rank.ObtainNum);
short trend = SportTrend(rank.UserID);
DataStruct dsItem = new DataStruct();
dsItem.PushIntoStack(rank.RankId);
dsItem.PushIntoStack(rank.UserID.ToNotNullString());
dsItem.PushIntoStack(rank.NickName.ToNotNullString());
dsItem.PushIntoStack(rank.UserLv);
dsItem.PushIntoStack(rank.TotalCombatNum > 0 ? rank.TotalCombatNum : UserHelper.GetTotalCombatNum(rank.UserID));
dsItem.PushIntoStack(trend);
dsItem.PushIntoStack(sportsName);
dsItem.PushIntoStack(rank.VictoryNum);
var embattleList = EmbattleHelper.CurrEmbattle(rank.UserID, true);
dsItem.PushIntoStack(embattleList.Count);
foreach (var item in embattleList)
{
var userGenearl = userGeneralCacheSet.FindKey(item.UserID, item.GeneralID);
DataStruct dsItem1 = new DataStruct();
dsItem1.PushIntoStack(item.GeneralID);
dsItem1.PushIntoStack(userGenearl == null ? string.Empty : userGenearl.GeneralName.ToNotNullString());
dsItem1.PushIntoStack(userGenearl == null ? string.Empty : userGenearl.HeadID.ToNotNullString());
dsItem1.PushIntoStack(userGenearl == null ? 0 : userGenearl.GeneralQuality.ToInt());
dsItem1.PushIntoStack(userGenearl == null ? 0 : userGenearl.GeneralLv.ToInt());
dsItem.PushIntoStack(dsItem1);
}
SportsRewardInfo sportsInfo = new ShareCacheStruct<SportsRewardInfo>().FindKey(rank.RankId);
var embatList = EmbattleHelper.CurrEmbattle(rank.UserID, false);
dsItem.PushIntoStack(embatList.Count);
dsItem.PushIntoStack(embattleList.Count);
dsItem.PushIntoStack(sportsInfo == null ? 0 : sportsInfo.RewardObtian);
PushIntoStack(dsItem);
}
}