本文整理汇总了C#中GameLiving.IsObjectInFront方法的典型用法代码示例。如果您正苦于以下问题:C# GameLiving.IsObjectInFront方法的具体用法?C# GameLiving.IsObjectInFront怎么用?C# GameLiving.IsObjectInFront使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameLiving
的用法示例。
在下文中一共展示了GameLiving.IsObjectInFront方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanUseStyle
/// <summary>
/// Returns wether this player can use a particular style
/// right now. Tests for all preconditions like prerequired
/// styles, previous attack result, ...
/// </summary>
/// <param name="living">The living wanting to execute a style</param>
/// <param name="style">The style to execute</param>
/// <param name="weapon">The weapon used to execute the style</param>
/// <returns>true if the player can execute the style right now, false if not</returns>
public static bool CanUseStyle(GameLiving living, Style style, InventoryItem weapon)
{
//First thing in processors, lock the objects you modify
//This way it makes sure the objects are not modified by
//several different threads at the same time!
lock (living)
{
GameLiving target = living.TargetObject as GameLiving;
if (target == null) return false;
//Required attack result
GameLiving.eAttackResult requiredAttackResult = GameLiving.eAttackResult.Any;
switch (style.AttackResultRequirement)
{
case Style.eAttackResult.Any: requiredAttackResult = GameLiving.eAttackResult.Any; break;
case Style.eAttackResult.Block: requiredAttackResult = GameLiving.eAttackResult.Blocked; break;
case Style.eAttackResult.Evade: requiredAttackResult = GameLiving.eAttackResult.Evaded; break;
case Style.eAttackResult.Fumble: requiredAttackResult = GameLiving.eAttackResult.Fumbled; break;
case Style.eAttackResult.Hit: requiredAttackResult = GameLiving.eAttackResult.HitUnstyled; break;
case Style.eAttackResult.Style: requiredAttackResult = GameLiving.eAttackResult.HitStyle; break;
case Style.eAttackResult.Miss: requiredAttackResult = GameLiving.eAttackResult.Missed; break;
case Style.eAttackResult.Parry: requiredAttackResult = GameLiving.eAttackResult.Parried; break;
}
AttackData lastAD = (AttackData)living.TempProperties.getProperty<object>(GameLiving.LAST_ATTACK_DATA, null);
switch (style.OpeningRequirementType)
{
case Style.eOpening.Offensive:
//Style required before this one?
if (style.OpeningRequirementValue != 0
&& (lastAD == null
|| lastAD.AttackResult != GameLiving.eAttackResult.HitStyle
|| lastAD.Style == null
|| lastAD.Style.ID != style.OpeningRequirementValue
|| lastAD.Target != target)) // style chains are possible only on the same target
{
//DOLConsole.WriteLine("Offensive: Opening Requirement style needed failed!("+style.OpeningRequirementValue+")");
return false;
}
//Last attack result
GameLiving.eAttackResult lastRes = (lastAD != null) ? lastAD.AttackResult : GameLiving.eAttackResult.Any;
if (requiredAttackResult != GameLiving.eAttackResult.Any && lastRes != requiredAttackResult)
{
//DOLConsole.WriteLine("Offensive: AttackResult Requirement failed!("+requiredAttackResult.ToString()+", was "+lastRes+")");
return false;
}
break;
case Style.eOpening.Defensive:
AttackData targetsLastAD = (AttackData)target.TempProperties.getProperty<object>(GameLiving.LAST_ATTACK_DATA, null);
//Last attack result
if (requiredAttackResult != GameLiving.eAttackResult.Any)
{
if (targetsLastAD == null || targetsLastAD.Target != living)
{
return false;
}
if (requiredAttackResult != GameLiving.eAttackResult.HitStyle && targetsLastAD.AttackResult != requiredAttackResult)
{
//DOLConsole.WriteLine("Defensive: AttackResult Requirement failed!("+requiredAttackResult.ToString()+", was "+lastEnemyRes+")");
return false;
}
else if (requiredAttackResult == GameLiving.eAttackResult.HitStyle && targetsLastAD.Style == null)
{
//DOLConsole.WriteLine("Defensive: AttackResult Requirement failed!("+requiredAttackResult.ToString()+", was "+lastEnemyRes+")");
return false;
}
}
break;
case Style.eOpening.Positional:
//check here if target is in front of attacker
if (!living.IsObjectInFront(target, 120))
return false;
//you can't use positional styles on keep doors or walls
if ((target is GameKeepComponent || target is GameKeepDoor) && (Style.eOpeningPosition)style.OpeningRequirementValue != Style.eOpeningPosition.Front)
return false;
// get players angle on target
float angle = target.GetAngle( living );
//player.Out.SendDebugMessage("Positional check: "+style.OpeningRequirementValue+" angle "+angle+" target heading="+target.Heading);
switch ((Style.eOpeningPosition)style.OpeningRequirementValue)
{
//.........这里部分代码省略.........