Exemple #1
0
    private void OnEnable()
    {
        td_target = (TopDownRpgQuest)target;

        if (TopDownIcon == null)
        {
            TopDownIcon = Resources.Load("TopDownIcon") as Texture;
        }
    }
Exemple #2
0
    /// <summary>
    /// Used to add new dialog choices.
    /// </summary>
    /// <param name="dialog">Dialog that we are adding choice to.</param>
    /// <param name="choiceText">Text in the choice button.</param>
    /// <param name="dialogText">Text in the dialog box when choice is activated.</param>
    /// <param name="dialogChoiceType">What type of dialog choice this is?</param>
    /// <param name="choicePosition">Position of choice in the choices list. It can be at Top or at Bottom. If there is four choices already if on Top the last one will be removed and if on Bottom the first one will be removed.</param>
    public void AddNewChoice(TopDownRpgQuest quest, TopDownUIDialog dialog, string choiceText, string dialogText, DialogType dialogChoiceType, ChoicePosition choicePosition)
    {
        if (choicePosition == ChoicePosition.Top)
        {
            for (int i = dialog.numberOfChoices; i > 0; i--)
            {
                if (i == 4)
                {
                    dialog.choiceFour         = dialog.choiceThree;
                    dialog.choiceFourDialog   = dialog.choiceThreeDialog;
                    dialog.choiceFourType     = dialog.choiceThreeType;
                    dialog.removeOnChoiceFour = dialog.removeOnChoiceThree;
                    dialog.branchFourDialog   = dialog.branchThreeDialog;
                    dialog.typeFourResponse   = dialog.typeThreeResponse;
                    dialog.choiceFourEvent    = dialog.choiceThreeEvent;
                }
                if (i == 3)
                {
                    dialog.choiceThree         = dialog.choiceTwo;
                    dialog.choiceThreeDialog   = dialog.choiceTwoDialog;
                    dialog.choiceThreeType     = dialog.choiceTwoType;
                    dialog.removeOnChoiceThree = dialog.removeOnChoiceTwo;
                    dialog.branchThreeDialog   = dialog.branchTwoDialog;
                    dialog.typeThreeResponse   = dialog.typeTwoResponse;
                    dialog.choiceThreeEvent    = dialog.choiceTwoEvent;
                }
                if (i == 2)
                {
                    dialog.choiceTwo         = dialog.choiceOne;
                    dialog.choiceTwoDialog   = dialog.choiceOneDialog;
                    dialog.choiceTwoType     = dialog.choiceOneType;
                    dialog.removeOnChoiceTwo = dialog.removeOnChoiceOne;
                    dialog.branchTwoDialog   = dialog.branchOneDialog;
                    dialog.typeTwoResponse   = dialog.typeOneResponse;
                    dialog.choiceTwoEvent    = dialog.choiceOneEvent;
                }
                if (i == 1)
                {
                    dialog.choiceOne         = choiceText;
                    dialog.choiceOneDialog   = dialogText;
                    dialog.choiceOneType     = dialogChoiceType;
                    dialog.removeOnChoiceOne = true;
                    dialog.branchOneDialog   = null;
                    dialog.typeOneResponse   = string.Empty;
                    dialog.choiceOneEvent    = null;
                    if (quest == null)
                    {
                        print("No quest");
                    }
                    dialog.choiceOneEvent = quest.questFinishEvents;
                }
            }

            return;
        }
    }
    void OnGUI()
    {
        GUIStyle boldCenteredLabel = new GUIStyle(EditorStyles.boldLabel)
        {
            alignment = TextAnchor.MiddleCenter
        };

        EditorStyles.textField.wordWrap = true;

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));
        EditorGUILayout.LabelField(new GUIContent(TopDownIcon), boldCenteredLabel, GUILayout.ExpandWidth(true), GUILayout.Height(32));
        EditorGUILayout.LabelField("- TOP DOWN RPG -", boldCenteredLabel);
        EditorGUILayout.LabelField("Setup New Quest", boldCenteredLabel);
        EditorGUILayout.HelpBox("This is used to setup new quest.", MessageType.Info);
        EditorGUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));

        questName     = EditorGUILayout.TextField("Quest Title:", questName);
        questCategory = EditorGUILayout.TextField("Quest Category:", questCategory);
        EditorGUILayout.HelpBox("This is the name of the Quest that will show up in the questlog and the quest category name under which it will be sorted.", MessageType.Info);

        EditorGUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));

        questType = (QuestType)EditorGUILayout.EnumPopup("Quest Type:", questType);
        EditorGUILayout.HelpBox("What kind of quest this is. This basicly sets its main objective.", MessageType.Info);

        questDescription = EditorGUILayout.TextField("Quest Description:", questDescription, GUILayout.MaxHeight(75));

        EditorGUILayout.HelpBox("Here you can describe what player needs to do to complete this quest.", MessageType.Info);

        EditorGUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        if (questType == QuestType.KillTargets)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));

            ScriptableObject   target          = this;
            SerializedObject   so              = new SerializedObject(target);
            SerializedProperty stringsProperty = so.FindProperty("questTargets");

            EditorGUILayout.PropertyField(stringsProperty, true);
            so.ApplyModifiedProperties();

            EditorGUILayout.HelpBox("Here we will set our quests objective.", MessageType.Info);

            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
        else
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));

            questTarget = (GameObject)EditorGUILayout.ObjectField("Quest Objective:", questTarget, typeof(GameObject), true);
            EditorGUILayout.HelpBox("Here we will set our quests objective.", MessageType.Info);

            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));

        questEnding = (QuestEnding)EditorGUILayout.EnumPopup("Quest Ending:", questEnding);
        EditorGUILayout.HelpBox("Determines in what manner the quest will finish.", MessageType.Info);

        EditorGUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        if (questEnding == QuestEnding.ReturnToNpc)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));

            questGiver = (GameObject)EditorGUILayout.ObjectField("Quest Giver:", questGiver, typeof(GameObject), true);
            EditorGUILayout.HelpBox("Here we set npc with TopDownRpgDialog.cs to whom we will end this quest.", MessageType.Info);

            questFinishDialogChoice = EditorGUILayout.TextField("Finish Quest Dialog Choice:", questFinishDialogChoice);
            EditorGUILayout.HelpBox("If quest is started by NPC, this choice will be visible in his dialog menu when quest is done.", MessageType.Info);

            questFinishDialogReply = EditorGUILayout.TextField("Finish Quest Dialog Reply:", questFinishDialogReply, GUILayout.MinHeight(90));
            EditorGUILayout.HelpBox("This will be the reply the npc will give us when the above choice is activated.", MessageType.Info);

            questFinishDialogType = (DialogType)EditorGUILayout.EnumPopup("Dialog Choice Type:", questFinishDialogType);
            EditorGUILayout.HelpBox("Determines what will happen when finish dialog choice is chosen in conversation.", MessageType.Info);

            SerializedObject serializedObject = new SerializedObject(this);
            serializedObject.Update();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("questFinishDialogEvent"), true);
            EditorGUILayout.HelpBox("This will be the reply the npc will give us when the above choice is activated.", MessageType.Info);
            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginVertical("Box", GUILayout.Width(90 * Screen.width / 100));

        if (GUILayout.Button("Create Quest"))
        {
            GameObject questGo = new GameObject();
            questGo.name = "Quest - " + questName;

            Transform questHub = GameObject.FindObjectOfType <TopDownRpgQuestHub>().transform;
            questGo.transform.SetParent(questHub.transform.Find("TD_Quests").transform);

            TopDownRpgQuest quest = questGo.AddComponent <TopDownRpgQuest>();
            quest.questName        = questName;
            quest.questDescription = questDescription;
            quest.questType        = questType;
            quest.questTarget      = questTarget;
            quest.questTargets     = questTargets;
            quest.questEnding      = questEnding;
            if (questGiver != null)
            {
                quest.questGiverDialog = questGiver.GetComponent <TopDownUIDialog>();
            }
            quest.questFinishDialogType = questFinishDialogType;
            quest.questFinishChoice     = questFinishDialogChoice;
            quest.questFinishDialog     = questFinishDialogReply;
            quest.questFinishEvents     = questFinishDialogEvent;

            Debug.Log("Quest named '" + questName + "' added to scene.");
        }

        EditorGUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
    }