public Rect drawNode(QuestNode node, int r, int w)
    {
        int cHeight = 150;
        int x = (int)(r * nodeWidth * 1.3) + offsetX;
        yCol[r] += 25;
        int yInit = yCol[r] + offsetY;

        // Creates main node box with name at top
        GUI.Box(new Rect(x, yCol[r] + offsetY, nodeWidth, cHeight), node.getQuestID());
        yCol[r] += 25;

        // Creates the quest rename field below
        node.setQuestID(GUI.TextField(new Rect(x + 5, yCol[r] + offsetY, nodeWidth - 10, 20), node.getQuestID()));
        yCol[r] += 25;

        int selectedItemIndex = typeBoxes[node].GetSelectedItemIndex();
        int topBoxY = yCol[r] + offsetY;
        yCol[r] += 25;

        //Draw outcome nodes
        foreach (QuestNode n in node.getOutcomeNodes())
        {
            // draw child node -- maybe should just draw line to children (requires x,y info in node)?
            Rect childBox = drawNode(n, r + 1, nodeWidth);

            // draws line to child node
            GUIHelper.DrawLine(new Vector2(x + nodeWidth, (yCol[r]) + offsetY), new Vector2(childBox.x, childBox.y + childBox.height / 2), Color.black);

            // draws and activates the 'x' button for deletion
            if (GUI.Button(new Rect(childBox.x, childBox.y, 20, 20), "X"))
            {
                deleteNode(n);
                node.removeOutcomeNode(n);
            }
        }

        yCol[r] += 25;

        // outcome label
        GUI.Label(new Rect(x + 60, yCol[r] + offsetY + 5, 92, 20), "- Outcomes -");

        yCol[r] += 25;

        //Draw add node button
        if (GUI.Button(new Rect(x + 5, yCol[r] + offsetY, 92, 20), "New Child..."))
        {
            QuestNode newNode = new QuestNode("New Node " + max++, qNpcs[0], 0, 0);
            node.addOutcomeNode(newNode);
            currentQuest.addNode(newNode);

            typeBoxes.Add(newNode, new ComboBox());
            npcBoxes.Add(newNode, new ComboBox());
            locationBoxes.Add(newNode, new ComboBox());
        }

        // Draw 'Select Node' button
        if (GUI.Button(new Rect(x + 102, yCol[r] + offsetY, 92, 20), "Select Node..."))
        {
            Dictionary<string, QuestNode> qInventory = new Dictionary<string, QuestNode>();
            GetNodeList(first, qInventory);

            setupQuestCombos(qInventory);

            int selectedNode = selNode.List(
            new Rect(x + 102, yCol[r] +offsetY, 92, 20), "vvvvv", questComboBoxList, listStyle);
            Debug.Log("YOU REACHED ME!!!!	"+ selectedNode.ToString());

        }

        // NPC selected
        if (selectedItemIndex == 0)
        {
            int selectedNPC = npcBoxes[node].GetSelectedItemIndex();
            selectedNPC = npcBoxes[node].List(
            new Rect(x + 5, topBoxY + 25, nodeWidth - 10, 20), npcComboBoxList[selectedNPC].text, npcComboBoxList, listStyle);
            Debug.Log(selectedNPC);
        }
        // Object Selected
        else if (selectedItemIndex == 1)
        {

        }
        // Location Selected
        else
        {
            int selectedLoc = locationBoxes[node].GetSelectedItemIndex();
            selectedLoc = locationBoxes[node].List(
            new Rect(x + 5, topBoxY + 25, nodeWidth - 10, 20), locationComboBoxList[selectedLoc].text, locationComboBoxList, listStyle);
        }

        selectedItemIndex = typeBoxes[node].List(
            new Rect(x + 5, topBoxY, nodeWidth - 10, 20), typeComboBoxList[selectedItemIndex].text, typeComboBoxList, listStyle);

        yCol[r] += 30;
        return new Rect(x, yInit, nodeWidth, cHeight);
    }
Exemple #2
0
    public Rect drawNode(QuestNode node, int r, int w)
    {
        int cHeight = 150;
        int x       = (int)(r * nodeWidth * 1.3) + offsetX;

        yCol[r] += 25;
        int yInit = yCol[r] + offsetY;

        // Creates main node box with name at top
        GUI.Box(new Rect(x, yCol[r] + offsetY, nodeWidth, cHeight), node.getQuestID());
        yCol[r] += 25;

        // Creates the quest rename field below
        node.setQuestID(GUI.TextField(new Rect(x + 5, yCol[r] + offsetY, nodeWidth - 10, 20), node.getQuestID()));
        yCol[r] += 25;

        int selectedItemIndex = typeBoxes[node].GetSelectedItemIndex();
        int topBoxY           = yCol[r] + offsetY;

        yCol[r] += 25;

        //Draw outcome nodes
        foreach (QuestNode n in node.getOutcomeNodes())
        {
            // draw child node -- maybe should just draw line to children (requires x,y info in node)?
            Rect childBox = drawNode(n, r + 1, nodeWidth);

            // draws line to child node
            GUIHelper.DrawLine(new Vector2(x + nodeWidth, (yCol[r]) + offsetY), new Vector2(childBox.x, childBox.y + childBox.height / 2), Color.black);

            // draws and activates the 'x' button for deletion
            if (GUI.Button(new Rect(childBox.x, childBox.y, 20, 20), "X"))
            {
                deleteNode(n);
                node.removeOutcomeNode(n);
            }
        }

        yCol[r] += 25;

        // outcome label
        GUI.Label(new Rect(x + 60, yCol[r] + offsetY + 5, 92, 20), "- Outcomes -");

        yCol[r] += 25;


        //Draw add node button
        if (GUI.Button(new Rect(x + 5, yCol[r] + offsetY, 92, 20), "New Child..."))
        {
            QuestNode newNode = new QuestNode("New Node " + max++, qNpcs[0], 0, 0);
            node.addOutcomeNode(newNode);
            currentQuest.addNode(newNode);


            typeBoxes.Add(newNode, new ComboBox());
            npcBoxes.Add(newNode, new ComboBox());
            locationBoxes.Add(newNode, new ComboBox());
        }

        // Draw 'Select Node' button
        if (GUI.Button(new Rect(x + 102, yCol[r] + offsetY, 92, 20), "Select Node..."))
        {
            Dictionary <string, QuestNode> qInventory = new Dictionary <string, QuestNode>();
            GetNodeList(first, qInventory);

            setupQuestCombos(qInventory);

            int selectedNode = selNode.List(
                new Rect(x + 102, yCol[r] + offsetY, 92, 20), "vvvvv", questComboBoxList, listStyle);
            Debug.Log("YOU REACHED ME!!!!	"+ selectedNode.ToString());
        }

        // NPC selected
        if (selectedItemIndex == 0)
        {
            int selectedNPC = npcBoxes[node].GetSelectedItemIndex();
            selectedNPC = npcBoxes[node].List(
                new Rect(x + 5, topBoxY + 25, nodeWidth - 10, 20), npcComboBoxList[selectedNPC].text, npcComboBoxList, listStyle);
            Debug.Log(selectedNPC);
        }
        // Object Selected
        else if (selectedItemIndex == 1)
        {
        }
        // Location Selected
        else
        {
            int selectedLoc = locationBoxes[node].GetSelectedItemIndex();
            selectedLoc = locationBoxes[node].List(
                new Rect(x + 5, topBoxY + 25, nodeWidth - 10, 20), locationComboBoxList[selectedLoc].text, locationComboBoxList, listStyle);
        }

        selectedItemIndex = typeBoxes[node].List(
            new Rect(x + 5, topBoxY, nodeWidth - 10, 20), typeComboBoxList[selectedItemIndex].text, typeComboBoxList, listStyle);

        yCol[r] += 30;
        return(new Rect(x, yInit, nodeWidth, cHeight));
    }