本文整理汇总了C#中EventContext.PushScope方法的典型用法代码示例。如果您正苦于以下问题:C# EventContext.PushScope方法的具体用法?C# EventContext.PushScope怎么用?C# EventContext.PushScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventContext
的用法示例。
在下文中一共展示了EventContext.PushScope方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
public bool Evaluate(EventContext context, Game game)
{
//No children means its never true. Used in CHILDREN_WELLDRESS_PRESTIGE_MOD.
if (context.CurrentCharacter.Children.Count == 0)
return false;
for (int i = 0; i < context.CurrentCharacter.Children.Count; ++i)
{
context.PushScope(context.CurrentCharacter.Children[i]);
if (!requirements.Evaluate(context, game))
{
//We've found a child that doesn't the requirements. This is a failure
context.PopScope();
return false;
}
context.PopScope();
}
return true;
}
示例2: Evaluate
public double Evaluate(Game game, EventContext context, Weights weights)
{
//TODO: Start with random index.
// TODO: Should we be doing some average here instead of just stopping
// at the first one that works?
for (int i = 0; i < context.CurrentCharacter.Children.Count; ++i)
{
Character character = context.CurrentCharacter.Children[i];
context.PushScope(character);
if (requirements.Evaluate(context, game))
{
double result = operation.Evaluate(game, context, weights);
//AnyChild stops after a single interation.
context.PopScope();
return result;
}
context.PopScope();
}
return 0.0;
}
示例3: Execute
public void Execute(EventResults result, Game game, EventContext context)
{
Character tellingCharacter = context.GetScopedObjectByName("ROOT") as Character;
InformationInstance informationInstance = tellingCharacter.ChooseInformationAbout(type, context.GetScopedObjectByName(about) as Character);
bool isNewInformation = context.CurrentCharacter.AddInformation(informationInstance);
context.PushScope(informationInstance);
operation.Execute(result, game, context);
context.PopScope();
result.AddObservableInfo(informationInstance, overhearChance, tellingCharacter);
if (isNewInformation)
{
game.Log(context.CurrentCharacter.Name + " learned an information.");
informationInstance.ExecuteOnTold(context.CurrentCharacter, game, context.CurrentCharacter.CurrentRoom);
}
}
示例4: EvaluateChangedModifiers
private double EvaluateChangedModifiers(Character character, EventContext context, Game game)
{
context.PushScope(character);
List<PrestigeModifier> addedModifiers = new List<PrestigeModifier>();
List<PrestigeModifier> removedModifiers = new List<PrestigeModifier>();
game.GetChangedModifiers(context, addedModifiers, removedModifiers);
double result = 0.0;
if (addedModifiers.Count > 0 || removedModifiers.Count > 0)
{
foreach (var added in addedModifiers)
{
result += added.DailyChange;
}
foreach (var removed in removedModifiers)
{
result -= removed.DailyChange;
}
}
context.PopScope();
return result * 100.0 * 10.0;
}
示例5: FilterCharacters
public Character[] FilterCharacters(ILogic requirements, EventContext context)
{
List<Character> matchingCharacters = new List<Character>();
foreach (Character character in this.AllCharacters)
{
context.PushScope(character);
if (requirements.Evaluate(context, this))
{
matchingCharacters.Add(character);
}
context.PopScope();
}
return matchingCharacters.ToArray();
}