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


C# Vector3.ToIntVector方法代码示例

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


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

示例1: GenGeometry

        private void GenGeometry()
        {
            Vector3 baseSize;
            Vector3 basePos;

            for (var x = 0; x < _room.Width; x++)
            for (var y = 0; y < _room.Height; y++)
            for (var z = 0; z < _room.Depth; z++)
            {
                var side = _room.roomBuffer[x, y, z];
                baseSize = Vector3.one*scale;
                basePos = new Vector3(x, y, z) *scale;

                var posIntVector = basePos.ToIntVector();
                if (posIntVector.Equals(_room.entryPoint))
                {
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = basePos;
                    geo.transform.localScale = baseSize*0.5f;
                    geo.GetComponent<MeshRenderer>().material.color = Color.red;
                }
                else if (posIntVector.Equals(_room.door))
                {
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = basePos;
                    geo.transform.localScale = baseSize*0.5f;
                    geo.GetComponent<MeshRenderer>().material.color = Color.green;
                }

                if ((side & Sides.Top) > 0)
                {
                    var pos = basePos + Vector3.up*0.5f;
                    var size = baseSize.ScaleBy(1, 0.1f, 1);
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = pos;
                    geo.transform.localScale = size;
                }

                if ((side & Sides.Bottom) > 0)
                {
                    var pos = basePos - Vector3.up*0.5f;
                    var size = baseSize.ScaleBy(1, 0.1f, 1);
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = pos;
                    geo.transform.localScale = size;
                }

                if ((side & Sides.Left) > 0)
                {
                    var pos = basePos + Vector3.left*0.5f;
                    var size = baseSize.ScaleBy(0.1f, 1, 1);
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = pos;
                    geo.transform.localScale = size;
                }

                if ((side & Sides.Right) > 0)
                {
                    var pos = basePos + Vector3.right*0.5f;
                    var size = baseSize.ScaleBy(0.1f, 1, 1);
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = pos;
                    geo.transform.localScale = size;
                }

                if ((side & Sides.Front) > 0)
                {
                    var pos = basePos + Vector3.forward*0.5f;
                    var size = baseSize.ScaleBy(1, 1, 0.1f);
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = pos;
                    geo.transform.localScale = size;
                }

                if ((side & Sides.Rear) > 0)
                {
                    var pos = basePos - Vector3.forward*0.5f;
                    var size = baseSize.ScaleBy(1, 1, 0.1f);
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = pos;
                    geo.transform.localScale = size;
                }

                if (side == Sides.None)
                {
                    var geo = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    geo.transform.position = basePos;
                    geo.transform.localScale = baseSize;
                    geo.GetComponent<MeshRenderer>().material.color = Color.yellow;
                }
            }
        }
开发者ID:fatiguedartist,项目名称:Sisyphus,代码行数:92,代码来源:RoomGenerator.cs

示例2: GenGeometry

        private void GenGeometry()
        {
            Vector3 baseSize;
            Vector3 pos;

            for (var x = 0; x < _room.Width; x++)
            for (var y = 0; y < _room.Height; y++)
            for (var z = 0; z < _room.Depth; z++)
            {
                var side = _room.roomBuffer[x, y, z];
                baseSize = Vector3.one;
                pos = new Vector3(x, y, z);

                var posIntVector = pos.ToIntVector();
                if (posIntVector.Equals(_room.entryPoint))
                {
                    var entryNode = entry.Instantiate();
                    entryNode.transform.parent = transform;
                    entryNode.transform.localPosition = new Vector3 (pos.x,pos.y-.15f,pos.z);
                    Destroy(entryNode.GetComponent<Collider>());
                        }
                        else if (posIntVector.Equals(_room.door))
                        {
                            var exitNode = exit.InstantiateToParentLocal(transform);
                            exitNode.transform.localPosition = pos;

                            if ((side & Sides.Top) > 0)
                            {
                                exitNode.transform.localEulerAngles = Vector3.right*180;
                            }
                            if ((side & Sides.Left) > 0)
                            {
                                exitNode.transform.localEulerAngles = Vector3.forward*-90;
                            }
                            if ((side & Sides.Right) > 0)
                            {
                                exitNode.transform.localEulerAngles = Vector3.forward*90;
                            }
                            if ((side & Sides.Front) > 0)
                            {
                                exitNode.transform.localEulerAngles = Vector3.right*-90;
                            }
                            if ((side & Sides.Rear) > 0)
                            {
                                exitNode.transform.localEulerAngles = Vector3.right * 90;
                            }
                        }

                        if (x == 0)
                        {
                            if (side == Sides.None)
                    {
                        var geo = spikesRight.InstantiateToParentLocal(transform);
                        geo.transform.localPosition = pos + Vector3.left;
                    }
                }
                if (x == _room.Width - 1)
                {
                     if (side == Sides.None)
                    {
                        var geo = spikesLeft.InstantiateToParentLocal(transform);
                        geo.transform.localPosition = pos + Vector3.right;
                    }
                }

                if (y == 0)
                {
                    if (side == Sides.None)
                    {
                        var geo = spikesTop.InstantiateToParentLocal(transform);
                        geo.transform.localPosition = pos + Vector3.down;
                    }
                }
                if (y == _room.Height - 1)
                {
                    if (side == Sides.None)
                    {
                        var geo = spikesBottom.InstantiateToParentLocal(transform);
                        geo.transform.localPosition = pos + Vector3.up;
                    }
                }

                if (z == 0)
                {
                    if (side == Sides.None)
                    {
                        var geo = spikesFront.InstantiateToParentLocal(transform);
                        geo.transform.localPosition = pos + Vector3.back;
                    }
                }
                if (z == _room.Depth - 1)
                {
                    if (side == Sides.None)
                    {
                        var geo = spikesBack.InstantiateToParentLocal(transform);
                        geo.transform.localPosition = pos + Vector3.forward;
                    }
                }

                if ((side & Sides.Top) > 0)
//.........这里部分代码省略.........
开发者ID:fatiguedartist,项目名称:Sisyphus,代码行数:101,代码来源:TestRoomGenerator.cs

示例3: OnDrawGizmos

        private void OnDrawGizmos()
        {
            if (_room == null)
                return;

            Vector3 size;
            Vector3 pos;

            Gizmos.color = Color.magenta;

            int itemIndex = -1;
            for (int index = 0; index < _room.solutionPath.Count; index++)
            {
                var int3 = _room.solutionPath[index];
                itemIndex++;

                if (itemIndex > 0)
                {
                    Gizmos.DrawLine(_room.solutionPath[itemIndex - 1].ToV3(), int3.ToV3());
                }
            }

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    for (var z = 0; z < depth; z++)
                    {
                        var side = _room.roomBuffer[x, y, z];
                        size = Vector3.one*scale*-1;
                        pos = new Vector3(x, y, z)*scale;

                        var posIntVector = pos.ToIntVector();
                        if (posIntVector.Equals(_room.entryPoint))
                        {
                            Gizmos.color = _startColor;
                            Gizmos.DrawCube(pos, size);
                        }
                        else if (posIntVector.Equals(_room.door))
                        {
                            Gizmos.color = _endColor;
                            Gizmos.DrawCube(pos, size);
                        }
                        /*
                            if ((side & Sides.Top) > 0)
                            {
                                var pos = pos + Vector3.up*0.5f;
                                var size = size.ScaleBy(1, 0.1f, 1);

                                Gizmos.color = _pathColor;
                                Gizmos.DrawCube(pos, size);
                            }

                            if ((side & Sides.Bottom) > 0)
                            {
                                var pos = pos + Vector3.up * 0.5f;
                                var size = size.ScaleBy(1, 0.1f, 1);

                                Gizmos.color = _pathColor;
                                Gizmos.DrawCube(pos, size);
                            }

                            if ((side & Sides.Left) > 0)
                            {
                                var pos = pos + Vector3.left * 0.5f;
                                var size = size.ScaleBy(0.1f, 1, 1);

                                Gizmos.color = _pathColor;
                                Gizmos.DrawCube(pos, size);
                            }

                            if ((side & Sides.Right) > 0)
                            {
                                var pos = pos + Vector3.right * 0.5f;
                                var size = size.ScaleBy(0.1f, 1, 1);

                                Gizmos.color = _pathColor;
                                Gizmos.DrawCube(pos, size);
                            }

                            if ((side & Sides.Front) > 0)
                            {
                                var pos = Vector3.forward * 0.5f;
                                var size = size.ScaleBy(1, 1, 0.1f);

                                Gizmos.color = _pathColor;
                                Gizmos.DrawCube(pos, size);
                            }

                            if ((side & Sides.Rear) > 0)
                            {
                                var pos = pos + Vector3.forward * 0.5f;
                                var size = size.ScaleBy(1, 1, 0.1f);

                                Gizmos.color = _pathColor;
                                Gizmos.DrawCube(pos, size);
                            }
                        if (side == Sides.None)
                        {
                            Gizmos.color = _wireColor;
//.........这里部分代码省略.........
开发者ID:fatiguedartist,项目名称:Sisyphus,代码行数:101,代码来源:RoomGenerator.cs


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