示例#1
0
        /// <summary>
        /// エッジ伸ばし開始
        /// </summary>
        /// <param name="start"></param>
        public void EdgeStart(uDraggableNode node, ConnectBox start)
        {
            // 既に接続されてないかチェック
            foreach (var edge in edgeList)
            {
                if (edge.edgeEnd != null && edge.edgeEnd.connact == start)
                {
                    edge.edgeEnd = null;
                    ActiveEdge   = edge;
                    return;
                }
                if (edge.edgeStart.connact == start)
                {
                    edge.edgeStart = null;
                    ActiveEdge     = edge;
                    return;
                }
            }


            uNodeEdge newedge = new uNodeEdge(this, new uNodeEdge.ConnectNode(node, start));

            ActiveEdge = newedge;
            edgeList.Add(newedge);
        }
示例#2
0
        /// <summary>
        /// エッジ伸ばし終了
        /// </summary>
        /// <param name="start"></param>
        public void EdgeEnd(uDraggableNode node, ConnectBox end)
        {
            // 既に接続されてないかチェック
            foreach (var edge in edgeList)
            {
                if (edge.edgeEnd != null && (edge.edgeEnd.connact == end) ||
                    edge.edgeStart != null && (edge.edgeStart.connact == end))
                {
                    return;
                }
            }

            if ((ActiveEdge.edgeStart != null && ActiveEdge.edgeStart.node == node) ||
                (ActiveEdge.edgeEnd != null && ActiveEdge.edgeEnd.node == node))
            {
                return;
            }

            if (ActiveEdge.edgeEnd == null)
            {
                ActiveEdge.edgeEnd = new uNodeEdge.ConnectNode(node, end);
            }
            else if (ActiveEdge.edgeStart == null)
            {
                ActiveEdge.edgeStart = new uNodeEdge.ConnectNode(node, end);
            }
            ActiveEdge = null;
        }
示例#3
0
        /// <summary>
        /// エッジ伸ばし終了
        /// </summary>
        /// <param name="start"></param>
        public void EdgeEnd(uDraggableNode node,ConnectBox end)
        {
            // 既に接続されてないかチェック
            foreach (var edge in edgeList)
            {
                if (edge.edgeEnd != null && (edge.edgeEnd.connact == end) ||
                    edge.edgeStart!= null && (edge.edgeStart.connact == end ) )
                {
                    return;
                }
            }

            if ((ActiveEdge.edgeStart != null && ActiveEdge.edgeStart.node == node) ||
                (ActiveEdge.edgeEnd != null && ActiveEdge.edgeEnd.node == node))
            {
                return;

            }

            if (ActiveEdge.edgeEnd == null)
            {
                ActiveEdge.edgeEnd = new uNodeEdge.ConnectNode(node, end);
            }
            else if (ActiveEdge.edgeStart == null)
            {
                ActiveEdge.edgeStart = new uNodeEdge.ConnectNode(node, end);
            }
            ActiveEdge = null;
        }
示例#4
0
 /// <summary>
 /// GUI描画
 /// </summary>
 public override void OnDrawGUI()
 {
     if (edgeEnd == null)
     {
         ConnectAreaType type  = parentWindow.ActiveEdge.edgeStart.connact.connectArea == ConnectAreaType.AREA_LEFT ? ConnectAreaType.AREA_RIGHT : ConnectAreaType.AREA_LEFT;
         ConnectBox      mouse = new ConnectBox(type);
         mouse.boxRect = parentWindow.mouseData.rect;
         DrawNodeCurve(edgeStart.connact, mouse);
     }
     else if (edgeStart == null)
     {
         ConnectAreaType type  = parentWindow.ActiveEdge.edgeEnd.connact.connectArea == ConnectAreaType.AREA_LEFT ? ConnectAreaType.AREA_RIGHT : ConnectAreaType.AREA_LEFT;
         ConnectBox      mouse = new ConnectBox(type);
         mouse.boxRect = parentWindow.mouseData.rect;
         DrawNodeCurve(mouse, edgeEnd.connact);
     }
     else
     {
         DrawNodeCurve(edgeStart.connact, edgeEnd.connact);
     }
 }
示例#5
0
        void AddConnectBox(ConnectBox con)
        {
            int cnt = areaConnectCount[(int)con.connectArea]++;

            if (cnt > 3)
            {
                if (con.connectArea == ConnectAreaType.AREA_LEFT ||
                    con.connectArea == ConnectAreaType.AREA_RIGHT)
                {
                    realWindowRect.height += CONNECT_BOX_INTERVAL * (cnt - 3);
                    windowRect.height      = realWindowRect.height * parentWindow.Grid.m_GridZoomRate;
                }
                if (con.connectArea == ConnectAreaType.AREA_BOTTOM ||
                    con.connectArea == ConnectAreaType.AREA_TOP)
                {
                    realWindowRect.width += CONNECT_BOX_INTERVAL * (cnt - 3);
                    windowRect.width      = realWindowRect.width * parentWindow.Grid.m_GridZoomRate;
                }
            }

            connectBoxList.Add(con);
        }
示例#6
0
        /// <summary>
        /// GUI描画
        /// </summary>
        public override void OnDrawGUI()
        {
            if (edgeEnd == null)
            {

                ConnectAreaType type = parentWindow.ActiveEdge.edgeStart.connact.connectArea == ConnectAreaType.AREA_LEFT ? ConnectAreaType.AREA_RIGHT : ConnectAreaType.AREA_LEFT;
                ConnectBox mouse = new ConnectBox(type);
                mouse.boxRect = parentWindow.mouseData.rect;
                DrawNodeCurve(edgeStart.connact, mouse);
            }
            else if (edgeStart == null)
            {
                ConnectAreaType type = parentWindow.ActiveEdge.edgeEnd.connact.connectArea == ConnectAreaType.AREA_LEFT ? ConnectAreaType.AREA_RIGHT : ConnectAreaType.AREA_LEFT;
                ConnectBox mouse = new ConnectBox(type);
                mouse.boxRect = parentWindow.mouseData.rect;
                DrawNodeCurve(mouse,edgeEnd.connact);
            }
            else
            {
                DrawNodeCurve(edgeStart.connact, edgeEnd.connact);
            }
        }
示例#7
0
        void RemoveConnect(ConnectBox con)
        {
            int cnt = areaConnectCount[(int)con.connectArea]--;

            if (cnt > 3)
            {
                if (con.connectArea == ConnectAreaType.AREA_LEFT ||
                    con.connectArea == ConnectAreaType.AREA_RIGHT)
                {
                    realWindowRect.height += CONNECT_BOX_INTERVAL * (cnt - 3);
                    windowRect.height = realWindowRect.height * parentWindow.Grid.m_GridZoomRate;

                }
                if (con.connectArea == ConnectAreaType.AREA_BOTTOM ||
                     con.connectArea == ConnectAreaType.AREA_TOP)
                {
                    realWindowRect.width += CONNECT_BOX_INTERVAL * (cnt - 3);
                    windowRect.width = realWindowRect.width * parentWindow.Grid.m_GridZoomRate;

                }
            }

            connectBoxList.Remove(con);
        }
示例#8
0
        /// <summary>
        /// 更新
        /// </summary>
        public override void OnUpdate()
        {
            ConnectBox near = null;

            {
                foreach (var box in connectBoxList)
                {
                    if (box.boxRect.Overlaps(parentWindow.mouseData.rect) && windowRect.Overlaps(parentWindow.mouseData.rect))
                    {
                        if (near == null ||
                            (near.boxRect.center - parentWindow.mouseData.rect.center).magnitude >=
                            (box.boxRect.center - parentWindow.mouseData.rect.center).magnitude)
                        {
                            box.active = true;
                            if (near != null)
                            {
                                // todo:ホントは遠い方をOFFにしたいけどうまくいかないので一旦。。。
                                box.active = false;
                            }
                            near = box;
                        }
                    }
                    else
                    {
                        box.active = false;
                    }
                }
            }


            if (parentWindow.Grid.m_GridZoomRate > 0.4f)
            {
                // エッジ生成
                if (parentWindow.mouseData.IsDown(MouseButton.Left))
                {
                    if (near != null)
                    {
                        if (parentWindow.ActiveEdge == null)
                        {
                            parentWindow.EdgeStart(this, near);
                        }
                        else
                        {
                            parentWindow.EdgeEnd(this, near);
                        }
                    }
                }
            }



            // グリッド移動
            if (parentWindow.mouseData.IsDrag(MouseButton.Middle))
            {
                windowRect.position += parentWindow.mouseData.delta;
            }
            // ズーム

            Vector2 gridPos = (windowRect.position - parentWindow.Grid.GridZoomCenterPoint) / parentWindow.Grid.preGridSize;

            if (parentWindow.mouseData.IsScroll())
            {
                // ズーム率1.0のサイズにズーム率かけてサイズ算出
                windowRect.width  = realWindowRect.width * parentWindow.Grid.m_GridZoomRate;
                windowRect.height = realWindowRect.height * parentWindow.Grid.m_GridZoomRate;

                //Debug.Log("pre : " + windowRect.position.ToString());
                // ズーム無しの時の位置
                realWindowRect.position = parentWindow.Grid.GridZoomCenterPoint + GridDrawer.GRID_INTERVAL * gridPos;

                // ズーム後の位置
                windowRect.position = parentWindow.Grid.GridZoomCenterPoint + parentWindow.Grid.gridSize * gridPos;
                //Debug.Log("post : " + windowRect.position.ToString());
            }
        }
示例#9
0
        /// <summary>
        /// カーブ描画
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        void DrawNodeCurve(ConnectBox start, ConnectBox end)
        {
            /*
             * Vector3 startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
             * Vector3 endPos = new Vector3(end.x, end.y + end.height / 2, 0);
             * Vector3 startTan = startPos + Vector3.right * 50;
             * Vector3 endTan = endPos + Vector3.left * 50;
             *
             * Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 1);
             */

            // x成分
            Vector2   vecX    = (end.boxRect.center - start.boxRect.center);
            const int tanMaxX = 800;
            const int tanMaxY = 300;

            vecX.y = Mathf.Abs(vecX.y);
            //if (startInd == endInd) vecX.y = tanMaxY - vecX.y;
            float lengthX = ((tanMaxX - Mathf.Clamp(vecX.x, 0, tanMaxX)) / 5) * Mathf.Clamp(vecX.y, 0, tanMaxY) / tanMaxY;



            // y成分
            //Vector2 vecY = (end.center - start.center);
            //vecY.x = 0.0f;
            //float lengthY = (tanMax - Mathf.Clamp(vecX.magnitude, 0, tanMax)) / 5;


            //Debug.Log(length.ToString());



            var   startPos = new Vector2(start.boxRect.center.x, start.boxRect.center.y);
            float x1       = start.connectArea == ConnectAreaType.AREA_RIGHT ? start.boxRect.x + lengthX : start.boxRect.x - lengthX;
            float y1       = start.boxRect.y;
            var   startTan = new Vector3(x1, y1, 0f);


            var   endPos = new Vector2(end.boxRect.center.x, end.boxRect.center.y);
            float x2     = end.connectArea == ConnectAreaType.AREA_RIGHT ? endPos.x + lengthX : endPos.x - lengthX;
            float y2     = endPos.y;
            var   endTan = new Vector3(x2, y2, 0f);



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

            if (start.active)
            {
                shadowCol.b = 0.8f; shadowCol.g = 0.4f; shadowCol.a = 0.2f;
            }
            if (end.active)
            {
                shadowCol.b = 0.8f; shadowCol.g = 0.4f; shadowCol.a = 0.2f;
            }
            if (start.error)
            {
                shadowCol.b = 0.2f; shadowCol.g = 0.2f; shadowCol.r = 1.0f; shadowCol.a = 0.2f;
            }
            if (end.error)
            {
                shadowCol.b = 0.2f; shadowCol.g = 0.2f; shadowCol.r = 1.0f; shadowCol.a = 0.2f;
            }


            for (int i = 0; i < 3; i++)             // Draw a shadow
            {
                Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);
            }

            Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.gray, null, 3f);

            // 接続先
            GUIHelper.Fill(new Rect(endPos - new Vector2(3, 3), new Vector2(6, 6)), Color.gray);
        }
示例#10
0
 public ConnectNode(uDraggableNode n, ConnectBox c)
 {
     node    = n;
     connact = c;
 }
示例#11
0
        /// <summary>
        /// エッジ伸ばし開始
        /// </summary>
        /// <param name="start"></param>
        public void EdgeStart(uDraggableNode node,ConnectBox start)
        {
            // 既に接続されてないかチェック
            foreach (var edge in edgeList)
            {
                if (edge.edgeEnd != null && edge.edgeEnd.connact == start)
                {
                    edge.edgeEnd = null;
                    ActiveEdge = edge;
                    return;
                }
                if( edge.edgeStart.connact == start)
                {
                    edge.edgeStart = null;
                    ActiveEdge = edge;
                    return;
                }
            }

            uNodeEdge newedge = new uNodeEdge(this, new uNodeEdge.ConnectNode(node, start));
            ActiveEdge = newedge;
            edgeList.Add(newedge);
        }
示例#12
0
        /// <summary>
        /// カーブ描画
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        void DrawNodeCurve(ConnectBox start, ConnectBox end)
        {
            /*
            Vector3 startPos = new Vector3(start.x + start.width, start.y + start.height / 2, 0);
            Vector3 endPos = new Vector3(end.x, end.y + end.height / 2, 0);
            Vector3 startTan = startPos + Vector3.right * 50;
            Vector3 endTan = endPos + Vector3.left * 50;

            Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.black, null, 1);
            */

            // x成分
            Vector2 vecX = (end.boxRect.center - start.boxRect.center);
            const int tanMaxX = 800;
            const int tanMaxY = 300;
            vecX.y = Mathf.Abs(vecX.y);
            //if (startInd == endInd) vecX.y = tanMaxY - vecX.y;
            float lengthX = ((tanMaxX - Mathf.Clamp(vecX.x, 0, tanMaxX)) / 5) * Mathf.Clamp(vecX.y, 0, tanMaxY) / tanMaxY;

            // y成分
            //Vector2 vecY = (end.center - start.center);
            //vecY.x = 0.0f;
            //float lengthY = (tanMax - Mathf.Clamp(vecX.magnitude, 0, tanMax)) / 5;

            //Debug.Log(length.ToString());

            var startPos = new Vector2(start.boxRect.center.x, start.boxRect.center.y);
            float x1 = start.connectArea == ConnectAreaType.AREA_RIGHT ? start.boxRect.x + lengthX : start.boxRect.x - lengthX;
            float y1 = start.boxRect.y;
            var startTan = new Vector3(x1, y1, 0f);

            var endPos = new Vector2(end.boxRect.center.x, end.boxRect.center.y);
            float x2 = end.connectArea == ConnectAreaType.AREA_RIGHT ? endPos.x + lengthX : endPos.x - lengthX;
            float y2 = endPos.y;
            var endTan = new Vector3(x2, y2, 0f);

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

            if (start.active) { shadowCol.b = 0.8f; shadowCol.g = 0.4f; shadowCol.a = 0.2f; }
            if (end.active) { shadowCol.b = 0.8f; shadowCol.g = 0.4f; shadowCol.a = 0.2f; }
            if (start.error) { shadowCol.b = 0.2f; shadowCol.g = 0.2f; shadowCol.r = 1.0f; shadowCol.a = 0.2f; }
            if (end.error) { shadowCol.b = 0.2f; shadowCol.g = 0.2f; shadowCol.r = 1.0f; shadowCol.a = 0.2f; }

            for (int i = 0; i < 3; i++) // Draw a shadow
                Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5);

            Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.gray, null, 3f);

            // 接続先
            GUIHelper.Fill(new Rect(endPos - new Vector2(3, 3), new Vector2(6, 6)), Color.gray);
        }
示例#13
0
 public ConnectNode(uDraggableNode n ,ConnectBox c)
 {
     node = n;
     connact = c;
 }