Exemple #1
0
        public static void BuildConversationDataBase()
        {
            DataMart.ClearConversationDatabase();

            //Orc Farmer Conversation
            ConversationData conversation = new ConversationData();

            conversation.NPCID = 1;
            conversation.ID    = 1000;
            StepData step = new StepData();

            step.Text = "Hey can you do something for me?";
            OptionData option = new OptionData();

            option.ValueCheck    = CompanyValue.ValueOne;
            option.DestinationID = 1;
            option.Trigger       = OptionTrigger.QuestAcceptance;
            option.Text          = "Sure OK.";
            step.OptionData[0]   = option;
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.None;
            option.DestinationID = 2;
            option.Text          = "No.";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            step                 = new StepData();
            step.Text            = "If you get me a <color=#0EA1FD>Five of Clubs Card</color> I'll <color=#C2C34D>Reward</color> you.";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.None;
            option.DestinationID = -1;
            option.Text          = "End Conversation";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            step                 = new StepData();
            step.Text            = "Leave me be then beggar.";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.None;
            option.DestinationID = -1;
            option.Text          = "End Conversation";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);


            DataMart.AddConversation(conversation);

            //Orc Farmer #2 Conversation
            conversation       = new ConversationData();
            conversation.NPCID = 1;
            conversation.ID    = 1001;
            step                 = new StepData();
            step.Text            = "Wow you got it! Here take this <color=#0EA1FD>Ace Card</color>";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.DestinationID = 1;
            option.Text          = "Thankyou! Ah..What does it do?";
            option.Trigger       = OptionTrigger.None;
            step.OptionData[0]   = option;
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.None;
            option.DestinationID = 2;
            option.Text          = "Hmm another card..";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            step                 = new StepData();
            step.Text            = "I dont know.";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.ObtainQuestReward;
            option.DestinationID = -1;
            option.Text          = "End Conversation";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            step                 = new StepData();
            step.Text            = "Never pleased are you? well don't take it then.";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.None;
            option.DestinationID = -1;
            option.Text          = "End Conversation";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            DataMart.AddConversation(conversation);

            //Orc Farmer #3 Conversation
            conversation       = new ConversationData();
            conversation.NPCID = 1;
            conversation.ID    = 1002;
            step                 = new StepData();
            step.Text            = "I gave you everything already.";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.DestinationID = -1;
            option.Text          = "End Conversation";
            option.Trigger       = OptionTrigger.None;
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            DataMart.AddConversation(conversation);

            //Orc Farmer #4
            conversation       = new ConversationData();
            conversation.NPCID = 1;
            conversation.ID    = 1003;
            step                 = new StepData();
            step.Text            = "Come on, go get me what I want.";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.DestinationID = -1;
            option.Text          = "End Conversation";
            option.Trigger       = OptionTrigger.None;
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            DataMart.AddConversation(conversation);

            //Lil Mushy Conversation
            conversation       = new ConversationData();
            conversation.NPCID = 2;
            conversation.ID    = 2000;
            step                 = new StepData();
            step.Text            = "So..Another idiot that goes around trying to talk to mushrooms..Are you stupid?";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.None;
            option.DestinationID = 1;
            option.Text          = "Ah..No!";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            step                 = new StepData();
            step.Text            = "OMG...You don't even blink at the fact I answered back...you are stupid!";
            option               = new OptionData();
            option.ValueCheck    = CompanyValue.NULL;
            option.Trigger       = OptionTrigger.None;
            option.DestinationID = -1;
            option.Text          = "End Conversation";
            step.OptionData.Add(option);
            conversation.StepData.Add(step);

            DataMart.AddConversation(conversation);
        }
    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;
    }