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


C# Vector2.ToString方法代码示例

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


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

示例1: HandleEvents


//.........这里部分代码省略.........
                        unlockedW = true;
                        unlockedH = true;
                    }
                    else if(_dragTarget == DragTargetType.BoxNode5)
                    {
                        unlockedW = true;
                    }

                    else if(_dragTarget == DragTargetType.BoxNode6)
                    {
                        unlockedX = true;
                        unlockedH = true;
                    }
                    else if(_dragTarget == DragTargetType.BoxNode7)
                    {
                        unlockedH = true;
                    }
                    else if(_dragTarget == DragTargetType.BoxNode8)
                    {
                        unlockedX = true;
                        unlockedH = true;
                    }

                    if(unlockedX || unlockedY || unlockedW || unlockedH)
                    {
                        //_dragDelta.x = Mathf.Ceil(_dragDelta.x / _zoom);
                        //_dragDelta.y = Mathf.Ceil(_dragDelta.y / _zoom);
                        //float dx = Mathf.Floor(_dragDelta.x / _zoom);

                        int dxZoomed = Mathf.RoundToInt(_dragDelta.x / _zoom);
                        int dyZoomed = Mathf.RoundToInt(_dragDelta.y / _zoom);

                        //Debug.Log("dxZoomed = " + dxZoomed.ToString());
                        Debug.Log("_dragDelta = " + _dragDelta.ToString());

                        if(unlockedX)
                        {
                            if(_frame.X + dxZoomed < 0)
                            {
                                dxZoomed = Mathf.FloorToInt((0 - _frame.X));
                            }
                            else if(_frame.X + dxZoomed > _frame.MaxX)
                            {
                                dxZoomed = Mathf.FloorToInt((_frame.MaxX - _frame.X));
                            }

                            _frame.X += dxZoomed;
                            _frame.Width -= dxZoomed;

                        }
                        //
                        if(unlockedY)
                        {
                            if(_frame.Y + dyZoomed < 0)
                            {
                                dyZoomed = Mathf.FloorToInt((0 - _frame.Y));
                            }
                            else if(_frame.X + dyZoomed > _frame.MaxY)
                            {
                                dyZoomed = Mathf.FloorToInt((_frame.MaxY - _frame.Y));
                            }

                            _frame.Y += dyZoomed;
                            _frame.Height -= dyZoomed;

                        }
开发者ID:redastruikys,项目名称:quest,代码行数:67,代码来源:SpriteEditor.cs

示例2: buildStructure

        /// <summary>
        /// This will build a structure that fits within the dimensions
        /// based on the seed passed in.
        /// </summary>
        /// <returns>The structure.</returns>
        /// <param name="dimensions">Dimensions.</param>
        /// <param name="seed">Seed.</param>
        /// <param name="theme">Theme.</param>
        public static GameObject buildStructure(Vector2 dimensions, int seed, AreaBiome theme, float civValue)
        {
            // First we begin by determining how many blocks we can fit in the x and y dimensions
            // plotDimensions is how many modules you can fit in the structure.
            float blockDimension = 3.0f;
            Vector2 plotDimensions = new Vector2( Mathf.FloorToInt( dimensions.x / blockDimension ), Mathf.FloorToInt( dimensions.y / blockDimension ));

            // Create random blueprints
            int[][] blueprints = generateBoringBlueprints (plotDimensions, seed, civValue);

            // If there are no blue prints don't go any further
            if(blueprints == null){
                return null;
            }

            // Build from the blueprints
            GameObject structure = new GameObject ("Structure: "+seed+", "+dimensions.ToString());

            for(int x = 0; x < blueprints.Length; x ++){

                for(int y = 0; y < blueprints[x].Length; y ++){

                    // Get the number of floors wanted from this module's position.
                    int floors = blueprints[x][y];

                    // Move to the next portion if there's nothin to build here.
                    if(floors <= 0){
                        continue;
                    }

                    int[][] wallInformation = wallsModuleIsTouching(blueprints, x, y);

                    // Build a module for each floor
                    for(int f = 0; f < floors; f ++){

                        // Whether or not to create a turret on this floor
                        bool createTurret = false;

                        // Just use a cube for now
                        GameObject module = null;

                        // The number of walls that are touching this floor
                        int numOfWallsTouchingThisFloor = 0;

                        List<int> neighboringWallDirections = new List<int>();

                        // Find the walls touching this floor
                        for(int w = 0; w < wallInformation.Length; w ++){

                            if(wallInformation[w][1]  >= f + 1){

                                numOfWallsTouchingThisFloor ++;
                                neighboringWallDirections.Add(wallInformation[w][0]);

                            }

                        }

                        if(numOfWallsTouchingThisFloor == 0){

                            module = Resources.Load("Structures/Civilization/Basic/0STop") as GameObject;
                            module = GameObject.Instantiate(module);

                        } else if(numOfWallsTouchingThisFloor == 1){

                            if(f == floors-1){
                                module = Resources.Load("Structures/Civilization/Basic/1STop") as GameObject;
                            } else {
                                module = Resources.Load("Structures/Civilization/Basic/1SMid") as GameObject;
                            }

                            module = GameObject.Instantiate(module);

                            // Find the correct rotation.
                            switch(neighboringWallDirections[0]){

                            // East
                            case 0:
                                module.transform.Rotate(new Vector3(0,270,0));
                                break;

                            // West
                            case 1:
                                module.transform.Rotate(new Vector3(0,90,0));
                                break;

                            // North
                            case 2:
                                module.transform.Rotate(new Vector3(0,180,0));
                                break;

                            }
//.........这里部分代码省略.........
开发者ID:EliCDavis,项目名称:DontStopRunning,代码行数:101,代码来源:StructureFactory.cs

示例3: DebugLog

 public virtual void DebugLog(Vector2 message)
 {
     if (_showDebug)
         Debug.Log(message.ToString());
 }
开发者ID:paigetech,项目名称:FPS_Walk_Through,代码行数:5,代码来源:UltraRealMonobehaviorBase.cs

示例4: CreateArea

        /// <summary>
        /// Generates terrain and the buildings that occupy the terrain.
        /// </summary>
        /// <param name="sectionsInXDirection">Sections in X direction.</param>
        /// <param name="sectionsInYDirection">Sections in Y direction.</param>
        /// <param name="border">Border of sections passed in.  if you pass in 10*10 sections
        /// and a border of 2, your final result will be a 14*14
        /// </param>
        void CreateArea(int sectionsInXDirection, int sectionsInYDirection, int border)
        {
            // Clear what we have defined as 'free area', array of area that AI can move through
            freeArea.Clear ();

            // Choose the maps dimensions
            int mapHeight = 1025;
            int mapWidth = 1025;

            // Create a seed for our generation, useful for generating the same map over and over if we so choose to
            Vector2 civSeed = new Vector2 (Random.Range (0, 10000), Random.Range (0, 10000));

            // Produce a civilization map, with alpha being civilization
            Texture2D civMap = MapGen.GetInstance ().CreateMap (mapWidth, mapHeight, (int)civSeed.x, (int)civSeed.y);
            civMap = MapGen.GetInstance ().SmoothEdges (civMap);
            guiMapRenderOne = civMap;//for guiPurposes.

            // Create our terrain object and position and scale it correctely
            GameObject terrain = GameObject.CreatePrimitive(PrimitiveType.Plane);
            terrain.transform.position = new Vector3 ( (dimensionOfSection*(sectionsInXDirection))/2, 0, (dimensionOfSection*(sectionsInYDirection))/2);
            terrain.transform.Rotate (new Vector3 (0, 180, 0));
            terrain.transform.localScale = new Vector3 ( (dimensionOfSection*(sectionsInXDirection))/10, 1, (dimensionOfSection*(sectionsInYDirection))/10);

            // Set the material on the terrain that will make it look like terain
            Material material = new Material(Shader.Find("MyShaders/TerrainTwoLayer"));

            // Set the texture on the terrain that will represent civilization
            material.SetTexture ("_MainTex", civArea);
            material.SetTextureScale ("_MainTex", new Vector2(70,70));

            // Set the texture on the terrain that will represent the wild.
            material.SetTexture ("_PathTex", uncivArea);
            material.SetTextureScale ("_PathTex", new Vector2(70,70));

            // Set the alpha that determines whether or not to render the wild or the civilization texture.
            material.SetTexture ("_PathMask", civMap);

            // Set the material to the terrain
            terrain.GetComponent<Renderer> ().material = material;

            // Create the area object
            currentArea = new Area ("Civ Seed: "+civSeed.ToString(), AreaBiome.Test, civSeed);

            // Create structures by splitting up the civilization map into multiple sections to be generated.
            for (int curXSec = 0; curXSec < sectionsInXDirection; curXSec++) {

                for (int curYSec = 0; curYSec < sectionsInYDirection; curYSec++) {

                    int sectionMapWidth = mapWidth / sectionsInXDirection;
                    int sectionMapHeight = mapHeight / sectionsInYDirection;

                    Texture2D sectionMap = new Texture2D (sectionMapWidth, sectionMapHeight);

                    sectionMap.SetPixels (civMap.GetPixels (curXSec * sectionMapWidth,
                                                            curYSec * sectionMapHeight,
                                                            sectionMapWidth, sectionMapHeight));

                    sectionMap.Apply ();

                    createSection (curXSec, curYSec, sectionMap);

                }

            }

            // Spawn trees to make things look more full
            spawnUncivilizedObjects (sectionsInXDirection, sectionsInYDirection, civMap);
        }
开发者ID:EliCDavis,项目名称:DontStopRunning,代码行数:76,代码来源:AreaGenerator.cs

示例5: DrawNode

        void DrawNode(Node node)
        {
            Color originalColor = GUI.color;

            if(brain.defaultNode == node)
                GUI.color = Color.yellow;

            if(brain.anyNode == node)
                GUI.color = Color.magenta;

            if(selectedNode == node)
                GUI.color = Color.green;

            Vector2 originalPosition = new Vector2(node.position.x, node.position.y);

            node.position.x += scrollPosition.x;
            node.position.y += scrollPosition.y;

            if(selectedNode == node)
            {
                Rect positionLabelRect = new Rect(node.position);
                positionLabelRect.y += node.position.height;
                GUI.Label(positionLabelRect, originalPosition.ToString());
            }

            GUILayout.BeginArea(node.position);
            GUI.Box(new Rect(0, 0, node.position.width, node.position.height), "");
            GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
            labelStyle.fontSize = brain.anyNode == node ? 48 : 12;
            labelStyle.fontStyle = FontStyle.Bold;
            labelStyle.alignment = TextAnchor.MiddleCenter;
            labelStyle.wordWrap = true;
            GUI.Label(new Rect(0, 0, node.position.width, node.position.height), node.name, labelStyle);
            GUILayout.EndArea();

            if(Event.current.button == 0)
            {
                switch(Event.current.type)
                {
                    case EventType.MouseDown:
                        if(node.position.Contains(Event.current.mousePosition))
                        {
                            if(linkNode != null && linkNode != node)
                            {
                                if(node == brain.anyNode)
                                {
                                    ShowNotification(new GUIContent("Can not connect to the Ω node."));
                                }
                                else if(linkNode.HasConnectionTo(node))
                                {
                                    ShowNotification(new GUIContent("Can not connect to the same node twice."));
                                }
                                else
                                {
                                    selectedConnection = brain.CreateConnection(linkNode, node);
                                    AddToBrainAsset(selectedConnection);
                                }

                                linkNode = null;
                            }

                            dragNode = node;
                            selectedNode = node;
                            Event.current.Use();
                            Save();
                        }
                        break;

                    case EventType.MouseDrag:
                        if(dragNode == node)
                        {
                            originalPosition.x += Event.current.delta.x;
                            originalPosition.y += Event.current.delta.y;
                            Event.current.Use();
                            Repaint();
                        }
                        break;

                    case EventType.MouseUp:
                        if(dragNode == node)
                        {
                            dragNode = null;
                            int snap = 64;
                            originalPosition.x = Mathf.RoundToInt(originalPosition.x / snap) * snap;
                            originalPosition.y = Mathf.RoundToInt(originalPosition.y / snap) * snap;
                            Event.current.Use();
                            Repaint();
                        }
                        break;
                }
            }

            node.position.x = originalPosition.x;
            node.position.y = originalPosition.y;

            GUI.color = originalColor;
        }
开发者ID:hellotheredev,项目名称:Brains,代码行数:97,代码来源:BrainWindow.cs


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