Exemplo n.º 1
0
    public void SetType(OCNodeType val, bool force)
    {
        if (val != type || force)
        {
            type = val;

            Reset();

            switch (type)
            {
            case OCNodeType.Speak:
                speak = new OCSpeak();
                SetOutputAmount(1);
                break;

            case OCNodeType.Event:
                evt = new OCEvent();
                SetOutputAmount(1);
                break;

            case OCNodeType.Jump:
                jump = new OCJump();
                SetOutputAmount(0);
                break;

            case OCNodeType.SetFlag:
                setFlag = new OCSetFlag();
                SetOutputAmount(1);
                break;

            case OCNodeType.GetFlag:
                getFlag = new OCGetFlag();
                SetOutputAmount(2);
                break;

            case OCNodeType.SetQuest:
                setQuest = new OCSetQuest();
                SetOutputAmount(1);
                break;

            case OCNodeType.GetQuest:
                getQuest = new OCGetQuest();
                SetOutputAmount(2);
                break;

            case OCNodeType.End:
                end = new OCEnd();
                SetOutputAmount(0);
                break;
            }
        }
    }
Exemplo n.º 2
0
    public void SetType(string str)
    {
        int type = 0;

        string[] names = System.Enum.GetNames(typeof(OCNodeType));

        for (int i = 0; i < names.Length; i++)
        {
            if (names[i] == str)
            {
                type = i;
            }
        }

        SetType((OCNodeType)type);
    }
Exemplo n.º 3
0
    private void DrawInspector()
    {
        int i = 0;

        string[]   questNames     = new string[0];
        string[]   objectiveNames = new string[0];
        OCNodeType type           = (OCNodeType)EditorGUILayout.Popup("Type", (int)node.type, System.Enum.GetNames(typeof(OCNodeType)));

        if (type != node.type)
        {
            node.SetType(type);
        }

        GUILayout.Space(20);

        switch (node.type)
        {
        case OCNodeType.Speak:
            GUI.backgroundColor = speakerColors [node.speak.speaker];
            node.speak.speaker  = EditorGUILayout.Popup("Speaker", node.speak.speaker, target.speakers);
            GUI.backgroundColor = Color.white;

            node.speak.smalltalk = EditorGUILayout.Toggle("Smalltalk", node.speak.smalltalk);

            GUILayout.Space(10);

            for (i = 0; i < node.speak.lines.Length; i++)
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label(i.ToString());

                GUI.color = Color.red;
                if (node.speak.lines.Length > 1 && GUILayout.Button("x", GUILayout.Height(16), GUILayout.Width(32)))
                {
                    node.speak.RemoveLine(i);
                    return;
                }
                GUI.color = Color.white;

                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                OCSpeak.Line line = node.speak.lines [i];

                line.text           = EditorGUILayout.TextArea(line.text, GUILayout.Height(80), GUILayout.Width(250));
                line.audio          = (AudioClip)EditorGUILayout.ObjectField("Audio", line.audio, typeof(AudioClip), false);
                GUI.backgroundColor = speakerColors [line.facing];
                line.facing         = EditorGUILayout.Popup("Facing", line.facing, target.speakers);
                GUI.backgroundColor = Color.white;
                GUILayout.Space(20);
            }

            GUI.color = Color.green;
            if (GUILayout.Button("+", GUILayout.Height(16), GUILayout.Width(32)))
            {
                node.speak.AddLine();
            }
            GUI.color = Color.white;

            if (node.speak.smalltalk)
            {
                node.SetOutputAmount(1);
            }
            else if (node.connectedTo.Length != node.speak.lines.Length)
            {
                node.SetOutputAmount(node.speak.lines.Length);
            }

            break;

        case OCNodeType.Event:
            node.evt.message       = EditorGUILayout.TextField("Message", node.evt.message);
            node.evt.argument      = EditorGUILayout.TextField("Argument", node.evt.argument);
            node.evt.obj           = (GameObject)EditorGUILayout.ObjectField("Target object", node.evt.obj, typeof(GameObject), true);
            node.evt.eventToTarget = EditorGUILayout.Toggle("Event to target", node.evt.eventToTarget);

            break;

        case OCNodeType.Jump:
            node.jump.rootNode = EditorGUILayout.Popup("To root node", node.jump.rootNode, target.rootNodeStrings);

            break;

        case OCNodeType.End:
            node.end.rootNode = EditorGUILayout.Popup("Next root node", node.end.rootNode, target.rootNodeStrings);

            break;

        case OCNodeType.SetFlag:
            node.setFlag.flag = EditorGUILayout.TextField("Flag", node.setFlag.flag);
            node.setFlag.b    = EditorGUILayout.Toggle("Bool", node.setFlag.b);

            break;

        case OCNodeType.GetFlag:
            node.getFlag.flag = EditorGUILayout.TextField("Flag", node.getFlag.flag);

            break;

        case OCNodeType.SetQuest:
            if (!manager)
            {
                manager = (OCManager)EditorGUILayout.ObjectField("Select OCManager object", manager, typeof(OCManager), true);
            }
            else
            {
                questNames = manager.quests.GetQuestNames();

                if (questNames.Length > 0)
                {
                    node.setQuest.quest = questNames [EditorGUILayout.Popup("Quest", manager.quests.GetIndex(node.setQuest.quest), questNames)];
                    objectiveNames      = manager.quests.GetObjectiveNames(node.setQuest.quest);

                    if (objectiveNames.Length > 0)
                    {
                        node.setQuest.objective = EditorGUILayout.Popup("Objective", node.setQuest.objective, objectiveNames);
                    }
                    else
                    {
                        GUILayout.Label("Objective");
                    }

                    node.setQuest.completed = EditorGUILayout.Toggle("Completed", node.setQuest.completed);
                }
                else
                {
                    GUILayout.Label("No potential quests in OCManager!");
                }
            }

            break;

        case OCNodeType.GetQuest:
            if (!manager)
            {
                manager = (OCManager)EditorGUILayout.ObjectField("Select OCManager object", manager, typeof(OCManager), true);
            }
            else
            {
                questNames = manager.quests.GetQuestNames();

                if (questNames.Length > 0)
                {
                    node.getQuest.quest = questNames [EditorGUILayout.Popup("Quest", manager.quests.GetIndex(node.getQuest.quest), questNames)];
                    objectiveNames      = manager.quests.GetObjectiveNames(node.getQuest.quest);

                    if (objectiveNames.Length > 0)
                    {
                        node.getQuest.objective = EditorGUILayout.Popup("Objective", node.getQuest.objective, objectiveNames);
                    }
                    else
                    {
                        GUILayout.Label("Objective");
                    }

                    node.getQuest.completed = EditorGUILayout.Toggle("Completed", node.getQuest.completed);
                }
                else
                {
                    GUILayout.Label("No potential quests in OCManager!");
                }
            }

            break;
        }
    }
Exemplo n.º 4
0
 public void SetType(OCNodeType val)
 {
     SetType(val, false);
 }