本文整理汇总了C#中Direction.Reversed方法的典型用法代码示例。如果您正苦于以下问题:C# Direction.Reversed方法的具体用法?C# Direction.Reversed怎么用?C# Direction.Reversed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Direction
的用法示例。
在下文中一共展示了Direction.Reversed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PushOrBounce
/// <summary>
/// Used to begin a push or bounce action by the player
/// </summary>
/// <param name="byWhom">The game object that is acting on the boulder</param>
/// <param name="direction">Which direction the specified game object is directing the boulder</param>
public void PushOrBounce(MovingItem byWhom, Direction direction)
{
var ps = CanBePushedOrBounced(byWhom, direction, true);
switch (ps)
{
case PushStatus.No:
return;
case PushStatus.Yes:
{
System.Diagnostics.Trace.WriteLine(string.Format("{0} is pushing {1}", byWhom.GetType().Name, this.GetType().Name));
this.Move(direction, this.StandardSpeed);
return;
}
case PushStatus.Bounce:
{
System.Diagnostics.Trace.WriteLine(string.Format("{0} is bouncing {1}", byWhom.GetType().Name, this.GetType().Name));
var reverseDirection = direction.Reversed();
this.Move(reverseDirection, this.BounceBackSpeed);
byWhom.Move(reverseDirection, this.BounceBackSpeed);
this.World.Game.SoundPlayer.Play(GameSound.BoulderBounces);
return;
}
default:
throw new InvalidOperationException();
}
}
示例2: CanBePushedOrBounced
private PushStatus CanBePushedOrBounced(MovingItem byWhom, Direction direction, bool isBounceBackPossible)
{
if (this.Solidity != ObjectSolidity.Moveable)
return PushStatus.No;
bool isPushable = byWhom.Capability == ObjectCapability.CanPushOthers || byWhom.Capability == ObjectCapability.CanPushOrCauseBounceBack;
if (!isPushable)
return PushStatus.No;
// first check if the object can be pushed
if (this.CanMoveInDirection(direction, isBounceBackPossible))
return PushStatus.Yes;
// is bounce back possible?
if (byWhom.Capability != ObjectCapability.CanPushOrCauseBounceBack || !isBounceBackPossible)
return PushStatus.No;
var result = byWhom.CanMoveInDirection(direction.Reversed(), false) ? PushStatus.Bounce : PushStatus.No;
return result;
}