예제 #1
0
 private void OnClickPoint()
 {
     if (m_SelectedOutPoint != null && m_SelectedInPoint != null)
     {
         if (m_SelectedOutPoint.GetNode() != m_SelectedInPoint.GetNode())
         {
             CreateConnection();
             ClearConnectionSelection();
         }
         else
         {
             ClearConnectionSelection();
         }
     }
 }
예제 #2
0
    protected virtual void Load()
    {
        string savePath = OpenFileDialogue();

        if (savePath == "")
        {
            return;
        }
        Graph <NodeType, ConnectionType> graphDeserialized = XMLSerializerHelper.Deserialize <Graph <NodeType, ConnectionType> >(savePath);

        m_Graph.m_Nodes       = new List <NodeType>();
        m_Graph.m_Connections = new List <ConnectionType>();

        foreach (var nodeDeserialized in graphDeserialized.m_Nodes)
        {
            m_Graph.m_Nodes.Add(GetAsFinalType().DeserializeNode(nodeDeserialized));
        }

        foreach (var connectionDeserialized in graphDeserialized.m_Connections)
        {
            ConnectionPoint outPoint = null;
            foreach (Node n in m_Graph.m_Nodes)
            {
                outPoint = n.GetConnectionPoint(connectionDeserialized.m_OutPoint.m_Id);
                if (outPoint != null)
                {
                    break;
                }
            }
            ConnectionPoint inPoint = null;
            foreach (Node n in m_Graph.m_Nodes)
            {
                inPoint = n.GetConnectionPoint(connectionDeserialized.m_InPoint.m_Id);
                if (inPoint != null)
                {
                    break;
                }
            }
            Connection     connectionBase = new Connection(inPoint, outPoint, OnClickRemoveConnection);
            ConnectionType connection     = GetAsFinalType().CreateConnection(connectionBase);
            m_Graph.m_Connections.Add(connection);
            inPoint.OnConnectionMade(connection);
            outPoint.OnConnectionMade(connection);
            outPoint.GetNode().OnConnectionMade(connection);
            inPoint.GetNode().OnConnectionMade(connection);
        }
    }