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


C# Location.ToVector3方法代码示例

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


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

示例1: DrawLine

 public static void DrawLine(Location from, Location to, Color4 color)
 {
     var vertices = new PositionColored[2];
     vertices[0] = new PositionColored(from.ToVector3(), color.ToArgb());
     vertices[1] = new PositionColored(to.ToVector3(), color.ToArgb());
     Device.DrawUserPrimitives(PrimitiveType.LineList, 1, vertices);
 }
开发者ID:aash,项目名称:cleanCore,代码行数:7,代码来源:Rendering.cs

示例2: DrawCircle

        public static unsafe void DrawCircle(Location center, float radius, Color innerColor, Color outerColor, int complexity = 24, bool isFilled = true)
        {
            var vertices = new List<PositionColored>();

            if (isFilled)
                vertices.Add(new PositionColored(Vector3.Zero, innerColor.ToArgb()));

            double stepAngle = (Math.PI * 2) / complexity;
            for (int i = 0; i <= complexity; i++)
            {
                double angle = (Math.PI * 2) - (i * stepAngle);
                float x = (float)(radius * Math.Cos(angle));
                float y = (float)(-radius * Math.Sin(angle));
                vertices.Add(new PositionColored(new Vector3(x, y, 0), outerColor.ToArgb()));
            }

            var buffer = vertices.ToArray();

            InternalRender(center.ToVector3() + new Vector3(0, 0, 0.3f));

            if (isFilled)
                Device.DrawUserPrimitives(PrimitiveType.TriangleFan, buffer.Length - 2, buffer);
            else
                Device.DrawUserPrimitives(PrimitiveType.LineStrip, buffer.Length - 1, buffer);
        }
开发者ID:Vipeax,项目名称:cleanLayer,代码行数:25,代码来源:Rendering.cs

示例3: GetRandomPosition

        private Vector3 GetRandomPosition(int groupId)
        {
            GameObject group = cubeCreator.groups[groupId];

            // キューブの位置をリスト化
            var positions = Enumerable
                .Range(0, group.transform.childCount)
                .Select(index => group.transform.GetChild(index))
                .Select(child => child.position)
                .ToList();

            // Pivot Cube Position
            positions.Insert(0, Vector3.zero);

            // 生成可能範囲を取得
            int xCanPutMin = xMin - positions.Min(p => (int)p.x);
            int xCanPutMax = xMax - positions.Max(p => (int)p.x);
            int zCanPutMin = zMin - positions.Min(p => (int)p.z);
            int zCanPutMax = zMax - positions.Max(p => (int)p.z);

            // 突然変異
            float probabilityOfMutation = GetProbabilityOfMutation();
            if (Random.value < probabilityOfMutation)
            {
                Debug.Log("mutatoin!!");
                var playerLocation = new Location(player.transform.position);
                playerLocation.x = Mathf.Clamp(playerLocation.x, xCanPutMin, xCanPutMax);
                playerLocation.z = Mathf.Clamp(playerLocation.z, zCanPutMin, zCanPutMax);
                return playerLocation.ToVector3();
            }

            // 生成可能範囲を配列化
            Location[] canPutLocations =
                (from x in Enumerable.Range(xCanPutMin, xCanPutMax - xCanPutMin + 1)
                 from z in Enumerable.Range(zCanPutMin, zCanPutMax - zCanPutMin + 1)
                 select new Location(x, z))
                .ToArray();

            // 評価の取得
            Dictionary<Location, int> cubeLengths = GetCubeLengths(positions);
            Dictionary<Location, int> heightMap = GetHeightMap();
            Dictionary<Location, int> scores = GetScores(canPutLocations, cubeLengths, heightMap);

            var scoreMin = scores.Min(score => score.Value);
            var threshold = GetScoreThreshold();
            var candidates =
                scores
                    .Where(score => score.Value >= scoreMin && score.Value <= scoreMin + threshold)
                    .Select(score => score.Key)
                    .ToArray();

            var randomPosition = candidates[Random.Range(0, candidates.Length)].ToVector3();
            return randomPosition;
        }
开发者ID:MAX-eipi,项目名称:NOBOTTOWER,代码行数:54,代码来源:CubeManager.cs

示例4: DrawLine

        public static void DrawLine(Location from, Location to, Color color)
        {
            var vertices = new PositionColored[2];
            vertices[0] = new PositionColored(Vector3.Zero, color.ToArgb());
            vertices[1] = new PositionColored(to.ToVector3() - from.ToVector3(), color.ToArgb());

            InternalRender(from.ToVector3());

            Device.DrawUserPrimitives(PrimitiveType.LineList, vertices.Length / 2, vertices);
        }
开发者ID:Vipeax,项目名称:cleanLayer,代码行数:10,代码来源:Rendering.cs


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