当前位置: 首页>>代码示例>>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;未经允许,请勿转载。