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


C# RawList.CopyTo方法代码示例

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


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

示例1: CopyTo

        public void CopyTo()
        {
            RawList<int> list = new RawList<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100, 100, 100 }, 10);
            RawList<int> listCopy = new RawList<int>(list);

            Assert.AreNotSame(list.Data, listCopy.Data);
            Assert.AreEqual(list.Count, listCopy.Count);
            CollectionAssert.AreEqual(list.Data.Take(list.Count), listCopy.Data.Take(list.Count));
            CollectionAssert.AreEqual(list, listCopy);

            RawList<int> listCopy2 = new RawList<int>();
            Assert.Throws<ArgumentNullException>(() => list.CopyTo(null, 0, 1));
            Assert.Throws<ArgumentException>(() => list.CopyTo(listCopy2, 0, 17));
            Assert.Throws<ArgumentException>(() => list.CopyTo(listCopy2, -1, 1));

            CollectionAssert.AreEqual(new int[] { }, listCopy2);
            list.CopyTo(listCopy2, 1, 2);
            CollectionAssert.AreEqual(new int[] { 0, 0, 1 }, listCopy2);
            list.CopyTo(listCopy2, 0, 10);
            CollectionAssert.AreEqual(list, listCopy2);
        }
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:21,代码来源:RawListTest.cs

示例2: GetTileAreaOutlines

        private static void GetTileAreaOutlines(IReadOnlyGrid<bool> tileArea, Vector2 tileSize, ref List<Vector2[]> outlines)
        {
            // Initialize the container we'll put our outlines into
            if (outlines == null)
                outlines = new List<Vector2[]>();
            else
                outlines.Clear();

            // Generate a data structure containing all visible edges
            TileEdgeMap edgeMap = new TileEdgeMap(tileArea.Width + 1, tileArea.Height + 1);
            for (int y = 0; y < edgeMap.Height; y++)
            {
                for (int x = 0; x < edgeMap.Width; x++)
                {
                    // Determine highlight state of the four tiles around this node
                    bool topLeft     = x > 0              && y > 0               && tileArea[x - 1, y - 1];
                    bool topRight    = x < tileArea.Width && y > 0               && tileArea[x    , y - 1];
                    bool bottomLeft  = x > 0              && y < tileArea.Height && tileArea[x - 1, y    ];
                    bool bottomRight = x < tileArea.Width && y < tileArea.Height && tileArea[x    , y    ];

                    // Determine which edges are visible
                    if (topLeft     != topRight   ) edgeMap.AddEdge(new Point2(x, y), new Point2(x    , y - 1));
                    if (topRight    != bottomRight) edgeMap.AddEdge(new Point2(x, y), new Point2(x + 1, y    ));
                    if (bottomRight != bottomLeft ) edgeMap.AddEdge(new Point2(x, y), new Point2(x    , y + 1));
                    if (bottomLeft  != topLeft    ) edgeMap.AddEdge(new Point2(x, y), new Point2(x - 1, y    ));
                }
            }

            // Traverse edges to form outlines until no more edges are left
            RawList<Vector2> outlineBuilder = new RawList<Vector2>();
            while (true)
            {
                // Find the beginning of an outline
                Point2 current = edgeMap.FindNonEmpty();
                if (current.X == -1 || current.Y == -1) break;

                // Traverse it until no more edges are left
                while (true)
                {
                    Point2 next = edgeMap.GetClockwiseNextFrom(current);
                    if (next.X == -1 || next.Y == -1) break;

                    outlineBuilder.Add(next * tileSize);
                    edgeMap.RemoveEdge(current, next);
                    current = next;
                }

                // Close the loop by adding the first element again
                if (outlineBuilder.Count > 0)
                    outlineBuilder.Add(outlineBuilder[0]);

                // If we have enough vertices, keep the outline for drawing
                Vector2[] outline = new Vector2[outlineBuilder.Count];
                outlineBuilder.CopyTo(outline, 0);
                outlines.Add(outline);

                // Reset the outline builder to an empty state
                outlineBuilder.Clear();
            }
        }
开发者ID:SirePi,项目名称:duality,代码行数:60,代码来源:TilemapEditorCamViewState.cs


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