Ejemplo n.º 1
0
    public NodeDescription AddNode(int module_id, int node_id)
    {
        if (CurrentGraph == null || CurrentGraphNodes == null)
        {
            return(null);
        }

        GraphNode graph_node = CurrentGraph.AddNode(module_id, node_id);

        NodeDescription new_node = Instantiate(NodeObject);

        new_node.SetReferenceNode(graph_node);
        CurrentGraphNodes.Add(graph_node.guid, new_node);

        //Set location to middle of screen
        Vector3 position = Camera.main.transform.position + new Vector3(0, 2.0f, 0);

        position.z = 0;
        new_node.transform.position = position;

        return(new_node);
    }
Ejemplo n.º 2
0
    public void OpenGraph(string name)
    {
        if (CurrentGraph != null)
        {
            CloseGraph();
        }

        if (CurrentGraphNodes == null)
        {
            CurrentGraphNodes = new Dictionary <System.Guid, NodeDescription>();
        }


        CurrentGraph = VScriptEngine.OpenGraph(name);

        if (CurrentGraph == null)
        {
            return;
        }

        Vector2 desired_position = new Vector2();

        //Create all the nodes
        foreach (KeyValuePair <System.Guid, GraphNode> pair in CurrentGraph.nodes)
        {
            NodeDescription new_node = Instantiate(NodeObject);
            new_node.SetReferenceNode(pair.Value);
            CurrentGraphNodes.Add(pair.Key, new_node);

            //If start node
            if (pair.Value.module_id == 0 && pair.Value.node_id == 1)
            {
                desired_position = new_node.transform.position;
            }
        }
        GraphSheild.SetActive(false);
        Camera.main.transform.position = new Vector3(desired_position.x, desired_position.y - 2.0f, -8.26f);
    }