Пример #1
0
 private IEnumerator <QuestStep> GetChildren(QuestTreeNode root)
 {
     foreach (QuestTreeNode nextNode in root.children)
     {
         yield return(_stepsDictionary[nextNode.stepId]);
     }
 }
Пример #2
0
    /**
     * Se charge de convertir les champs chargés depuis le XML en des données plus
     * utilisables (dictionnaires au lieu de listes, ...).
     * C'aurait été directement possible avec des propriétés si Microsoft n'avait
     * pas programmé l'API de C# avec le cul ! (et en Inde!!!) Du coup ça ne l'est
     * pas car les champs de collections sont assignés à une nouvelle collection,
     * PUIS celle-ci est remplie, au lieu de remplir avant d'assigner, comme l'aurait
     * voulu le bon sens... Sérieux, c'est des erreurs de première bac, ça ! ><
     **/
    public void FinaliseXMLData()
    {
        foreach (QuestStep step in stepsList)
        {
            _stepsDictionary[step.id] = step;
            step.FinaliseXMLData();
        }

        _currentNode = root;
    }
Пример #3
0
    public static Dictionary <long, QuestTreeNode> getQuestTreeNodeFromList(List <ITreeNode> treeNodeList)
    {
        Dictionary <long, QuestTreeNode> treeNodeDict = new Dictionary <long, QuestTreeNode>();

        foreach (var node in treeNodeList)
        {
            QuestTreeNode wNode = (QuestTreeNode)node;
            treeNodeDict.Add(wNode.index, wNode);
        }

        return(treeNodeDict);
    }
Пример #4
0
    //return a string list of the quest, given the current global flags
    //classic tree traversal, checking conditions
    public List <string> getQuestDisplay()
    {
        List <string> questStrList = new List <string>();

        if (globalFlags.checkFlag(treeName, "true", CompareType.Equal))
        {
            QuestTreeNode rootNode = (QuestTreeNode)getNode(1);
            questStrList.Add(rootNode.name);     //quest title

            questStrList.AddRange(getQuestDisplayTree());
        }
        return(questStrList);
    }
Пример #5
0
    public List <QuestStep> GetDoneSteps()
    {
        Queue <QuestTreeNode> toVisit       = new Queue <QuestTreeNode>();
        List <QuestStep>      questStepDone = new List <QuestStep>();

        toVisit.Enqueue(root);
        while (toVisit.Count > 0)
        {
            QuestTreeNode questStepNode = toVisit.Dequeue();
            QuestStep     qs;
            if (_stepsDictionary.TryGetValue(questStepNode.stepId, out qs) && StepDone(qs.id))
            {
                questStepDone.Add(qs);
                foreach (QuestTreeNode child in questStepNode.children)
                {
                    toVisit.Enqueue(child);
                }
            }
        }
        return(questStepDone);
    }
Пример #6
0
    //-iterate through list first, adding all complete nodes
    //-iterate through again, adding branch names (from complete nodes) pointing to incomplete nodes
    private List <string> getQuestDisplayTree()
    {
        List <string> questStrList = new List <string>();

        foreach (QuestTreeNode node in treeNodeDictionary.Values)
        {
            if (globalFlags.checkFlag(node.content.flagName, "true", CompareType.Equal))
            {
                questStrList.Add("X-" + node.content.description);

                foreach (var branch in node.branchList)
                {
                    QuestTreeNode branchNode = (QuestTreeNode)getNode(branch.linkIndex);
                    if (!globalFlags.checkFlag(branchNode.content.flagName, "true", CompareType.Equal))
                    {
                        questStrList.Add("--" + branch.description);
                    }
                }
            }
        }
        return(questStrList);
    }
Пример #7
0
    //précondition: TreeTraversalFinished=false ; sinon,c'est que la quête est finie
    public void IncrementCurrent(string subStep, int value)
    {
        QuestStep currentStep = _stepsDictionary[_currentNode.stepId];

        currentStep.IncrementSubStep(subStep, value);

        if (currentStep.Validated())
        {
            currentStep.End();

            List <QuestTreeNode> availableNextNodes = new List <QuestTreeNode>();
            foreach (QuestTreeNode child in _currentNode.children)
            {
                QuestStep childStep = _stepsDictionary[child.stepId];

                if (childStep.EvaluateSpecs())
                {
                    availableNextNodes.Add(child);
                }
            }

            int availableNextNodesCount = availableNextNodes.Count;
            if (availableNextNodesCount > 0)
            {
                _stepsDone.Add(currentStep.id);
                _currentNode = availableNextNodes[Random.Range(0, availableNextNodesCount)];

                QuestStep newCurrent = _stepsDictionary[_currentNode.stepId];
                newCurrent.Begin();
                //TODO un event quelconque pour indiquer le passage à la QuestStep suivante
            }
            else
            {
                treeTraversalFinished = true;
            }
        }
    }
Пример #8
0
    private static ITreeNode getTreeNodeFromDataStr(string nodeDataStr, TreeType treeType)
    {
        var dataList = ParseHelper.getSplitList(nodeDataStr, Environment.NewLine);

        ITreeNode node = null;

        switch (treeType)
        {
        case TreeType.World:

            var worldTreeNode = new WorldTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (WorldNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = worldTreeNode;
            break;

        case TreeType.Zone:
            var zoneTreeNode = new ZoneTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (ZoneNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = zoneTreeNode;
            break;

        case TreeType.Dialog:
            var dialogTreeNode = new DialogTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (DialogNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = dialogTreeNode;
            break;

        case TreeType.Quest:
            var questTreeNode = new QuestTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (QuestNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = questTreeNode;
            break;

        case TreeType.Battle:
            var battleTreeNode = new BattleTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (BattleNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = battleTreeNode;
            break;

        case TreeType.Info:
            var infoTreeNode = new InfoTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (InfoNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = infoTreeNode;
            break;

        case TreeType.Store:
            var storeTreeNode = new StoreTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (StoreNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = storeTreeNode;
            break;

        case TreeType.Cutscene:
            var cutsceneTreeNode = new CutsceneTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (CutsceneNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
            node = cutsceneTreeNode;
            break;

        default: break;
        }

        if (dataList.Count > 3)
        {
            node.flagSetList = getFlagSetFromDataStr(dataList[3]);
        }
        if (dataList.Count > 4)
        {
            node.actionList = getTreeNodeActionListFromDataStr(dataList[4]);
        }

        return(node);
    }
Пример #9
0
    private static ITreeNode getTreeNodeFromDataStr(string nodeDataStr, TreeType treeType)
    {
        var dataList = ParseHelper.getSplitList(nodeDataStr, Environment.NewLine);

            ITreeNode node = null;
            switch(treeType)
            {
                case TreeType.World:

                    var worldTreeNode =  new WorldTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (WorldNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
                    node = worldTreeNode;
                    break;
                case TreeType.Zone:
                    var zoneTreeNode = new ZoneTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (ZoneNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
                    node = zoneTreeNode;
                    break;
                case TreeType.Dialog:
                    var dialogTreeNode = new DialogTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (DialogNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
                node = dialogTreeNode;
                    break;
                case TreeType.Quest:
                    var questTreeNode = new QuestTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (QuestNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
                    node = questTreeNode;
                    break;
                case TreeType.Battle:
                    var battleTreeNode = new BattleTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (BattleNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
                    node = battleTreeNode;
                    break;
                case TreeType.Info:
                     var infoTreeNode = new InfoTreeNode(Int64.Parse(dataList[0]), dataList[1], null, null, (InfoNodeContent)getTreeNodeContentFromStr(dataList[2], treeType));
                   node = infoTreeNode;
                    break;
                default: break;
            }

            if (dataList.Count > 3)
            {
                node.flagSetList = getFlagSetFromDataStr(dataList[3]);
            }
            if (dataList.Count > 4)
            {
                node.actionList = getTreeNodeActionListFromDataStr(dataList[4]);
            }

            return node;
    }