Esempio n. 1
0
        public static void UpdateDirectionMap(DirectionInfo directionInfo, DirectionType[] directionMap)
        {
            var mapIndex = 0;

            foreach (var directionOp in directionInfo.Directions)
            {
                for (var i = 0; i < directionOp.Length; i++)
                {
                    directionMap[i + mapIndex] = directionOp.Direction;
                }

                mapIndex += directionOp.Length;
            }
        }
Esempio n. 2
0
        private DirectionInfo GetDirectionInfo()
        {
            var           directionInfo     = new DirectionInfo();
            DirectionType?lastDirection     = null;
            var           lastDirectionSize = 0;

            for (var i = 0; i < SequencedBaseDirectionMap.Length; i++)
            {
                var direction = SequencedBaseDirectionMap[i];
                if (!lastDirection.HasValue)  // first time, just set it
                {
                    lastDirection = direction;
                    lastDirectionSize++;
                }
                else
                {
                    if (direction == lastDirection)
                    {
                        lastDirectionSize++;
                    }
                    else
                    {
                        directionInfo.Directions.Add(new DirectionOp()
                        {
                            Direction = lastDirection.Value,
                            Length    = lastDirectionSize
                        });
                        lastDirection     = direction;
                        lastDirectionSize = 1;
                    }
                }
            }

            directionInfo.Directions.Add(new DirectionOp()
            {
                Direction = lastDirection.Value,
                Length    = lastDirectionSize
            });

            return(directionInfo);
        }