本文整理汇总了C#中GameDataCacheSet.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# GameDataCacheSet.ForEach方法的具体用法?C# GameDataCacheSet.ForEach怎么用?C# GameDataCacheSet.ForEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameDataCacheSet
的用法示例。
在下文中一共展示了GameDataCacheSet.ForEach方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
private void Process(string userID, int potential)
{
var generalList = new GameDataCacheSet<UserGeneral>().FindAll(userID);
if (generalList.Count > 0)
{
generalList.ForEach(general =>
{
general.Potential = MathUtils.Addition(general.Potential, potential);
});
}
}
示例2: GeneralSort
public static void GeneralSort(string userId, List<UserGeneral> userGenerals)
{
if (userGenerals.Count > 0)
{
var _userMagicArray = new GameDataCacheSet<UserMagic>().FindAll(userId);
var userMagic =
_userMagicArray.Find(
x => x.UserID == userId && x.MagicType == MagicType.MoFaZhen && x.IsEnabled == true);
var userEmbattleInfo = new GameDataCacheSet<UserEmbattle>().FindAll(userId,
x =>
x.MagicID == userMagic.MagicID);
if (userEmbattleInfo != null)
{
userEmbattleInfo.ForEach(x =>
{
foreach (var userGeneral in userGenerals)
{
if (x.GeneralID == userGeneral.GeneralID)
{
userGeneral.Position = x.Position;
}
}
});
}
userGenerals.QuickSort((x, y) =>
{
int result = 0;
if (x == null && y == null) return 0;
if (x != null && y == null) return 1;
if (x == null) return -1;
// 1、是否上阵(出手先后) 2、品质高低
result = y.IsBattle.CompareTo(x.IsBattle);
if (result == 0)
{
result = x.Position.CompareTo(y.Position);
}
if (result == 0)
{
result = y.GeneralQuality.CompareTo(x.GeneralQuality);
}
if (result == 0)
{
result = x.GeneralID.CompareTo(y.GeneralID);
}
return result;
});
}
}
示例3: RegainGeneralLife
/// <summary>
/// 恢复最大生命值
/// </summary>
/// <param name="userID"></param>
public static void RegainGeneralLife(string userID)
{
var generalList = new GameDataCacheSet<UserGeneral>().FindAll(userID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong);
generalList.ForEach(general =>
{
general.LifeNum = MathUtils.Addition(general.LifeNum, general.LifeMaxNum, general.LifeMaxNum);
});
}
示例4: DoPlotPrize
/// <summary>
/// 副本奖励,如果通关下发通关奖励
/// </summary>
/// <param name="userID"></param>
/// <param name="plotNpcInfo"></param>
/// <param name="userPlotCombat"></param>
internal static void DoPlotPrize(string userID, PlotNPCInfo plotNpcInfo, UserPlotCombat userPlotCombat, int npcGeneralNum, out int honourNum)
{
honourNum = 0;
int experience = 0;
PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(plotNpcInfo.PlotID);
var package = UserPlotPackage.Get(userID);
if (plotInfo == null || plotNpcInfo == null || userPlotCombat == null || package == null)
{
return;
}
GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID);
if (user != null)
{
experience += plotNpcInfo.Experience;
userPlotCombat.Experience = plotNpcInfo.Experience;
if (!string.IsNullOrEmpty(user.MercenariesID))
{
//公会技能加成
userPlotCombat.Experience = MathUtils.RoundCustom(experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt();
experience = userPlotCombat.Experience;
}
var cacheSetGeneral = new GameDataCacheSet<UserGeneral>();
var userMagic = new GameDataCacheSet<UserMagic>().Find(user.UserID, s => s.IsEnabled);
int userMagicID = userMagic == null ? 0 : userMagic.MagicID;
var userEmbattleList = new GameDataCacheSet<UserEmbattle>().FindAll(userID, s => s.MagicID == userMagicID && s.GeneralID > 0);
int generalNum = 0;
userEmbattleList.ForEach(userEmbattle =>
{
var userGeneral = cacheSetGeneral.FindKey(userID, userEmbattle.GeneralID);
generalNum = userGeneral != null && userGeneral.LifeNum > 0
? MathUtils.Addition(generalNum, 1)
: generalNum;
});
user.GeneralAllCount = MathUtils.Addition(user.GeneralAllCount, userPlotCombat.GeneralNum);
user.GeneralKillCount = MathUtils.Addition(user.GeneralKillCount,
(userPlotCombat.GeneralNum - generalNum));
//怪物掉落物品)
if (plotNpcInfo.IsBoss)
{
if (plotInfo.PlotType == PlotType.Normal && user.PlotProgress < plotInfo.PlotID)
{
user.PlotProgress = plotInfo.PlotID;
}
//日常任务-通关副本
TaskHelper.TriggerDailyTask(userID, 4005);
DateTime currDate = DateTime.Now;
//通关奖励
var userPlot = UserPlotHelper.GetUserPlotInfo(userID, plotNpcInfo.PlotID);
if (userPlot == null)
{
userPlot = new UserPlotInfo();
userPlot.PlotID = plotNpcInfo.PlotID;
userPlot.CreateDate = currDate;
package.SaveItem(userPlot);
}
NoviceHelper.PlotFestivalList(user, plotInfo.PlotID); //活动集合
List<UserPlotCombat> preUserPlotList = new GameDataCacheSet<UserPlotCombat>().FindAll(userID, m => !m.PlotNpcID.Equals(userPlotCombat.PlotNpcID) && m.PlotID == plotNpcInfo.PlotID);
preUserPlotList.Add(userPlotCombat);
List<UserPlotCombat> plotCombatList = preUserPlotList;
short starScore;
PlotSuccessType plotSuccessType = PlotSuccessType.No;
userPlot.ScoreNum = GetPlotScoreNum(plotCombatList, out starScore);
userPlot.PlotStatus = PlotStatus.Completed;
userPlot.AttackScore = 0;
userPlot.DefenseScore = 0;
userPlot.ItemID = 0;
userPlot.EnchantID = 0;
userPlot.PlotSuccessType = plotSuccessType;
//获得星星等级
if (userPlotCombat.IsWin)
{
double pren = 0;
GetStar(user, generalNum, out starScore, out plotSuccessType, out pren);
userPlot.StarScore = starScore;
userPlot.PlotSuccessType = plotSuccessType;
//获得荣誉值
honourNum = plotInfo.HonourNum;
userPlot.PlotNum = MathUtils.Addition(userPlot.PlotNum, 1);
if (GetPlotChallengeNum(userID, plotNpcInfo.PlotID) == 1)
{
if (starScore >= 3)
{
if (plotInfo.PlotType==PlotType.Elite) // 如果是精英副本
//.........这里部分代码省略.........