Exemplo n.º 1
0
        /// <summary>
        /// 添加连线
        /// </summary>
        /// <param name="linkId">连线GUID</param>
        /// <param name="nextNode">连接到的节点</param>
        public void AddLink(int linkId, GKToyNode nextNode, int height, string parmKey = "")
        {
            bool    vertical = false;
            Vector2 src      = new Vector2(outputRect.x + outputRect.width, outputRect.y + outputRect.height * 0.5f);
            Vector2 dest     = Vector2.zero;

            // 参数链接.
            if (!string.IsNullOrEmpty(parmKey) && nextNode.parmRect.ContainsKey(parmKey))
            {
                dest = new Vector2(nextNode.parmRect[parmKey].rect.x, nextNode.parmRect[parmKey].rect.y + nextNode.parmRect[parmKey].rect.height * 0.5f);
            }
            // 节点链接.
            else
            {
                dest = new Vector2(nextNode.inputRect.x, nextNode.inputRect.y + nextNode.inputRect.height * 0.5f);
            }
            if (10 <= (int)nextNode.nodeType)
            {
                otherLinks.Add(new Link(linkId, GK.ClacLinePoint(src, dest, out vertical, height), vertical, id, nextNode.id, parmKey));
            }
            else
            {
                links.Add(new Link(linkId, GK.ClacLinePoint(src, dest, out vertical, height), vertical, id, nextNode.id, parmKey));
            }

            LinkUpdate();
        }
Exemplo n.º 2
0
 override public int CheckLink(GKToyNode _selectNode, Vector2 mousePos, ref string paramKey)
 {
     // 禁止连接到虚拟入节点、禁止虚拟节点相连.
     if (GroupLinkType.LinkIn == linkType || NodeType.VirtualNode == _selectNode.nodeType)
     {
         return(0);
     }
     return(base.CheckLink(_selectNode, mousePos, ref paramKey));
 }
Exemplo n.º 3
0
        public void UpdateLinkWithNode(GKToyNode node, int height)
        {
            Link l = FindLinkFromNode(node.id);

            if (null != l)
            {
                UpdateLink(l, node, height);
            }
            if ((int)node.nodeType >= 10)
            {
                l = FindLinkFromOtherNode(node.id);
                if (null != l)
                {
                    UpdateLink(l, node, height);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 检测是否被连接
        /// </summary>
        /// <param name="_selectNode">连线起始节点</param>
        /// <param name="mousePos">mouse up的位置</param>
        /// <returns>0:未被连接,1:被连接,但不添加连接,2:添加链接</returns>
        virtual public int CheckLink(GKToyNode _selectNode, Vector2 mousePos, ref string paramKey)
        {
            if (id == _selectNode.id)
            {
                return(0);
            }
            if (inputRect.Contains(mousePos) || rect.Contains(mousePos))
            {
                if (10 > (int)nodeType && null != _selectNode.FindLinkFromNode(id))
                {
                    return(1);
                }
                if (10 <= (int)nodeType && null != _selectNode.FindLinkFromOtherNode(id))
                {
                    return(1);
                }
                return(2);
            }
            else if (null != parmRect)
            {
                // 检测是否为节点参数区域.
                var pr = parmRect.Values.ToArray();
                for (int i = 0; i < ioStates.Length; i++)
                {
                    // 当前输入节点未开放.
                    if ((ioStates[i] & 1) != 1)
                    {
                        continue;
                    }

                    // 输出输入参数相等.
                    if (null != _selectNode.outputObject && pr[i].propretyInfo.PropertyType.Name == _selectNode.outputObject.GetType().Name)
                    {
                        if (pr[i].rect.Contains(mousePos))
                        {
                            paramKey = pr[i].propretyInfo.Name;
                            return(2);
                        }
                    }
                }
            }
            return(0);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新单根连线
        /// </summary>
        /// <param name="linkId">要更新连线的Id</param>
        public void UpdateLink(Link link, GKToyNode nextNode, int height)
        {
            bool    vertical = false;
            Vector2 src      = new Vector2(outputRect.x + outputRect.width, outputRect.y + outputRect.height * 0.5f);
            Vector2 dest     = Vector2.zero;

            // 参数链接.
            if (!string.IsNullOrEmpty(link.parmKey) && nextNode.parmRect.ContainsKey(link.parmKey))
            {
                dest = new Vector2(nextNode.parmRect[link.parmKey].rect.x, nextNode.parmRect[link.parmKey].rect.y + nextNode.parmRect[link.parmKey].rect.height * 0.5f);
            }
            // 节点链接.
            else
            {
                dest = new Vector2(nextNode.inputRect.x, nextNode.inputRect.y + nextNode.inputRect.height * 0.5f);
            }
            link.points          = new List <Vector2>(GK.ClacLinePoint(src, dest, out vertical, height));
            link.isFirstVertical = vertical;
        }
Exemplo n.º 6
0
        public void RemoveLink(GKToyNode removeNode)
        {
            if (10 > (int)removeNode.nodeType)
            {
                Link link = FindLinkFromNode(removeNode.id);
                if (null != link)
                {
                    links.Remove(link);
                }
            }
            else
            {
                Link link = FindLinkFromOtherNode(removeNode.id);
                if (null != link)
                {
                    otherLinks.Remove(link);
                }
            }

            LinkUpdate();
        }
Exemplo n.º 7
0
 static public void SelectCom(GKToyNode node)
 {
 }