예제 #1
0
        private void AddListQuests_Click(object sender, EventArgs e)
        {
            int index = CurrentWSG.NumberOfQuestLists;

            // Create an empty quest table
            WillowSaveGame.QuestTable qt = new WillowSaveGame.QuestTable();
            qt.Index       = index;
            qt.TotalQuests = 0;
            qt.Quests      = new List <WillowSaveGame.QuestEntry>();

            // Add the new table to the list
            CurrentWSG.QuestLists.Add(qt);
            CurrentWSG.NumberOfQuestLists++;

            QuestTree.BeginUpdate();

            //Add the new table to the tree view
            ColoredTextNode categoryNode = new ColoredTextNode();

            categoryNode.Text = "Playthrough " + (index + 1) + " Quests";
            categoryNode.Tag  = index.ToString();
            (QuestTree.Model as TreeModel).Nodes.Add(categoryNode);

            // Add Fresh Off the Bus (the first quest) to the table
            string startQuest = "Z0_Missions.Missions.M_IntroStateSaver";

            AddQuestByName(startQuest, index);
            qt.CurrentQuest = startQuest;
            QuestTree.EndUpdate();
        }
예제 #2
0
파일: ScriptQuests.cs 프로젝트: gloist/RBot
        /// <summary>
        /// Checks if the specified quest is a completed daily quest.
        /// </summary>
        /// <param name="id">The id of the quest.</param>
        /// <returns>Whether or not the specified quest is a daily quest that the player has already completed.</returns>
        public bool IsDailyComplete(int id)
        {
            Bot.Wait.ForTrue(() => QuestTree.Contains(x => x.ID == id), () => Load(id), 20);
            Quest q = QuestTree.Find(x => x.ID == id);

            return(q != null && q.Field != null && Bot.CallGameFunction <int>("world.getAchievement", q.Field, q.Index) != 0);
        }
예제 #3
0
        private void RemoveListQuests_Click(object sender, EventArgs e)
        {
            TreeNodeAdv[] selection = QuestTree.SelectedNodes.ToArray();

            QuestTree.BeginUpdate();
            foreach (TreeNodeAdv nodeAdv in selection)
            {
                if (nodeAdv.Parent == QuestTree.Root)
                {
                    CurrentWSG.NumberOfQuestLists--;
                    CurrentWSG.QuestLists.RemoveAt(nodeAdv.Index);
                    QuestTree.Root.Children[nodeAdv.Index].Remove();
                }
            }

            // The indexes will be messed up if a list that is not the last one is
            // removed, so update the tree text, tree indexes, and quest list indices
            int count = CurrentWSG.NumberOfQuestLists;

            for (int index = 0; index < count; index++)
            {
                TreeNodeAdv nodeAdv = QuestTree.Root.Children[index];

                // Adjust the category node's text and tag to reflect its new position
                ColoredTextNode parent = nodeAdv.Data();
                parent.Text = "Playthrough " + (index + 1) + " Quests";
                parent.Tag  = index.ToString();

                // Adjust the quest list index to reflect its new position
                CurrentWSG.QuestLists[index].Index = index;
            }
            QuestTree.EndUpdate();
        }
예제 #4
0
        public void DoQuestTree()
        {
            QuestTree.BeginUpdate();

            // Make a new quest tree or clear the old one
            if (QuestTree.Model == null)
            {
                QuestTree.Model = new TreeModel();
            }
            else
            {
                QuestTree.Clear();
            }

            TreeModel model = QuestTree.Model as TreeModel;

            for (int listIndex = 0; listIndex < CurrentWSG.NumberOfQuestLists; listIndex++)
            {
                // Create the category node for this playthrough
                // Quest tree category nodes:
                //     Text = human readable quest category ("Playthrough 1 Quests", etc)
                //     Tag = quest list index as string (0 based)
                ColoredTextNode parent = new ColoredTextNode();
                parent.Text = "Playthrough " + (listIndex + 1) + " Quests";
                parent.Tag  = listIndex.ToString();
                model.Nodes.Add(parent);

                WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[listIndex];
                // Create all the actual quest nodes for this playthrough
                //     Text = human readable quest name
                //     Tag = internal quest name
                for (int questIndex = 0; questIndex < qt.TotalQuests; questIndex++)
                {
                    string nodeName = qt.Quests[questIndex].Name;

                    ColoredTextNode node = new ColoredTextNode();
                    node.Tag  = nodeName;
                    node.Text = QuestsXml.XmlReadValue(nodeName, "MissionName");
                    if (node.Text == "")
                    {
                        node.Text = "(" + nodeName + ")";
                    }
                    parent.Nodes.Add(node);
                }
            }
            QuestTree.EndUpdate();
        }
예제 #5
0
    public static void SaveFile(QuestTree data)
    {
        List <Quest> quests = data.GetQuests();

        if (!Directory.Exists(Application.dataPath + "/Quests/"))
        {
            Directory.CreateDirectory(Application.dataPath + "/Quests/");
        }
        foreach (Quest quest in quests)
        {
            string path = Application.dataPath + "/Quests/" + filename + "_" + quest.QuestName + ".json";
            File.Delete(path);
            StreamWriter writer = new StreamWriter(File.OpenWrite(path), System.Text.Encoding.UTF8);
            Debug.Log(QuestFileManager.serializeQuest(quest));
            writer.Write(QuestFileManager.serializeQuest(quest));
            writer.Close();
        }
    }
예제 #6
0
    public static QuestTree LoadFile()
    {
        QuestTree tree = new QuestTree();

        string[] files = Directory.GetFiles(Application.dataPath + "/Quests/", "*.json");

        foreach (string filepath in files)
        {
            StreamReader reader = new StreamReader(filepath, System.Text.Encoding.UTF8);
            string       json   = reader.ReadToEnd();

            Quest quest = new Quest();
            quest.fromJson(JSON.Parse(json));
            tree.AddQuest(quest);
            reader.Close();
        }
        return(tree);
    }
예제 #7
0
    //DEPRECATED
    public static ITree getTreeFromFile(string path, TreeType treeType, GlobalFlags gf)
    {
        ITree            t            = null;
        List <ITreeNode> treeNodeList = null;

        switch (treeType)
        {
        case TreeType.World:
            WorldTree worldTree = new WorldTree(gf, treeType);
            treeNodeList = getTreeNodeListFromFile(path, treeType);
            worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList);
            worldTree.currentIndex       = treeNodeList[0].index;
            t = worldTree;
            break;

        case TreeType.Zone:
            ZoneTree zoneTree = new ZoneTree(gf, treeType);
            treeNodeList = getTreeNodeListFromFile(path, treeType);
            zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList);
            zoneTree.currentIndex       = treeNodeList[0].index;
            t = zoneTree;
            break;

        case TreeType.Dialog:
            DialogTree dialogTree = new DialogTree(gf, treeType);
            treeNodeList = getTreeNodeListFromFile(path, treeType);
            dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList);
            dialogTree.currentIndex       = treeNodeList[0].index;
            t = dialogTree;
            break;

        case TreeType.Quest:
            QuestTree questTree = new QuestTree(gf, treeType);
            treeNodeList = getTreeNodeListFromFile(path, treeType);
            questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList);
            questTree.currentIndex       = treeNodeList[0].index;
            t = questTree;
            break;

        default:
            break;
        }
        return(t);
    }
예제 #8
0
        public void DeleteAllQuests(int index)
        {
            WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index];
            qt.Quests.Clear();
            qt.TotalQuests = 0;

            QuestTree.BeginUpdate();
            TreeNodeAdv[] children = QuestTree.Root.Children[index].Children.ToArray();
            foreach (TreeNodeAdv child in children)
            {
                child.Remove();
            }

            string startQuest = "Z0_Missions.Missions.M_IntroStateSaver";

            AddQuestByName(startQuest, index);
            qt.CurrentQuest = startQuest;

            QuestTree.EndUpdate();
        }
예제 #9
0
    public void OnGUI()
    {
        if (quests.GetQuests().Count == 0)
        {
            quests = QuestFileManager.LoadFile();
        }

        if (GUILayout.Button("Add quest", GUILayout.MaxWidth(100)))
        {
            AddQuest addQuestEditor = (AddQuest)EditorWindow.GetWindow(typeof(AddQuest));
            addQuestEditor.setQuestTree(quests);
            addQuestEditor.Show();
        }
        if (GUILayout.Button("Reset quest", GUILayout.MaxWidth(100)))
        {
            foreach (Quest quest in quests.GetQuests())
            {
                QuestFileManager.DeleteQuest(quest);
            }
            quests.Empty();
        }

        EditorGUILayout.BeginScrollView(new Vector2(0, 0), true, true);
        if (quests.GetQuests().Count != 0)
        {
            foreach (Quest quest in quests.GetQuests())
            {
                if (GUILayout.Button(quest.QuestName, GUILayout.MaxWidth(100)))
                {
                    EditQuest editQuest = (EditQuest)EditorWindow.GetWindow(typeof(EditQuest));
                    editQuest.setQuestTree(quests);
                    editQuest.setQuest(quest);
                    editQuest.Show();
                }
            }
        }
        EditorGUILayout.EndScrollView();
    }
예제 #10
0
 private Quest EnsureLoaded(int id)
 {
     Bot.Wait.ForTrue(() => QuestTree.Contains(x => x.ID == id), () => Load(id), 20);
     return(QuestTree.Find(q => q.ID == id));
 }
예제 #11
0
 /// <summary>
 /// Tries to get the quest with the given ID if it is loaded.
 /// </summary>
 /// <param name="id">The ID of the quest to get.</param>
 /// <param name="quest">The quest object to set as the result.</param>
 /// <returns>True if the quest is loaded and quest was set succesfully.</returns>
 public bool TryGetQuest(int id, out Quest quest) => (quest = QuestTree.Find(x => x.ID == id)) != null;
예제 #12
0
        /// <summary>
        /// Checks if the specified quest is a completed daily quest.
        /// </summary>
        /// <param name="id">The id of the quest.</param>
        /// <returns>Whether or not the specified quest is a daily quest that the player has already completed.</returns>
        public bool IsDailyComplete(int id)
        {
            Quest q = QuestTree.Find(x => x.ID == id);

            return(q != null && q.Field != null && Bot.CallGameFunction <int>("world.getAchievement", q.Field, q.Index) != 0);
        }
예제 #13
0
 public void setQuestTree(QuestTree questTree)
 {
     quests = questTree;
 }
예제 #14
0
        public void MergeFromSaveQuests(string filename, int index)
        {
            WillowSaveGame OtherSave = new WillowSaveGame();

            OtherSave.LoadWsg(filename);

            if (OtherSave.NumberOfQuestLists - 1 < index)
            {
                return;
            }

            WillowSaveGame.QuestTable qtOther = OtherSave.QuestLists[index];
            WillowSaveGame.QuestTable qt      = CurrentWSG.QuestLists[index];

            QuestTree.BeginUpdate();
            foreach (WillowSaveGame.QuestEntry qe in OtherSave.QuestLists[index].Quests)
            {
                string name     = qe.Name;
                int    progress = qe.Progress;

                // Check to see if the quest is already in the list
                QuestSearchKey = name;
                int prevIndex = qt.Quests.FindIndex(QuestSearchByName);
                if (prevIndex != -1)
                {
                    // This quest entry exists in both lists.  If the progress is
                    // not greater then don't do anything with it.
                    WillowSaveGame.QuestEntry old = qt.Quests[prevIndex];
                    if (progress < old.Progress)
                    {
                        continue;
                    }

                    if (progress == old.Progress)
                    {
                        // If the progress of the quest is the same, there may be
                        // individual objectives that don't have the same progress
                        // so check and update them.
                        int objectiveCount = qe.NumberOfObjectives;

                        // The number of objectives should be the same with the same
                        // level of progress.  If they aren't then there's something
                        // wrong so just ignore the new quest and keep the old.
                        if (objectiveCount != old.NumberOfObjectives)
                        {
                            continue;
                        }

                        for (int i = 0; i < objectiveCount; i++)
                        {
                            int objectiveProgress = old.Objectives[i].Progress;
                            if (qe.Objectives[i].Progress < objectiveProgress)
                            {
                                qe.Objectives[i].Progress = objectiveProgress;
                            }
                        }
                    }

                    // This quest progress is further advanced than the existing one
                    // so replace the existing one in the list.
                    qt.Quests[prevIndex] = qe;

                    // The quest doesn't need to be added to the quest list since we
                    // modified an existing entry.  The tree view doesn't need to be
                    // changed because the name and text should still be the same.
                    continue;
                }

                // Add the quest entry to the quest list
                qt.Quests.Add(qe);
                qt.TotalQuests++;

                // Add the quest to the tree view
                ColoredTextNode treeNode = new ColoredTextNode();
                treeNode.Tag  = qe.Name;
                treeNode.Text = QuestsXml.XmlReadValue(qe.Name, "MissionName");
                if (treeNode.Text == "")
                {
                    treeNode.Text = "(" + treeNode.Tag as string + ")";
                }
                QuestTree.Root.Children[index].AddNode(treeNode);
            }
            QuestTree.EndUpdate();

            // In case the operation modified the currently selected quest, refresh
            // the quest group panel by signalizing the selection changed event.
            QuestTree_SelectionChanged(null, null);
        }
예제 #15
0
        public void MergeAllFromXmlQuests(string filename, int index)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(filename);

            if (doc.SelectSingleNode("/WT/Quests") == null)
            {
                throw new ApplicationException("NoQuests");
            }

            XmlNodeList questnodes = doc.SelectNodes("/WT/Quests/Quest");

            if (questnodes == null)
            {
                return;
            }

            WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index];

            QuestTree.BeginUpdate();
            // Copy only the quests that are not duplicates from the XML file
            foreach (XmlNode node in questnodes)
            {
                string name     = node.GetElement("Name", "");
                int    progress = node.GetElementAsInt("Progress", 0);

                // Check to see if the quest is already in the list
                QuestSearchKey = name;
                int prevIndex = qt.Quests.FindIndex(QuestSearchByName);
                if (prevIndex != -1)
                {
                    // This quest entry exists in both lists.  If the progress is
                    // not greater then don't do anything with it.
                    WillowSaveGame.QuestEntry old = qt.Quests[prevIndex];
                    if (progress <= old.Progress)
                    {
                        continue;
                    }

                    // This quest progress is further advanced than the existing one
                    // so copy all its values.
                    old.Progress  = progress;
                    old.DlcValue1 = node.GetElementAsInt("DLCValue1", 0);
                    old.DlcValue2 = node.GetElementAsInt("DLCValue2", 0);

                    int newObjectiveCount = node.GetElementAsInt("Objectives", 0);
                    old.NumberOfObjectives = newObjectiveCount;
                    old.Objectives         = new WillowSaveGame.QuestObjective[newObjectiveCount];

                    for (int objectiveIndex = 0; objectiveIndex < newObjectiveCount; objectiveIndex++)
                    {
                        old.Objectives[objectiveIndex].Description = node.GetElement("FolderName" + objectiveIndex, "");
                        old.Objectives[objectiveIndex].Progress    = node.GetElementAsInt("FolderValue" + objectiveIndex, 0);
                    }

                    // The quest doesn't need to be added to the quest list since we
                    // modified an existing entry.  The tree view doesn't need to be
                    // changed because the name and text should still be the same.
                    continue;
                }

                // Create a new quest entry from the quest's xml node data
                WillowSaveGame.QuestEntry qe = new WillowSaveGame.QuestEntry();
                qe.Name      = name;
                qe.Progress  = progress;
                qe.DlcValue1 = node.GetElementAsInt("DLCValue1", 0);
                qe.DlcValue2 = node.GetElementAsInt("DLCValue2", 0);

                int objectiveCount = node.GetElementAsInt("Objectives", 0);
                qe.NumberOfObjectives = objectiveCount;
                qe.Objectives         = new WillowSaveGame.QuestObjective[objectiveCount];

                for (int objectiveIndex = 0; objectiveIndex < objectiveCount; objectiveIndex++)
                {
                    qe.Objectives[objectiveIndex].Description = node.GetElement("FolderName" + objectiveIndex, "");
                    qe.Objectives[objectiveIndex].Progress    = node.GetElementAsInt("FolderValue" + objectiveIndex, 0);
                }

                // Add the quest entry to the quest list
                qt.Quests.Add(qe);
                qt.TotalQuests++;

                // Add the quest to the tree view
                ColoredTextNode treeNode = new ColoredTextNode();
                treeNode.Tag  = name;
                treeNode.Text = QuestsXml.XmlReadValue(name, "MissionName");
                if (treeNode.Text == "")
                {
                    treeNode.Text = "(" + name + ")";
                }
                QuestTree.Root.Children[index].AddNode(treeNode);
            }
            QuestTree.EndUpdate();

            // In case the operation modified the currently selected quest, refresh
            // the quest group panel by signalizing the selection changed event.
            QuestTree_SelectionChanged(null, null);
        }
예제 #16
0
 ///<inheritdoc/>
 public override bool Undo()
 {
     QuestTree.RemoveChild(Parent, ChildToAdd);
     return(true);
 }
예제 #17
0
 ///<inheritdoc/>
 public override bool Execute()
 {
     QuestTree.RemoveChild(_parent, _toDelete);
     return(true);
 }
예제 #18
0
 public static ITree getTreeFromString(string data, TreeType treeType, GlobalFlags gf)
 {
     ITree t = null;
         List<ITreeNode> treeNodeList = null;
         switch (treeType)
         {
             case TreeType.World:
                 WorldTree worldTree = new WorldTree(gf, treeType);
                 treeNodeList = getTreeNodeListFromString(data, treeType);
                 worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList);
                 worldTree.currentIndex = treeNodeList[0].index;
                 t = worldTree;
                 break;
             case TreeType.Zone:
                 ZoneTree zoneTree = new ZoneTree(gf, treeType);
                 treeNodeList = getTreeNodeListFromString(data, treeType);
                 zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList);
                 zoneTree.currentIndex = treeNodeList[0].index;
                 t = zoneTree;
                 break;
             case TreeType.Dialog:
                 DialogTree dialogTree = new DialogTree(gf, treeType);
                 treeNodeList = getTreeNodeListFromString(data, treeType);
                 dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList);
                 dialogTree.currentIndex = treeNodeList[0].index;
                 t = dialogTree;
                 break;
             case TreeType.Quest:
                 QuestTree questTree = new QuestTree(gf, treeType);
                 treeNodeList = getTreeNodeListFromString(data, treeType);
                 questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList);
                 questTree.currentIndex = treeNodeList[0].index;
                 t = questTree;
                 break;
             case TreeType.Battle:
                 BattleTree battleTree = new BattleTree(gf, treeType);
                 treeNodeList = getTreeNodeListFromString(data, treeType);
                 battleTree.treeNodeDictionary = getBattleTreeNodeFromList(treeNodeList);
                 battleTree.currentIndex = treeNodeList[0].index;
                 t = battleTree;
                 break;
             case TreeType.Info:
                 InfoTree infoTree = new InfoTree(gf, treeType);
                 treeNodeList = getTreeNodeListFromString(data, treeType);
                 infoTree.treeNodeDictionary = getInfoTreeNodeFromList(treeNodeList);
                 infoTree.currentIndex = treeNodeList[0].index;
                 t = infoTree;
                 break;
             default:
                 break;
         }
         return t;
 }
예제 #19
0
        private void ImportFromSaveQuests_Click(object sender, EventArgs e)
        {
            int index = GetSelectedQuestList();

            if (index == -1)
            {
                MessageBox.Show("Select a playthrough to import to first.");
                return;
            }

            Util.WTOpenFileDialog tempOpen = new Util.WTOpenFileDialog("sav", "");

            if (tempOpen.ShowDialog() == DialogResult.OK)
            {
                WillowSaveGame OtherSave = new WillowSaveGame();

                try
                {
                    OtherSave.LoadWsg(tempOpen.FileName());
                }
                catch { return; }

                if (OtherSave.NumberOfQuestLists - 1 < index)
                {
                    MessageBox.Show("This quest list does not exist in the other savegame file.");
                    return;
                }

                // Note that when you set lists equal to one another like this it doesn't copy
                // the elements, only the pointer to the list.  This is only safe here because
                // OtherSave will be disposed of right away and not modify the values.  If OtherSave
                // was being used actively then a new copy of all the elements in the quest list
                // would have to be made or else changes to one would affect the quest
                // list of the other.

                // Replace the old entries in the quest table with the new ones
                CurrentWSG.QuestLists[index] = OtherSave.QuestLists[index];

                WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index];

                QuestTree.BeginUpdate();
                TreeNodeAdv parent = QuestTree.Root.Children[index];

                // Remove the old entries from the tree view
                TreeNodeAdv[] children = parent.Children.ToArray();
                foreach (TreeNodeAdv child in children)
                {
                    child.Remove();
                }

                // Add the new entries to the tree view
                foreach (WillowSaveGame.QuestEntry qe in qt.Quests)
                {
                    string nodeName = qe.Name;

                    ColoredTextNode node = new ColoredTextNode();
                    node.Tag  = nodeName;
                    node.Text = QuestsXml.XmlReadValue(nodeName, "MissionName");
                    if (node.Text == "")
                    {
                        node.Text = "(" + node.Tag as string + ")";
                    }
                    parent.AddNode(node);
                }
                QuestTree.EndUpdate();
            }
        }
예제 #20
0
 ///<inheritdoc/>
 public override bool Undo()
 {
     QuestTree.AddChild(_parent, _toDelete);
     return(true);
 }
예제 #21
0
 public static ITree getTreeFromFile(string path,TreeType treeType,  GlobalFlags gf)
 {
     ITree t = null;
         List<ITreeNode> treeNodeList = null;
         switch (treeType)
         {
             case TreeType.World:
                 WorldTree worldTree = new WorldTree(gf, treeType);
                     treeNodeList = getTreeNodeListFromFile(path,treeType);
                    worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList);
                    worldTree.currentIndex = treeNodeList[0].index;
                 t = worldTree;
                 break;
             case TreeType.Zone:
                 ZoneTree zoneTree = new ZoneTree(gf, treeType);
                    treeNodeList = getTreeNodeListFromFile(path,treeType);
                    zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList);
                    zoneTree.currentIndex = treeNodeList[0].index;
                    t = zoneTree;
                 break;
             case TreeType.Dialog:
                 DialogTree dialogTree = new DialogTree(gf, treeType);
                     treeNodeList = getTreeNodeListFromFile(path,treeType);
                     dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList);
                     dialogTree.currentIndex = treeNodeList[0].index;
                     t = dialogTree;
                 break;
             case TreeType.Quest:
                 QuestTree questTree = new QuestTree(gf, treeType);
                     treeNodeList = getTreeNodeListFromFile(path,treeType);
                     questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList);
                     questTree.currentIndex = treeNodeList[0].index;
                     t = questTree;
                 break;
             default:
                 break;
         }
         return t;
 }
예제 #22
0
        public void LoadQuests(string filename, int index)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(filename);

            if (doc.SelectSingleNode("WT/Quests") == null)
            {
                throw new ApplicationException("NoQuests");
            }

            XmlNodeList questnodes = doc.SelectNodes("WT/Quests/Quest");

            int count = questnodes.Count;

            WillowSaveGame.QuestTable qt = CurrentWSG.QuestLists[index];
            qt.Quests.Clear();
            qt.TotalQuests = count;

            QuestTree.BeginUpdate();

            TreeNodeAdv parent = QuestTree.Root.Children[index];

            // Remove the old entries from the tree view
            TreeNodeAdv[] children = parent.Children.ToArray();
            foreach (TreeNodeAdv child in children)
            {
                child.Remove();
            }

            for (int nodeIndex = 0; nodeIndex < count; nodeIndex++)
            {
                XmlNode node = questnodes[nodeIndex];
                WillowSaveGame.QuestEntry qe = new WillowSaveGame.QuestEntry();
                qe.Name      = node.GetElement("Name", "");
                qe.Progress  = node.GetElementAsInt("Progress", 0);
                qe.DlcValue1 = node.GetElementAsInt("DLCValue1", 0);
                qe.DlcValue2 = node.GetElementAsInt("DLCValue2", 0);

                int objectiveCount = node.GetElementAsInt("Objectives", 0);
                qe.NumberOfObjectives = objectiveCount;
                qe.Objectives         = new WillowSaveGame.QuestObjective[objectiveCount];

                for (int objectiveIndex = 0; objectiveIndex < objectiveCount; objectiveIndex++)
                {
                    qe.Objectives[objectiveIndex].Description = node.GetElement("FolderName" + objectiveIndex, "");
                    qe.Objectives[objectiveIndex].Progress    = node.GetElementAsInt("FolderValue" + objectiveIndex, 0);
                }
                qt.Quests.Add(qe);

                // Add the quest to the tree view
                ColoredTextNode treeNode = new ColoredTextNode();
                treeNode.Tag  = qe.Name;
                treeNode.Text = QuestsXml.XmlReadValue(qe.Name, "MissionName");
                if (treeNode.Text == "")
                {
                    treeNode.Text = "(" + treeNode.Tag as string + ")";
                }
                QuestTree.Root.Children[index].AddNode(treeNode);
            }

            // TODO: The current quest is not currently stored in a quest file.
            // It should be stored when the entire list is stored and restored
            // when the list is loaded here.
            qt.CurrentQuest = "";

            QuestTree.EndUpdate();
        }
예제 #23
0
    public static ITree getTreeFromString(string data, TreeType treeType, GlobalFlags gf)
    {
        ITree            t            = null;
        List <ITreeNode> treeNodeList = null;

        switch (treeType)
        {
        case TreeType.World:
            WorldTree worldTree = new WorldTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList);
            worldTree.currentIndex       = treeNodeList[0].index;
            t = worldTree;
            break;

        case TreeType.Zone:
            ZoneTree zoneTree = new ZoneTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList);
            zoneTree.currentIndex       = treeNodeList[0].index;
            t = zoneTree;
            break;

        case TreeType.Dialog:
            DialogTree dialogTree = new DialogTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList);
            dialogTree.currentIndex       = treeNodeList[0].index;
            t = dialogTree;
            break;

        case TreeType.Quest:
            QuestTree questTree = new QuestTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList);
            questTree.currentIndex       = treeNodeList[0].index;
            t = questTree;
            break;

        case TreeType.Battle:
            BattleTree battleTree = new BattleTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            battleTree.treeNodeDictionary = getBattleTreeNodeFromList(treeNodeList);
            battleTree.currentIndex       = treeNodeList[0].index;
            t = battleTree;
            break;

        case TreeType.Info:
            InfoTree infoTree = new InfoTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            infoTree.treeNodeDictionary = getInfoTreeNodeFromList(treeNodeList);
            infoTree.currentIndex       = treeNodeList[0].index;
            t = infoTree;
            break;

        case TreeType.Store:
            StoreTree storeTree = new StoreTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            storeTree.treeNodeDictionary = getStoreTreeNodeFromList(treeNodeList);
            storeTree.currentIndex       = treeNodeList[0].index;
            t = storeTree;
            break;

        case TreeType.Cutscene:
            CutsceneTree cutsceneTree = new CutsceneTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            cutsceneTree.treeNodeDictionary = getCutsceneTreeNodeFromList(treeNodeList);
            cutsceneTree.currentIndex       = treeNodeList[0].index;
            t = cutsceneTree;
            break;

        default:
            break;
        }
        return(t);
    }
예제 #24
0
 ///<inheritdoc/>
 public override bool Execute()
 {
     QuestTree.AddChild(Parent, ChildToAdd);
     return(true);
 }