Example #1
0
 public CDialog(string Holder, string Title, string Text, int QuestDialog, CDialogPrecondition Precondition, Actions Actions, ListOfQuests Nodes, int DialogID, int version)
 {
     this.Holder       = Holder;
     this.Title        = Title;
     this.Text         = Text;
     this.QuestDialog  = QuestDialog;
     this.Precondition = Precondition;
     this.Actions      = Actions;
     this.Nodes        = Nodes;
     this.DialogID     = DialogID;
     this.version      = version;
 }
Example #2
0
 public CDialog()
 {
     //this.Holder = new List<string>();
     this.Holder       = "";
     this.Title        = "";
     this.Text         = "";
     this.QuestDialog  = new int();
     this.Precondition = new CDialogPrecondition();
     this.Actions      = new Actions();
     this.Nodes        = new List <int>();
     this.DialogID     = new int();
     this.version      = new int();
 }
Example #3
0
        public object Clone()
        {
            CDialogPrecondition copy = new CDialogPrecondition();

            //copy.CheckClanID = this.CheckClanID;
            //copy.CheckClan = this.CheckClan;
            foreach (int test in this.tests)
            {
                copy.tests.Add(test);
            }
            copy.ListOfNecessaryQuests = (CDialogPreconditionQuests)this.ListOfNecessaryQuests.Clone();
            copy.ListOfMustNoQuests    = (CDialogPreconditionQuests)this.ListOfMustNoQuests.Clone();
            copy.Reputation            = this.Reputation;
            copy.KarmaPK = this.KarmaPK;
            return(copy);
        }
Example #4
0
        public EditDialogForm(bool isAdd, MainForm parent, int selectedDialogID)
        {
            InitializeComponent();
            dialogID            = selectedDialogID;
            this.isAdd          = isAdd;
            this.parent         = parent;
            this.parent.Enabled = false;


            CDialog curDialog = parent.getDialogOnDialogID(dialogID);

            if (curDialog.Precondition.Reputation.Any())
            {
                editPrecondition = curDialog.Precondition;
                checkReputationIndicates();
            }
            if (curDialog.Precondition.KarmaPK.Any())
            {
                editKarmaPK = curDialog.Precondition.KarmaPK;
            }

            if (parent.isRoot(selectedDialogID) && (!isAdd))
            {
                NPCReactionText.Text = "Приветствие:";
            }

            else if (parent.isRoot(selectedDialogID) && (isAdd))
            {
                //MustPanel.Location = new Point(5, 8);
            }
            if (!isAdd)
            {
                fillDialogEditForm(selectedDialogID);
                this.Text = "Добавление диалога в " + selectedDialogID + "";
            }

            this.Text += "   Версия: " + curDialog.version;
        }
Example #5
0
        //! Парсер xml - файла диалогов, записывает результат в target
        private void parseDialogsFile(String DialogsXMLFile, NPCDicts target)
        {
            if (!File.Exists(DialogsXMLFile))
            {
                return;
            }

            doc = XDocument.Load(DialogsXMLFile);
            foreach (XElement item in doc.Root.Elements())
            {
                int DialogID = int.Parse(item.Element("DialogID").Value);

                string              Title        = item.Element("Title").Value.Trim();
                string              Text         = item.Element("Text").Value.Trim();
                List <string>       Holder       = new List <string>();
                int                 QuestDialog  = new int();
                List <int>          Nodes        = new List <int>();
                Actions             Actions      = new Actions();
                CDialogPrecondition Precondition = new CDialogPrecondition();

                if (item.Element("QuestDialog").Element("toCompleteQuest").Value != "")
                {
                    QuestDialog = int.Parse(item.Element("QuestDialog").Element("toCompleteQuest").Value);
                }

                foreach (string holder in item.Element("Holder").Value.Split(','))
                {
                    Holder.Add(holder.Trim());
                }

                if (item.Element("Nodes").Value != "")
                {
                    foreach (string node in item.Element("Nodes").Value.Split(','))
                    {
                        if (node != "")
                        {
                            Nodes.Add(int.Parse(node));
                        }
                    }
                }

                if (item.Element("Actions").Element("Exit").Value == "1")
                {
                    Actions.Exit = true;
                }
                else
                {
                    Actions.Exit = false;
                }

                if (item.Element("Actions").Element("ToDialog").Value != "")
                {
                    Actions.ToDialog = int.Parse(item.Element("Actions").Element("ToDialog").Value);
                }

                if (!item.Element("Actions").Element("Event").Value.Equals(""))
                {
                    Actions.Event = int.Parse(item.Element("Actions").Element("Event").Value);
                }
                else
                {
                    Actions.Event = 0;
                }

                Actions.Data = item.Element("Actions").Element("Data").Value;

                if (item.Element("Actions").Element("GetQuest").Value != "")
                {
                    foreach (string quest in item.Element("Actions").Element("GetQuest").Value.Split(','))
                    {
                        Actions.GetQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Actions").Element("CompleteQuest").Value != "")
                {
                    foreach (string quest in item.Element("Actions").Element("CompleteQuest").Value.Split(','))
                    {
                        Actions.CompleteQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfCompletedQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfCompletedQuests").Value.Split(','))
                    {
                        Precondition.ListOfNecessaryQuests.ListOfCompletedQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfOpenedQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfOpenedQuests").Value.Split(','))
                    {
                        Precondition.ListOfNecessaryQuests.ListOfOpenedQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfOnTestQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfOnTestQuests").Value.Split(','))
                    {
                        Precondition.ListOfNecessaryQuests.ListOfOnTestQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfCompletedQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfCompletedQuests").Value.Split(','))
                    {
                        Precondition.ListOfMustNoQuests.ListOfCompletedQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfOpenedQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfOpenedQuests").Value.Split(','))
                    {
                        Precondition.ListOfMustNoQuests.ListOfOpenedQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfOnTestQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfOnTestQuests").Value.Split(','))
                    {
                        Precondition.ListOfMustNoQuests.ListOfOnTestQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfFailedQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfMustNoQuests").Element("listOfFailedQuests").Value.Split(','))
                    {
                        Precondition.ListOfMustNoQuests.ListOfFailedQuests.Add(int.Parse(quest));
                    }
                }

                if (item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfFailedQuests").Value != "")
                {
                    foreach (string quest in item.Element("Precondition").Element("ListOfNecessaryQuests").Element("listOfFailedQuests").Value.Split(','))
                    {
                        Precondition.ListOfNecessaryQuests.ListOfOnTestQuests.Add(int.Parse(quest));
                    }
                }

                //if (item.Element("Precondition").Element("CheckClan").Value == "1")
                //    Precondition.tests.Add(0);
                //if (item.Element("Precondition").Element("CheckClanID").Value == "1")
                //    Precondition.tests.Add(1);

                Precondition.KarmaPK = new List <int>();
                if (item.Element("Precondition").Element("KarmaPK").Value != "")
                {
                    foreach (string karme_el in item.Element("Precondition").Element("KarmaPK").Value.Split(','))
                    {
                        Precondition.KarmaPK.Add(int.Parse(karme_el));
                    }
                }

                if (item.Element("Precondition").Element("tests").Value != "")
                {
                    foreach (string test in item.Element("Precondition").Element("tests").Value.Split(','))
                    {
                        Precondition.tests.Add(int.Parse(test));
                    }
                }

                int Version = 0;
                if (!item.Element("Version").Value.Equals(""))
                {
                    Version = int.Parse(item.Element("Version").Value);
                }

                foreach (string el in item.Element("Precondition").Element("Reputation").Value.Split(';'))
                {
                    string[] fr = el.Split(':');
                    if (fr.Count() > 1)
                    {
                        Precondition.Reputation.Add(int.Parse(fr[0]), new List <double>());
                        int type = int.Parse(fr[1]);
                        Precondition.Reputation[int.Parse(fr[0])].Add(type);
                        double a = 0;
                        if (fr[2] != "")
                        {
                            a = double.Parse(fr[2]);
                        }
                        Precondition.Reputation[int.Parse(fr[0])].Add(a);
                        double b = 0;
                        if (fr[3] != "")
                        {
                            b = double.Parse(fr[3]);
                        }
                        Precondition.Reputation[int.Parse(fr[0])].Add(b);
                    }
                }

                foreach (string holder in Holder)
                {
                    if (target.Keys.Contains(holder))
                    {
                        if (!target[holder].Keys.Contains(DialogID))
                        {
                            target[holder].Add(DialogID, new CDialog(holder, Title, Text, QuestDialog, Precondition, Actions, Nodes, DialogID, Version));
                        }
                    }
                    else
                    {
                        target.Add(holder, new Dictionary <int, CDialog>());
                        target[holder].Add(DialogID, new CDialog(holder, Title, Text, QuestDialog, Precondition, Actions, Nodes, DialogID, Version));
                    }
                }
            }
        }
Example #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            int                 newID;
            Actions             actions      = new Actions();
            CDialogPrecondition precondition = new CDialogPrecondition();
            List <int>          nodes        = new List <int>();
            int                 questDialog  = parent.getDialogOnDialogID(dialogID).QuestDialog;
            //List<string> holder = new List<string>();
            string holder;


            //holder.Add(parent.currentNPC);
            holder = parent.currentNPC;



            if (!tSubDialogsTextBox.Text.Equals(""))
            {
                foreach (string node in tSubDialogsTextBox.Text.Split(','))
                {
                    nodes.Add(int.Parse(node));
                }
            }
            if (actionsCheckBox.Checked)
            {
                actions.Exit = ExitcheckBox.Checked;
                if (toTradeCheckBox.Checked)
                {
                    actions.Event = 1;
                }
                if (changeCheckBox.Checked)
                {
                    actions.Event = 2;
                }
                if (ToDialogCheckBox1.Checked)
                {
                    actions.ToDialog = int.Parse(ToDialogComboBox.SelectedItem.ToString());
                }
                if (toRepairCheckBox.Checked)
                {
                    actions.Event = 4;
                }
                if (tleportCheckBox.Checked && !teleportComboBox.SelectedItem.ToString().Equals(""))
                {
                    actions.Event = 5;
                    actions.Data  = parent.tpConst.getTtID(teleportComboBox.SelectedItem.ToString());
                }
                if (toComplexRapairCheckBox.Checked)
                {
                    actions.Event = 6;
                }
                if (barterCheckBox.Checked)
                {
                    actions.Event = 7;
                }

                if (GetQuestsCheckBox.Checked)
                {
                    foreach (string quest in GetQuestsTextBox.Text.Split(','))
                    {
                        actions.GetQuests.Add(int.Parse(quest));
                    }
                }
                if (CompleteQuestsCheckBox.Checked)
                {
                    foreach (string quest in CompleteQuetsTextBox.Text.Split(','))
                    {
                        actions.CompleteQuests.Add(int.Parse(quest));
                    }
                }
            }

            if (!tMustHaveOpenQuests.Text.Equals(""))
            {
                foreach (string quest in tMustHaveOpenQuests.Text.Split(','))
                {
                    precondition.ListOfNecessaryQuests.ListOfOpenedQuests.Add(int.Parse(quest));
                }
            }
            if (!tMustHaveQuestsOnTest.Text.Equals(""))
            {
                foreach (string quest in tMustHaveQuestsOnTest.Text.Split(','))
                {
                    precondition.ListOfNecessaryQuests.ListOfOnTestQuests.Add(int.Parse(quest));
                }
            }
            if (!tMustHaveCompletedQuests.Text.Equals(""))
            {
                foreach (string quest in tMustHaveCompletedQuests.Text.Split(','))
                {
                    precondition.ListOfNecessaryQuests.ListOfCompletedQuests.Add(int.Parse(quest));
                }
            }
            if (!tMustHaveFailedQuests.Text.Equals(""))
            {
                foreach (string quest in tMustHaveFailedQuests.Text.Split(','))
                {
                    precondition.ListOfNecessaryQuests.ListOfFailedQuests.Add(int.Parse(quest));
                }
            }

            if (!tShouldntHaveOpenQuests.Text.Equals(""))
            {
                foreach (string quest in tShouldntHaveOpenQuests.Text.Split(','))
                {
                    precondition.ListOfMustNoQuests.ListOfOpenedQuests.Add(int.Parse(quest));
                }
            }
            if (!tShouldntHaveQuestsOnTest.Text.Equals(""))
            {
                foreach (string quest in tShouldntHaveQuestsOnTest.Text.Split(','))
                {
                    precondition.ListOfMustNoQuests.ListOfOnTestQuests.Add(int.Parse(quest));
                }
            }
            if (!tShouldntHaveCompletedQuests.Text.Equals(""))
            {
                foreach (string quest in tShouldntHaveCompletedQuests.Text.Split(','))
                {
                    precondition.ListOfMustNoQuests.ListOfCompletedQuests.Add(int.Parse(quest));
                }
            }
            if (!tShouldntHaveFailedQuests.Text.Equals(""))
            {
                foreach (string quest in tShouldntHaveFailedQuests.Text.Split(','))
                {
                    precondition.ListOfMustNoQuests.ListOfFailedQuests.Add(int.Parse(quest));
                }
            }

            precondition.tests.Clear();
            if (CheckClanIDcheckBox.Checked)
            {
                precondition.tests.Add(1);
            }
            if (CheckClanCheckBox.Checked)
            {
                precondition.tests.Add(0);
            }
            if (CheckLonerCheckBox.Checked)
            {
                precondition.tests.Add(2);
            }

            //if (!reputationTextBox01.Text.Equals("") || !reputationTextBox0.Text.Equals(""))
            //{
            //    precondition.Reputation.Add(0, new List<int>());
            //    if (!reputationTextBox01.Text.Equals("") && !reputationTextBox0.Text.Equals(""))
            //    {
            //        precondition.Reputation[0].Add(0);
            //        precondition.Reputation[0].Add(int.Parse(reputationTextBox01.Text));
            //        precondition.Reputation[0].Add(int.Parse(reputationTextBox0.Text));
            //    }
            //    else if (!reputationTextBox01.Text.Equals("") && reputationTextBox0.Text.Equals(""))
            //    {
            //        precondition.Reputation[0].Add(1);
            //        precondition.Reputation[0].Add(int.Parse(reputationTextBox01.Text));
            //        precondition.Reputation[0].Add(0);
            //    }
            //    else if (reputationTextBox01.Text.Equals("") && !reputationTextBox0.Text.Equals(""))
            //    {
            //        precondition.Reputation[0].Add(2);
            //        precondition.Reputation[0].Add(0);
            //        precondition.Reputation[0].Add(int.Parse(reputationTextBox0.Text));
            //    }

            //}
            //if (!reputationTextBox11.Text.Equals("") || !reputationTextBox1.Text.Equals(""))
            //{
            //    precondition.Reputation.Add(1, new List<int>());
            //    if (!reputationTextBox11.Text.Equals("") && !reputationTextBox1.Text.Equals(""))
            //    {
            //        precondition.Reputation[1].Add(0);
            //        precondition.Reputation[1].Add(int.Parse(reputationTextBox11.Text));
            //        precondition.Reputation[1].Add(int.Parse(reputationTextBox1.Text));
            //    }
            //    else if (!reputationTextBox11.Text.Equals("") && reputationTextBox1.Text.Equals(""))
            //    {
            //        precondition.Reputation[1].Add(1);
            //        precondition.Reputation[1].Add(int.Parse(reputationTextBox11.Text));
            //        precondition.Reputation[1].Add(0);
            //    }
            //    else if (reputationTextBox11.Text.Equals("") && !reputationTextBox1.Text.Equals(""))
            //    {
            //        precondition.Reputation[1].Add(2);
            //        precondition.Reputation[1].Add(0);
            //        precondition.Reputation[1].Add(int.Parse(reputationTextBox1.Text));
            //    }

            //}
            //if (!reputationTextBox21.Text.Equals("") || !reputationTextBox2.Text.Equals(""))
            //{
            //    precondition.Reputation.Add(2, new List<int>());
            //    if (!reputationTextBox21.Text.Equals("") && !reputationTextBox2.Text.Equals(""))
            //    {
            //        precondition.Reputation[2].Add(0);
            //        precondition.Reputation[2].Add(int.Parse(reputationTextBox21.Text));
            //        precondition.Reputation[2].Add(int.Parse(reputationTextBox2.Text));
            //    }
            //    else if (!reputationTextBox21.Text.Equals("") && reputationTextBox2.Text.Equals(""))
            //    {
            //        precondition.Reputation[2].Add(1);
            //        precondition.Reputation[2].Add(int.Parse(reputationTextBox21.Text));
            //        precondition.Reputation[2].Add(0);
            //    }
            //    else if (reputationTextBox21.Text.Equals("") && !reputationTextBox2.Text.Equals(""))
            //    {
            //        precondition.Reputation[2].Add(2);
            //        precondition.Reputation[2].Add(0);
            //        precondition.Reputation[2].Add(int.Parse(reputationTextBox2.Text));
            //    }
            //}
            //if (!reputationTextBox31.Text.Equals("") || !reputationTextBox3.Text.Equals(""))
            //{
            //    precondition.Reputation.Add(3, new List<int>());
            //    if (!reputationTextBox21.Text.Equals("") && !reputationTextBox2.Text.Equals(""))
            //    {
            //        precondition.Reputation[3].Add(0);
            //        precondition.Reputation[3].Add(int.Parse(reputationTextBox31.Text));
            //        precondition.Reputation[3].Add(int.Parse(reputationTextBox3.Text));
            //    }
            //    else if (!reputationTextBox31.Text.Equals("") && reputationTextBox3.Text.Equals(""))
            //    {
            //        precondition.Reputation[3].Add(1);
            //        precondition.Reputation[3].Add(int.Parse(reputationTextBox31.Text));
            //        precondition.Reputation[3].Add(0);
            //    }
            //    else if (reputationTextBox31.Text.Equals("") && !reputationTextBox3.Text.Equals(""))
            //    {
            //        precondition.Reputation[3].Add(2);
            //        precondition.Reputation[3].Add(0);
            //        precondition.Reputation[3].Add(int.Parse(reputationTextBox3.Text));
            //    }
            //}
            //if (!reputationTextBox41.Text.Equals("") || !reputationTextBox4.Text.Equals(""))
            //{
            //    precondition.Reputation.Add(4, new List<int>());
            //    if (!reputationTextBox41.Text.Equals("") && !reputationTextBox4.Text.Equals(""))
            //    {
            //        precondition.Reputation[4].Add(0);
            //        precondition.Reputation[4].Add(int.Parse(reputationTextBox41.Text));
            //        precondition.Reputation[4].Add(int.Parse(reputationTextBox4.Text));
            //    }
            //    else if (!reputationTextBox41.Text.Equals("") && reputationTextBox4.Text.Equals(""))
            //    {
            //        precondition.Reputation[4].Add(1);
            //        precondition.Reputation[4].Add(int.Parse(reputationTextBox41.Text));
            //        precondition.Reputation[4].Add(0);
            //    }
            //    else if (reputationTextBox41.Text.Equals("") && !reputationTextBox4.Text.Equals(""))
            //    {
            //        precondition.Reputation[4].Add(2);
            //        precondition.Reputation[4].Add(0);
            //        precondition.Reputation[4].Add(int.Parse(reputationTextBox4.Text));
            //    }
            //}

            //if (editPrecondition.Reputation.Any())
            precondition.Reputation = editPrecondition.Reputation;
            precondition.KarmaPK    = editKarmaPK;



            if (isAdd)
            {
                newID = parent.getDialogsNewID();
                parent.addActiveDialog(newID, new CDialog(holder, tPlayerText.Text, tNPCReactiontextBox.Text, questDialog, precondition, actions, nodes, newID, 1), dialogID);
            }
            else
            {
                parent.replaceDialog(new CDialog(holder
                                                 , tPlayerText.Text, tNPCReactiontextBox.Text, questDialog, precondition, actions, nodes, dialogID, (curDialog.version + 1)), dialogID);
            }
            parent.Enabled = true;
            this.Close();
        }