当前位置: 首页>>代码示例>>C#>>正文


C# Direction.Reversed方法代码示例

本文整理汇总了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();
                }
        }
开发者ID:JonSaffron,项目名称:Labyrinth,代码行数:34,代码来源:MovingItem.cs

示例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;
        }
开发者ID:JonSaffron,项目名称:Labyrinth,代码行数:20,代码来源:MovingItem.cs


注:本文中的Direction.Reversed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。