Exemplo n.º 1
0
    private void DrawConditionalNode(Node node, GUIStyle style)
    {
        Rect nodeRect = new Rect(node.m_position.x, node.m_position.y, node.m_dimension.x, node.m_dimension.y);

        // draw plugs on specific node
        DrawPlug(node.m_inputPlug, nodeRect, m_inputPlugStyle, 1, 1);
        Plug trueOutput  = node.GetOutputPlugAtIndex(0);
        Plug falseOutput = node.GetOutputPlugAtIndex(1);

        DrawConditionalOutPlug(trueOutput, nodeRect, m_outputTruePlugStyle, 1, node.m_outputPlugs.Count);
        DrawConditionalOutPlug(falseOutput, nodeRect, m_outputFalsePlugStyle, 2, node.m_outputPlugs.Count);

        // drawing the node itself with the contents in it
        GUI.Box(nodeRect, "", style);
        float padding         = 7f;
        Rect  nodeContentRect = new Rect(node.m_position.x + padding, node.m_position.y + padding, node.m_dimension.x - (2 * padding), node.m_dimension.y - (2 * padding));

        BeginArea(nodeContentRect);
        DialogueData data = m_nodeGraphModel.GetDataFromNodeID(node.m_id);

        if (data != null)
        {
            var rightAlign = new GUIStyle(GUI.skin.label)
            {
                alignment = TextAnchor.UpperRight
            };
            Label("Conditional", EditorStyles.boldLabel);
            Label("True", rightAlign);
            Label("");
            string tag_pattern = "<[^>]+>";
            string displayText = Regex.Replace(data.dialogueText, tag_pattern, "");
            Label("False", rightAlign);

            List <string> errors = m_nodeGraphModel.GetErrorMesssages(node.m_id);
            if (errors.Count > 0)
            {
                GUIStyle error_label = new GUIStyle();
                error_label.fontStyle        = FontStyle.Bold;
                error_label.normal.textColor = new Color(171f / 255f, 19f / 255f, 0);
                Label("Errors!!", error_label);
            }
        }

        OutputPlugToNode outputdata = m_nodeGraphModel.GetOutputPlugToNode(node.m_id, 0);

        if (outputdata != null)
        {
            DialogueData inputNodeData = m_nodeGraphModel.GetDataFromNodeID(outputdata.inputNodeID);
            inputNodeData.branchingIndex = 1;
        }
        outputdata = m_nodeGraphModel.GetOutputPlugToNode(node.m_id, 1);
        if (outputdata != null)
        {
            DialogueData inputNodeData = m_nodeGraphModel.GetDataFromNodeID(outputdata.inputNodeID);
            inputNodeData.branchingIndex = 0;
        }

        EndArea();
    }
Exemplo n.º 2
0
    public OutputPlugToNode GetOutputPlugToNode(int node_id, int plug_index)
    {
        OutputPlugToNode result  = new OutputPlugToNode();
        Node             node    = GetNodeFromID(node_id);
        Plug             outPlug = node.GetOutputPlugAtIndex(plug_index);

        foreach (KeyValuePair <int, Connection> connection_pair in GetConnections())
        {
            Connection connection = connection_pair.Value;
            if (connection.m_outputNodeId == node_id && connection.m_outputPlugId == outPlug.m_plugId)
            {
                // adding branching indices
                result.inputNodeID  = connection.m_inputNodeId;
                result.outputNodeID = connection.m_outputNodeId;
                result.outputPlugID = connection.m_outputPlugId;

                return(result);
            }
        }

        return(null);
    }
Exemplo n.º 3
0
    private void DrawStartNode(Node node, GUIStyle style)
    {
        if (node.isConditionalNode)
        {
            Rect nodeRect = new Rect(node.m_position.x, node.m_position.y, node.m_dimension.x - 50, node.m_dimension.y);

            // draw plugs on specific node
            Plug trueOutput  = node.GetOutputPlugAtIndex(0);
            Plug falseOutput = node.GetOutputPlugAtIndex(1);

            DrawConditionalOutPlug(trueOutput, nodeRect, m_outputTruePlugStyle, 1, node.m_outputPlugs.Count);
            DrawConditionalOutPlug(falseOutput, nodeRect, m_outputFalsePlugStyle, 2, node.m_outputPlugs.Count);

            // drawing the node itself with the contents in it
            GUI.Box(nodeRect, "", style);
            float padding         = 7f;
            Rect  nodeContentRect = new Rect(node.m_position.x + padding, node.m_position.y + padding, node.m_dimension.x - (2 * padding), node.m_dimension.y - (2 * padding));
            BeginArea(nodeContentRect);
            DialogueData data = m_nodeGraphModel.GetDataFromNodeID(node.m_id);
            if (data != null)
            {
                var rightAlign = new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.UpperRight
                };
                Label("Conditional Start", EditorStyles.boldLabel);
                Label("True", rightAlign);
                Label("");
                Label("False", rightAlign);
            }

            OutputPlugToNode outputdata = m_nodeGraphModel.GetOutputPlugToNode(node.m_id, 0);
            if (outputdata != null)
            {
                DialogueData inputNodeData = m_nodeGraphModel.GetDataFromNodeID(outputdata.inputNodeID);
                inputNodeData.branchingIndex = 1;
            }
            outputdata = m_nodeGraphModel.GetOutputPlugToNode(node.m_id, 1);
            if (outputdata != null)
            {
                DialogueData inputNodeData = m_nodeGraphModel.GetDataFromNodeID(outputdata.inputNodeID);
                inputNodeData.branchingIndex = 0;
            }
        }
        else
        {
            Rect nodeRect = new Rect(node.m_position.x, node.m_position.y, node.m_dimension.x - 50, node.m_dimension.y);

            // draw plugs on specific node
            int plug_count = 1;
            foreach (KeyValuePair <int, Plug> output_plug in node.m_outputPlugs)
            {
                DrawPlug(output_plug.Value, nodeRect, m_outputPlugStyle, plug_count, node.m_outputPlugs.Count);
                ++plug_count;
            }

            // drawing the node itself with the contents in it
            GUI.Box(nodeRect, "", style);
            float padding         = 7f;
            Rect  nodeContentRect = new Rect(node.m_position.x + padding, node.m_position.y + padding, node.m_dimension.x - (2 * padding), node.m_dimension.y - (2 * padding));
            BeginArea(nodeContentRect);
            List <string> errors = m_nodeGraphModel.GetErrorMesssages(node.m_id);
            Label("Start Node", EditorStyles.boldLabel);
            if (errors.Count > 0)
            {
                GUIStyle error_label = new GUIStyle();
                error_label.fontStyle        = FontStyle.Bold;
                error_label.normal.textColor = new Color(171f / 255f, 19f / 255f, 0);
                Label("Errors!!", error_label);
            }
            EndArea();
        }
    }