コード例 #1
0
    // 断开当前的线,并握住这根线的这一头
    public void ChangeLink(LinkNodeData node)
    {
        OperatorLink input_node, output_node;
        int          input_idx;
        GameObject   input_anchor, output_anchor;

        GetLinkData(node, out input_node, out input_idx, out output_node);
        output_node.RemoveOutputLink(input_node, input_idx);
        input_node.RemoveInputLink(input_idx);
        LinkLine line = RemoveLinkLine(input_node, input_idx, output_node);

        m_curLine = line;

        if (node.isInput)
        {
            output_anchor = output_node.FindOutputAnchor();
            line.SetNode(output_anchor, null);
            m_matchingObj = new LinkNodeData(output_node, output_anchor, false, -1, -1);
        }
        else
        {
            input_anchor = input_node.FindInputAnchor(input_idx);
            line.SetNode(null, input_anchor);
            m_matchingObj = new LinkNodeData(input_node, input_anchor, true, input_idx, -1);
        }

        OnLinkChange();
    }
コード例 #2
0
 // 创建一条线
 public void StartMatch(LinkNodeData src)
 {
     m_matchingObj = src;
     m_curLine     = CreateLine();
     if (src.isInput)
     {
         m_curLine.SetNode(null, src.anchorObj);
     }
     else
     {
         m_curLine.SetNode(src.anchorObj, null);
     }
 }
コード例 #3
0
    // 决定当前的线
    public void SettleMatch(LinkNodeData dst)
    {
        if (!CanMatch(dst))
        {
            return;
        }

        OperatorLink input_node    = (dst.isInput ? dst : m_matchingObj).obj;
        OperatorLink output_node   = (!dst.isInput ? dst : m_matchingObj).obj;
        GameObject   input_anchor  = (dst.isInput ? dst : m_matchingObj).anchorObj;
        GameObject   output_anchor = (!dst.isInput ? dst : m_matchingObj).anchorObj;
        int          input_idx     = dst.isInput ? dst.inputIdx : m_matchingObj.inputIdx;

        input_node.AddInputLink(output_node, input_idx);
        output_node.AddOutputLink(input_node, input_idx);

        m_links.Add(new LinkData(m_curLine, input_node, input_idx, output_node));
        m_curLine.SetNode(output_anchor, input_anchor);

        m_matchingObj = null;
        m_curLine     = null;

        OnLinkChange();
    }