本文整理汇总了C#中ShareCacheStruct.Find方法的典型用法代码示例。如果您正苦于以下问题:C# ShareCacheStruct.Find方法的具体用法?C# ShareCacheStruct.Find怎么用?C# ShareCacheStruct.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShareCacheStruct
的用法示例。
在下文中一共展示了ShareCacheStruct.Find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TakeAction
public override bool TakeAction()
{
var cache = new ShareCacheStruct<UserRanking>();
var ranking = cache.Find(m => m.UserName == UserName);
if (ranking == null)
{
var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = UserName};
new PersonalCacheStruct<GameUser>().Add(user);
ranking = new UserRanking();
ranking.UserID = user.UserId;
ranking.UserName = UserName;
ranking.Score = Score;
if (!cache.Add(ranking))
{
ErrorCode = Language.Instance.ErrorCode;
ErrorInfo = string.Format("add fail, UserID {0} is exist.", ranking.UserID);
return false;
}
}
else
{
ranking.UserName = UserName;
ranking.Score = Score;
}
return true;
}
示例2: TakeAction
public override bool TakeAction() {
var cache = new ShareCacheStruct<UserRanking>();
var ranking = cache.Find(m => m.UserName == userName);
if (ranking == null) {
var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = userName };
new PersonalCacheStruct<GameUser>().Add(user);
ranking = new UserRanking();
ranking.UserId = user.UserId;
ranking.UserName = userName;
ranking.Score = score;
cache.Add(ranking);
} else {
ranking.UserName = userName;
ranking.Score = score;
}
return true;
}
示例3: TakeAction
public override bool TakeAction()
{
var cache = new ShareCacheStruct<UserRanking>();
var ranking = cache.Find(m => m.UserName == UserName);
if (ranking == null)
{
ranking = new UserRanking();
ranking.UserID = (int)cache.GetNextNo();
ranking.UserName = UserName;
ranking.Score = Score;
cache.Add(ranking);
}
else
{
ranking.UserName = UserName;
ranking.Score = Score;
}
return true;
}
示例4: TakeAction
public override bool TakeAction()
{
var cache = new ShareCacheStruct<UserScore>();
var ranking = cache.Find(m => m.username == _username);
if (ranking == null)
{
var user = new User() { userid = (int)cache.GetNextNo(), nickname = _username };
new PersonalCacheStruct<User>().Add(user);
ranking = new UserScore();
ranking.userid = user.userid;
ranking.username = _username;
ranking.score = _score;
cache.Add(ranking);
}
else
{
ranking.username = _username;
ranking.score = _score;
}
return true;
}
示例5: AddFoe
/// <summary>
/// 增加仇敌
/// </summary>
/// <param name="user"></param>
/// <param name="toUser"></param>
private static void AddFoe(GameUser user, GameUser toUser)
{
var cacheSet = new ShareCacheStruct<UserFriends>();
var friends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.Friend);
var choudiFriends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);
if (friends == null && choudiFriends == null)
{
var list = cacheSet.FindAll(s => s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);
if (list.Count >= 50)
{
list.QuickSort((x, y) =>
{
if (x == null && y == null) return 0;
if (x != null && y == null) return 1;
if (x == null) return -1;
return (x.FightTime).CompareTo(y.FightTime);
});
int count = list.Count - 49 + 1;
for (int i = 0; i < count; i++)
{
cacheSet.Delete(list[i]);
}
}
var userFriends = new UserFriends();
userFriends.UserID = toUser.UserID;
userFriends.FriendID = user.UserID;
userFriends.FightTime = DateTime.Now;
userFriends.FriendType = FriendType.ChouDi;
userFriends.ChatTime = DateTime.Now;
cacheSet.Add(userFriends, GameEnvironment.CacheGlobalPeriod);
}
}
示例6: checkBlack
int checkBlack()
{
//01 blacklist
var blackCache = new ShareCacheStruct<BlackListData>();
BlackListData blackD = blackCache.Find((o) =>
{
return (o.Identify == requestPack.Identify);
});
if (null != blackD)
return (int)ErrorCodeEx.DataCheck_BlackList;
return (int)ErrorCodeEx.None;
}
示例7: processCache
bool processCache(string orderId,bool bSuccess, string jrRet, bool hasGet)
{
// cache order
var payCache = new ShareCacheStruct<PayOrder>();
PayOrder payData = payCache.Find((o) =>
{
if (orderId == o.ServerOrderId)
return true;
return false;
});
if (null == payData)
{
//ConsoleLog.showErrorInfo(0, "PayLog not find order:" + orderId);
TraceLog.WriteError("PayLog not find order:" + orderId);
return false;
}
PayOrder.PayStatus payStatus = PayOrder.PayStatus.payFailed;
if (bSuccess)
{
payStatus = PayOrder.PayStatus.paySuccess;
}
if (false == payData.process)
{
payData.ModifyLocked(() =>
{
payData.userParms = urlParams; // save ..
payData.the3rdOrderId = order_id; // dic["order_id"];
payData.state = payStatus;
payData.process = true;
payData.typeUser = jrRet;
payData.hasGetPayReward = hasGet;
});
}
//ConsoleLog.showNotifyInfo("process HttpPost:" + jrRet);
//TraceLog.ReleaseWrite("process HttpPost:" + jrRet);
return true;
}
示例8: doEnd_order
void doEnd_order()
{
string orderId = requestPack.infoExt;
var payCache = new ShareCacheStruct<PayOrder>();
PayOrder payData = payCache.Find((o) =>
{
if (orderId == o.ServerOrderId)
return true;
return false;
});
if (payData == null)
{
responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.order_not_find;
}
payData.ModifyLocked(() => {
payData.hasGetPayReward = true;
});
responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok;
}
示例9: doCheck_order
void doCheck_order()
{
string orderId = requestPack.infoExt;
var payCache = new ShareCacheStruct<PayOrder>();
PayOrder payData = payCache.Find((o) =>
{
if (orderId == o.ServerOrderId)
return true;
return false;
});
if(payData == null)
{
responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.order_not_find;
return;
}
if (payData.hasGetPayReward)
{
responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.hasGetPayReward;
return;
}
string productId = payData.ProductId;
responsePack.extInfo = GameConfigMgr.Instance().getProductInfo(productId,orderId); // add 道具发放信息。
responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok;
}
示例10: TakeAction
public override bool TakeAction()
{
PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(PlotID);
if (plotInfo != null)
{
plotName = plotInfo.PlotName;
}
var cacheSetGeneralEscalate = new ShareCacheStruct<GeneralEscalateInfo>();
GeneralEscalateHelper.AddUserLv(ContextUser, 0);
int lv = ContextUser.UserLv;
lv = lv < 0 ? 1 : lv + 1;
var generalEscalate =
cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv);
if (generalEscalate != null)
{
maxHonourNum = generalEscalate.UpExperience;
}
var lastGeneralEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == (lv-1));
if (lastGeneralEscalate!=null)
{
lastMaxHonourNum = lastGeneralEscalate.UpExperience;
}
embattleList = new PersonalCacheStruct<UserEmbattle>().FindAll(ContextUser.UserID, m => m.MagicID == ContextUser.UseMagicID);
embattleList.QuickSort((x, y) => x.GeneralID.CompareTo(y.GeneralID));
List<UniversalInfo> universalList = new List<UniversalInfo>();
userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, PlotID);
//var cacheSetPlotInfo = new ShareCacheStruct<PlotInfo>();
//var cacheSetItem = new ShareCacheStruct<ItemBaseInfo>();
//var plotInfo = cacheSetPlotInfo.FindKey(PlotID);
if (userPlot != null && userPlot.ItemList.Count > 0)
{
universalList.AddRange(userPlot.ItemList);
//if (plotInfo != null && userPlot.PlotStatus == PlotStatus.Completed && plotInfo.ItemRank != "" && plotInfo.ItemRank != null)
//{
// var itemArray = plotInfo.ItemRank.Split(',');
// foreach (var s in itemArray)
// {
// int itemId = s.Split('=')[0].ToInt();
// var item = cacheSetItem.FindKey(itemId);
// if (item != null)
// {
// universalList.Add(new UniversalInfo() { Name = item.ItemName, HeadID = item.HeadID, Num = s.Split('=')[1].ToInt() });
// }
// }
//}
//if (userPlot.ItemID > 0)
//{
// itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(userPlot.ItemID);
// if (itemInfo != null)
// {
// universalList.Add(new UniversalInfo() { Name = itemInfo.ItemName, HeadID = itemInfo.HeadID, Num = 1 });
// }
//}
//if (userPlot.EnchantID > 0)
//{
// enchant = new ShareCacheStruct<EnchantInfo>().FindKey(userPlot.EnchantID);
// if (enchant != null)
// {
// universalList.Add(new UniversalInfo() { Name = enchant.EnchantName, HeadID = enchant.HeadID, Num = 1 });
// }
//}
userPlot.ItemList.Clear();
}
universalArray = universalList.ToArray();
return true;
}
示例11: TakeAction
public override bool TakeAction()
{
short currMaxLv = ConfigEnvSet.GetInt("User.CurrMaxLv").ToShort();
//NoviceHelper.CheckFestival(ContextUser);
NoviceHelper.GetFunctionEnum(Uid); //默认开启金币,精力大作战功能
if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
{
UserHelper.ChecheDailyContribution(ContextUser.MercenariesID, ContextUser.UserID);
}
PaymentService.Trigger(ContextUser);
if (ContextUser.UserLv > currMaxLv)
{
genlv = currMaxLv;
}
else
{
genlv = ContextUser.UserLv;
}
var cacheSetGeneralEscalate = new ShareCacheStruct<GeneralEscalateInfo>();
GeneralEscalateHelper.AddUserLv(ContextUser, 0);
_honourNum = ContextUser.HonourNum;
int lv = ContextUser.UserLv;
lv = lv < 0 ? 1 : lv + 1;
var generalEscalate =
cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv);
if (generalEscalate != null)
{
_nextHonourNum = generalEscalate.UpExperience;
}
guildID = ContextUser.MercenariesID;
var userGeneralList = new PersonalCacheStruct<UserGeneral>().FindAll(ContextUser.UserID);
if (userGeneralList.Count == 0)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
return false;
}
userGeneralInfo = userGeneralList[0]; //UserGeneral.GetMainGeneral(ContextUser.UserID);
if (userGeneralInfo != null)
{
//wuzf 去掉刷新血量,其它改变血量接口有触发刷新
//userGeneralInfo.RefreshMaxLife();
generalID = userGeneralInfo.GeneralID;
//careerInfo = new ShareCacheStruct<CareerInfo>().FindKey(userGeneralInfo.CareerID);
headID = userGeneralInfo.HeadID; //ContextUser.Sex ? careerInfo.HeadID2 : careerInfo.HeadID;
escalateInfo = new ShareCacheStruct<GeneralEscalateInfo>().FindKey(genlv);
lifeNum = userGeneralInfo.LifeNum;
careerID = userGeneralInfo.CareerID;
}
lifeMaxNum = UserHelper.GetMaxLife(ContextUser.UserID, generalID);
maxEnergyNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum");
sex = ContextUser.Sex ? 1 : 0;
//道具图标
_blessingList = UserHelper.BlessingInfoList(ContextUser);
//变身卡图标
List<UserProps> userPropsList = new PersonalCacheStruct<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 3 && u.ItemID != 5200 && u.ItemID != 7003);
if (userPropsList.Count > 0)
{
UserProps props = userPropsList[0];
int pTime = props.DoRefresh();
ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(props.ItemID);
if (itemInfo != null && pTime > pictureTime)
{
pictureID = itemInfo.PictrueID;
pictureTime = pTime;
}
}
//兼容客户端上已版本血量图标
List<UserProps> userPropsList2 = new PersonalCacheStruct<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1);
if (userPropsList2.Count > 0)
{
UserProps props = userPropsList2[0];
int pTime = props.DoRefresh();
ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(props.ItemID);
if (itemInfo != null && pTime > pictureTime)
{
_itemLiveNum = props.SurplusNum;
_itemLiveMaxNum = itemInfo.EffectNum;
}
}
//加量,领土战不能加血wuzf)
if (ContextUser.UserStatus != UserStatus.CountryCombat)
{
UserHelper.GetGeneralLife(ContextUser.UserID);
}
//精力恢复
List<UserQueue> energyQueueArray = new PersonalCacheStruct<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EnergyHuiFu);
if (energyQueueArray.Count > 0)
{
UserQueue energyQueue = energyQueueArray[0];
short energyMaxNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum");
int restorationDate = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationDate"); //半小时
int restorationNum = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationNum"); //恢复5点
//.........这里部分代码省略.........
示例12: AddGeneralSoul
/// 获得灵魂
/// </summary>
/// <param name="userId"></param>
/// <param name="itemId"></param>
/// <param name="num"></param>
public static void AddGeneralSoul(string userId, int itemId, int num)
{
var cacheSetGeneral = new PersonalCacheStruct<UserGeneral>();
var cacheSetGeneralInfo = new ShareCacheStruct<GeneralInfo>();
var generalInfo = cacheSetGeneralInfo.Find(s => s.SoulID == itemId);
var userGeneral = cacheSetGeneral.FindKey(userId, itemId);
if (userGeneral != null && generalInfo != null)
{
userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, num).ToShort();
}
else
{
if (generalInfo != null)
{
userGeneral = new UserGeneral();
userGeneral.UserID = userId;
userGeneral.GeneralID = itemId;
userGeneral.AtmanNum = num;
userGeneral.GeneralName = generalInfo.GeneralName;
userGeneral.HeadID = generalInfo.HeadID;
userGeneral.PicturesID = generalInfo.PicturesID;
userGeneral.GeneralLv = generalInfo.GeneralLv;
userGeneral.LifeNum = generalInfo.LifeNum;
userGeneral.GeneralType = generalInfo.GeneralType;
userGeneral.CareerID = generalInfo.CareerID;
userGeneral.PowerNum = generalInfo.PowerNum;
userGeneral.SoulNum = generalInfo.SoulNum;
userGeneral.IntellectNum = generalInfo.IntellectNum;
userGeneral.TrainingPower = 0;
userGeneral.TrainingSoul = 0;
userGeneral.TrainingIntellect = 0;
userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum");
userGeneral.AbilityID = generalInfo.AbilityID;
userGeneral.Momentum = 0;
userGeneral.Description = generalInfo.Description;
userGeneral.AddGeneralStatus(2);
userGeneral.CurrExperience = 0;
userGeneral.Experience1 = 0;
userGeneral.Experience2 = 0;
userGeneral.AbilityNum = 3;
cacheSetGeneral.Add(userGeneral);
}
}
}