當前位置: 首頁>>代碼示例>>C#>>正文


C# Coordinate.Move方法代碼示例

本文整理匯總了C#中System.Coordinate.Move方法的典型用法代碼示例。如果您正苦於以下問題:C# Coordinate.Move方法的具體用法?C# Coordinate.Move怎麽用?C# Coordinate.Move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Coordinate的用法示例。


在下文中一共展示了Coordinate.Move方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Raycast

 public RaycastResult Raycast(Coordinate start, Direction dir, int length)
 {
     return this.Raycast(start, start.Move(dir, length));
 }
開發者ID:kernelbitch,項目名稱:Lemma,代碼行數:4,代碼來源:Map.cs

示例2: adjacentToFilledCell

 private bool adjacentToFilledCell(Coordinate coord)
 {
     return this[coord.Move(0, 0, 1)].ID != 0
     || this[coord.Move(0, 1, 0)].ID != 0
     || this[coord.Move(0, 1, 1)].ID != 0
     || this[coord.Move(1, 0, 0)].ID != 0
     || this[coord.Move(1, 0, 1)].ID != 0
     || this[coord.Move(1, 1, 0)].ID != 0
     || this[coord.Move(1, 1, 1)].ID != 0
     || this[coord.Move(0, 0, -1)].ID != 0
     || this[coord.Move(0, -1, 0)].ID != 0
     || this[coord.Move(0, -1, -1)].ID != 0
     || this[coord.Move(-1, 0, 0)].ID != 0
     || this[coord.Move(-1, 0, 1)].ID != 0
     || this[coord.Move(-1, -1, 0)].ID != 0
     || this[coord.Move(-1, -1, -1)].ID != 0;
 }
開發者ID:kernelbitch,項目名稱:Lemma,代碼行數:17,代碼來源:Map.cs

示例3: FindClosestFilledCell

        public Coordinate? FindClosestFilledCell(Coordinate coord, int maxDistance = 20)
        {
            if (this[coord].ID != 0)
                return coord;

            Vector3 pos = this.GetRelativePosition(coord);

            Coordinate? closestCoord = null;

            for (int radius = 1; radius < maxDistance; radius++)
            {
                float closestDistance = float.MaxValue;

                // Left
                for (int y = -radius; y <= radius; y++)
                {
                    for (int z = -radius; z <= radius; z++)
                    {
                        Coordinate c = coord.Move(-radius, y, z);
                        if (this[c].ID != 0)
                        {
                            float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
                            if (distance < closestDistance)
                            {
                                closestDistance = distance;
                                closestCoord = c;
                            }
                        }
                    }
                }

                // Right
                for (int y = -radius; y <= radius; y++)
                {
                    for (int z = -radius; z <= radius; z++)
                    {
                        Coordinate c = coord.Move(radius, y, z);
                        if (this[c].ID != 0)
                        {
                            float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
                            if (distance < closestDistance)
                            {
                                closestDistance = distance;
                                closestCoord = c;
                            }
                        }
                    }
                }

                // Bottom
                for (int x = -radius + 1; x < radius; x++)
                {
                    for (int z = -radius + 1; z < radius; z++)
                    {
                        Coordinate c = coord.Move(x, -radius, z);
                        if (this[c].ID != 0)
                        {
                            float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
                            if (distance < closestDistance)
                            {
                                closestDistance = distance;
                                closestCoord = c;
                            }
                        }
                    }
                }

                // Top
                for (int x = -radius + 1; x < radius; x++)
                {
                    for (int z = -radius + 1; z < radius; z++)
                    {
                        Coordinate c = coord.Move(x, radius, z);
                        if (this[c].ID != 0)
                        {
                            float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
                            if (distance < closestDistance)
                            {
                                closestDistance = distance;
                                closestCoord = c;
                            }
                        }
                    }
                }

                // Backward
                for (int x = -radius + 1; x < radius; x++)
                {
                    for (int y = -radius; y <= radius; y++)
                    {
                        Coordinate c = coord.Move(x, y, -radius);
                        if (this[c].ID != 0)
                        {
                            float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
                            if (distance < closestDistance)
                            {
                                closestDistance = distance;
                                closestCoord = c;
                            }
                        }
//.........這裏部分代碼省略.........
開發者ID:kernelbitch,項目名稱:Lemma,代碼行數:101,代碼來源:Map.cs


注:本文中的System.Coordinate.Move方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。