Exemple #1
0
        public void CompareSpiralLoopToGenerateLoopCoords_BreakCondition()
        {
            var radius = 50;

            var expected = new List <Vector2>();

            LoopUtil.SpiralLoop(radius, radius, (x, y) => {
                if (x == 4)
                {
                    return(false);
                }

                expected.Add(new Vector2(x, y));
                return(true);
            });

            var actual = new List <Vector2>();

            foreach (var item in LoopUtil.GenerateSpiralGridCoordsClockwise().Take(radius * radius))
            {
                if (item.x == 4)
                {
                    break;
                }

                actual.Add(item);
            }

            CollectionAssert.AreEqual(expected, actual);
        }
        public void GenerateSpiralGridCoordsClockwise_Once_Radius17()
        {
            var radius = 17;
            var coords = LoopUtil.GenerateSpiralGridCoordsClockwise().Take(radius * radius);

            foreach (var coord in coords)
            {
            }
        }
        public void GenerateSpiralGridCoordsClockwise_10Times_Radius17()
        {
            for (int i = 0; i < 10; i++)
            {
                var posX = 3621;
                var posY = 2342;
                var BUILDINGGRID_CELL_SIZE  = 64;
                var BUILDINGGRID_RESOLUTION = 270;

                var centerI = (int)((posX / BUILDINGGRID_CELL_SIZE) +
                                    (BUILDINGGRID_RESOLUTION / 2f));
                var centerJ = (int)((posY / BUILDINGGRID_CELL_SIZE) +
                                    (BUILDINGGRID_RESOLUTION / 2f));

                int radius = 17;

                ushort     ignoreParked   = 1;
                Vector3    refPos         = Vector3.back;
                float      width          = 5f;
                float      length         = 5f;
                bool       randomize      = true;
                ushort     foundSegmentId = 0;
                Vector3    myParkPos      = Vector3.back;
                Quaternion myParkRot      = Quaternion.identity;
                float      myParkOffset   = 10f;

                bool LoopHandler(int x, int y)
                {
                    if (randomize)
                    {
                        width = ignoreParked
                                + refPos.x
                                + length
                                + length
                                + foundSegmentId
                                + myParkPos.x
                                + myParkPos.x
                                + myParkRot.x
                                + myParkOffset;
                    }

                    return(true);
                }

                foreach (var position in LoopUtil.GenerateSpiralGridCoordsClockwise().Take(radius * radius))
                {
                    var positionWithOffset = position + new Vector2(centerI, centerJ);
                    if (LoopHandler((int)positionWithOffset.x, (int)positionWithOffset.y))
                    {
                        break;
                    }
                }
            }
        }
        public void GenerateSpiralGridCoordsClockwise_10Times_Radius17()
        {
            var radius = 17;

            for (int i = 0; i < 10; i++)
            {
                var coords = LoopUtil.GenerateSpiralGridCoordsClockwise().Take(radius * radius);
                foreach (var coord in coords)
                {
                }
            }
        }
        public void CompareSpiralLoopToGenerateLoopCoords_Radius33()
        {
            var radius = 33;

            var expected = new List <Vector2>();

            LoopUtil.SpiralLoop(radius, radius, (x, y) => {
                expected.Add(new Vector2(x, y));
                return(true);
            });

            var actual = LoopUtil.GenerateSpiralGridCoordsClockwise(radius)
                         .ToList();

            CollectionAssert.AreEqual(expected, actual);
        }
Exemple #6
0
        public void GenerateSpiralGridCoordsClockwise_Radius1()
        {
            var radius   = 1;
            var expected = new List <Vector2>()
            {
                new Vector2()
                {
                    x = 0f, y = 0f
                }
            };

            var actual = LoopUtil.GenerateSpiralGridCoordsClockwise()
                         .Take(radius * radius)
                         .ToList();

            CollectionAssert.AreEqual(expected, actual);
        }
        public void CompareSpiralLoopToGenerateLoopCoords_Radius33_WithOffset()
        {
            var radius = 33;
            var offset = new Vector2(121.3f, 324.7f);

            var expected = new List <Vector2>();

            LoopUtil.SpiralLoop((int)offset.x, (int)offset.y, radius, radius, (x, y) => {
                expected.Add(new Vector2(x, y));
                return(true);
            });

            var actual = LoopUtil.GenerateSpiralGridCoordsClockwise(radius)
                         .Select(p => p + new Vector2((int)offset.x, (int)offset.y))
                         .ToList();

            CollectionAssert.AreEqual(expected, actual);
        }
        private ExtPathManager()
        {
            var radius = 3;

            _spiralGridCoordsCache = LoopUtil.GenerateSpiralGridCoordsClockwise(3).ToArray();
        }