Esempio n. 1
0
 private void DeleteConversation(ConversationData conversationData)
 {
     if (DataMart.CheckConversationDataBase(conversationData.ID))
     {
         DataMart.RemoveConversation(conversationData.ID);
     }
     DestroyAllChildUIElements();
 }
Esempio n. 2
0
    public void LoadConversation(int id)
    {
        if (DataMart.CheckConversationDataBase(id))
        {
            ConversationData data = DataMart.GetConversation(id);

            RefreshConversationUI(data);
        }
        else
        {
            Debug.LogError("Load Error: No conversation with that ID");
        }
    }
Esempio n. 3
0
    public void SaveConversation(ConversationData conversationData)
    {
        //Exit if no steps
        if (StepContainer.childCount <= 0)
        {
            return;
        }

        //Get Conversations NPCID
        conversationData.NPCID = int.Parse(NPCID.text);

        for (int stepObjectID = 0; stepObjectID < StepContainer.childCount; stepObjectID++)
        {
            //Step Data (for easy reference)
            StepData stepData = conversationData.StepData[stepObjectID];

            //Get Step Text
            conversationData.StepData[stepObjectID].Text = StepContainer.GetChild(stepObjectID).GetChild(2).GetComponent <TMP_InputField>().text;

            //Option Container
            Transform optionContainer = StepContainer.GetChild(stepObjectID).GetChild(3).GetChild(0).GetChild(0).transform;

            for (int option = 0; option < optionContainer.childCount; option++)
            {
                //Option Data (for easy reference)
                OptionData optionData = stepData.OptionData[option];

                //Get Option ID
                optionData.DestinationID = int.Parse(optionContainer.GetChild(option).GetChild(5).GetComponent <TMP_InputField>().text);

                //Get Option Text
                optionData.Text = optionContainer.GetChild(option).GetChild(4).GetComponent <TMP_InputField>().text;

                //Get Option Trigger
                if (optionContainer.GetChild(option).GetChild(0).GetComponent <TMP_Dropdown>().value == 0)
                {
                    //Acceptance Trigger
                    optionData.Trigger = OptionTrigger.QuestAcceptance;
                }
                else if (optionContainer.GetChild(option).GetChild(0).GetComponent <TMP_Dropdown>().value == 1)
                {
                    //Reward Trigger
                    optionData.Trigger = OptionTrigger.ObtainQuestReward;
                }
                else if (optionContainer.GetChild(option).GetChild(0).GetComponent <TMP_Dropdown>().value == 2)
                {
                    //No Trigger
                    optionData.Trigger = OptionTrigger.None;
                }

                //Get Option Value
                if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 0)
                {
                    //Value 1
                    optionData.ValueCheck       = CompanyValue.ValueOne;
                    optionData.ValueCheckAmount = int.Parse(optionContainer.GetChild(option).GetChild(6).GetComponent <TMP_InputField>().text);
                }
                else if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 1)
                {
                    //Value 2
                    optionData.ValueCheck       = CompanyValue.ValueTwo;
                    optionData.ValueCheckAmount = int.Parse(optionContainer.GetChild(option).GetChild(6).GetComponent <TMP_InputField>().text);
                }
                else if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 2)
                {
                    //Value 3
                    optionData.ValueCheck       = CompanyValue.ValueThree;
                    optionData.ValueCheckAmount = int.Parse(optionContainer.GetChild(option).GetChild(6).GetComponent <TMP_InputField>().text);
                }
                else if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 3)
                {
                    //No Value
                    optionData.ValueCheck       = CompanyValue.NULL;
                    optionData.ValueCheckAmount = -1;
                }
            }
        }

        if (DataMart.CheckConversationDataBase(conversationData.ID))
        {
            DataMart.RemoveConversation(conversationData.ID);
        }
        DataMart.AddConversation(conversationData);
        SaveButton.GetComponent <Image>().color = Color.green;
    }