Пример #1
0
        //----------------------------------------------------------------------------


        //----------------------------------------------------------------------------
        //new Vector3(end.x, end.y + end.height / 2, 0);
        Vector3 getEndPos(Rect start, Rect end, nodeLocation currentNodeLocation, int repeatCount)
        {
            float adj  = 10;
            float adj2 = 0;

            if (start == end)
            {
                adj2 = 60.0f;
            }

            if (currentNodeLocation == nodeLocation.right)
            {
                return(new Vector3(end.x - adj, end.y + end.height / 1.5f + repeatCount * 10 + adj2, 0));
            }
            if (currentNodeLocation == nodeLocation.left)
            {
                return(new Vector3(end.x + end.width + adj, end.y + end.height / 1.5f + repeatCount * 10 + adj2, 0));
            }
            if (currentNodeLocation == nodeLocation.top)
            {
                return(new Vector3(end.x + end.width / 1.5f + repeatCount * 10 + adj2, end.y + end.height + adj, 0));
            }
            if (currentNodeLocation == nodeLocation.bottom)
            {
                return(new Vector3(end.x + end.width / 1.5f + repeatCount * 10 + adj2, end.y - adj, 0));
            }
            return(new Vector3(end.x, end.y + end.height / 1.5f, 0));
        }
Пример #2
0
        //----------------------------------------------------------------------------



        //----------------------------------------------------------------------------
        void DrawNodeCurve(Rect start, Rect end, EventConnection eventCon)
        {
            nodeLocation currentNodeLocation = getNodeLocation(start, end);

            Vector3 startPos = getStartPos(start, end, currentNodeLocation, eventCon.fromToCount);
            Vector3 endPos   = getEndPos(start, end, currentNodeLocation, eventCon.fromToCount);

            eventCon.fromPT = startPos;
            eventCon.toPT   = endPos;

            float chunk = Vector3.Distance(startPos, endPos) / 2.5f;

            Vector3 startTan = getStartTan(currentNodeLocation, chunk, startPos);
            Vector3 endTan   = getEndTan(currentNodeLocation, chunk, endPos);        //endPos +  chunk*Vector3.left;;

            Color shadowCol = new Color(0, 0, 0, 0.06f);

            //Vector3 end3=new Vector3(endPos.x-(endPos.x- startPos.x)/45,endPos.y-(endPos.y- startPos.y)/45,0);

            for (int i = 0; i < 3; i++)
            {                    // Draw a shadow
                //arrow = Resources.GetBuiltinResource<Texture>("/stateMachine/Resources/arrow.png");
                Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 3) * 5);
            }
            float arrowSize = 17;
            Rect  arrowRect = new Rect(endPos.x - arrowSize / 2, endPos.y - arrowSize / 2, arrowSize, arrowSize);

            if (currentNodeLocation == nodeLocation.bottom)
            {
                arrow = (Texture2D)Resources.Load("arrowDown", typeof(Texture2D));
            }

            else
            if (currentNodeLocation == nodeLocation.top)
            {
                arrow = (Texture2D)Resources.Load("arrowUp", typeof(Texture2D));
            }
            else
            if (currentNodeLocation == nodeLocation.left)
            {
                arrow = (Texture2D)Resources.Load("arrowLeft", typeof(Texture2D));
            }
            else
            {
                arrow = (Texture2D)Resources.Load("arrowRight", typeof(Texture2D));
            }


            //GUIUtility.RotateAroundPivot(20,new Vector2(0,0));

            Handles.color = Color.white;


            //Handles.ConeCap (0,end3, Quaternion.AngleAxis(0,Vector3.down) ,11);
            //Handles.ConeCap (0,endPos, Quaternion.AngleAxis(0,Vector3.down) ,7);

            Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.gray, null, 2);
            drawHandle(startPos);
            GUI.DrawTexture(arrowRect, arrow);
        }
Пример #3
0
        //----------------------------------------------------------------------------


        //----------------------------------------------------------------------------
        Vector3 getStartPos(Rect start, Rect end, nodeLocation currentNodeLocation, int repeatCount)
        {
            float adj = 0;

            if (start == end)
            {
                adj = -60.0f;
            }
            float boxAdjust = 2;

            if (currentNodeLocation == nodeLocation.right)
            {
                return(new Vector3(start.x + start.width + boxAdjust, start.y + start.height / 3 + repeatCount * 10 + adj, 0));
            }
            if (currentNodeLocation == nodeLocation.left)
            {
                return(new Vector3(start.x - boxAdjust, start.y + start.height / 3 + repeatCount * 10 + adj, 0));
            }
            if (currentNodeLocation == nodeLocation.top)
            {
                return(new Vector3(start.x + start.width / 3 + repeatCount * 10 + adj, start.y - boxAdjust, 0));
            }
            if (currentNodeLocation == nodeLocation.bottom)
            {
                return(new Vector3(start.x + start.width / 3 + repeatCount * 10 + adj, start.y + start.height + boxAdjust, 0));
            }
            return(new Vector3(start.x + start.width, start.y + start.height / 2, 0));
        }
Пример #4
0
        //----------------------------------------------------------------------------



        //----------------------------------------------------------------------------
        Vector3 getEndTan(nodeLocation currentNodeLocation, float chunk, Vector3 endPos)
        {
            if (currentNodeLocation == nodeLocation.right)
            {
                return(endPos + chunk * Vector3.left);
            }
            if (currentNodeLocation == nodeLocation.left)
            {
                return(endPos + chunk * Vector3.right);
            }
            if (currentNodeLocation == nodeLocation.top)
            {
                return(endPos + chunk * Vector3.up);
            }
            if (currentNodeLocation == nodeLocation.bottom)
            {
                return(endPos + chunk * Vector3.down);
            }
            return(endPos + chunk * Vector3.right);
        }