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


C# Directions.Where方法代码示例

本文整理汇总了C#中Directions.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Directions.Where方法的具体用法?C# Directions.Where怎么用?C# Directions.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Directions的用法示例。


在下文中一共展示了Directions.Where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsSimilarByColores

 private bool IsSimilarByColores(Directions[] interestingSide, Dictionary<Directions, Colores> originSides)
 {
     return interestingSide.
         Where(side => !Side2Colores[side].Equals(Colores.Uncolored)).
         Any(side => Side2Colores[side].Equals(originSides[side]));
 }
开发者ID:Rast1234,项目名称:2013,代码行数:6,代码来源:SHtekh_Gennadijj_Petrovich.cs

示例2: DetermineNextLocation

        private static Int3 DetermineNextLocation(Room room, Int3 currentLocation, Directions[] possibleDirections, ref Directions lastDirection)
        {
            Directions invalidDirections = Directions.None;
            var foundValidDirection = false;
            var intendedLocation = currentLocation;
            var currentSide = room.roomBuffer[currentLocation.X, currentLocation.Y, currentLocation.Z];

            if (lastDirection == Directions.Left)
            {
                invalidDirections |= Directions.Right;
            }

            if (lastDirection == Directions.Right)
            {
                invalidDirections |= Directions.Left;
            }

            if (lastDirection == Directions.Up)
            {
                invalidDirections |= Directions.Down;
            }

            if (lastDirection == Directions.Down)
            {
                invalidDirections |= Directions.Up;
            }

            if (lastDirection == Directions.Forward)
            {
                invalidDirections |= Directions.Back;
            }

            if (lastDirection == Directions.Back)
            {
                invalidDirections |= Directions.Forward;
            }

            if ((currentSide & Sides.Left) > 0)
            {
                invalidDirections |= Directions.Left;
                invalidDirections |= Directions.Right;
            }
            if ((currentSide & Sides.Right) > 0)
            {
                invalidDirections |= Directions.Left;
                invalidDirections |= Directions.Right;
            }
            if ((currentSide & Sides.Top) > 0)
            {
                invalidDirections |= Directions.Up;
                invalidDirections |= Directions.Down;
            }
            if ((currentSide & Sides.Bottom) > 0)
            {
                invalidDirections |= Directions.Up;
                invalidDirections |= Directions.Down;
            }
            if ((currentSide & Sides.Front) > 0)
            {
                invalidDirections |= Directions.Back;
                invalidDirections |= Directions.Forward;
            }
            if ((currentSide & Sides.Rear) > 0)
            {
                invalidDirections |= Directions.Back;
                invalidDirections |= Directions.Forward;
            }

            while (!foundValidDirection)
            {
                intendedLocation = currentLocation;

                if (invalidDirections >= Directions.NUM_VALUES - 1)
                {
                    throw new InvalidSolveException();
                }

                var directions = invalidDirections;
                lastDirection = possibleDirections.Where(d => (directions & d) == 0).SelectRandom();
                if (lastDirection == Directions.None)
                    throw new InvalidSolveException();

                switch (lastDirection)
                {
                    case Directions.Forward:
                        intendedLocation.Z += 1;
                        if (intendedLocation.Z == room.Depth)
                        {
                            invalidDirections |= lastDirection;
                        }
                        else
                        {
                            if (room.roomBuffer[intendedLocation.X, intendedLocation.Y, intendedLocation.Z] !=
                                Sides.None)
                            {
                                invalidDirections |= lastDirection;
                            }
                            else
                            {
                                foundValidDirection = true;
//.........这里部分代码省略.........
开发者ID:fatiguedartist,项目名称:Sisyphus,代码行数:101,代码来源:Solver.cs

示例3: IsEqualByColores

 public bool IsEqualByColores(Directions[] interestingSides, Dictionary<Directions, Colores> originSides)
 {
     return interestingSides.
         Where(side => (!Side2Colores[side].Equals(Colores.Uncolored))).
         All(side => Side2Colores[side].Equals(originSides[side]));
 }
开发者ID:Rast1234,项目名称:2013,代码行数:6,代码来源:SHtekh_Gennadijj_Petrovich.cs


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