Пример #1
0
    public static Dictionary <long, InfoTreeNode> getInfoTreeNodeFromList(List <ITreeNode> treeNodeList)
    {
        Dictionary <long, InfoTreeNode> treeNodeDict = new Dictionary <long, InfoTreeNode>();

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

        return(treeNodeDict);
    }
    public void UpdateInfo(GameDataObject gameObject, InfoTree infoTree)
    {
        if (infoTree != null)
        {
            InfoTreeNode infoNode = (InfoTreeNode)infoTree.getNode(infoTree.currentIndex);
            infoNode.SelectNode(infoTree);
            UIHelper.UpdateTextComponent(TreeInfoPanel, "TreeInfoTitle", infoNode.content.nodeName);
            UIHelper.UpdateTextComponent(TreeInfoPanel, "TreeInfoText", infoNode.content.text);

            gameObject.runActions(infoNode.actionList);
        }
    }
Пример #3
0
        private static void Prune(InfoTreeNode node, uint frequencyThreshold)
        {
            if (node.Children == null || node.Children.Count == 0)
            {
                return;
            }
            var children = node.Children.ToList();

            node.Children.Clear();
            foreach (var child in children)
            {
                if (child.Value < frequencyThreshold)
                {
                    continue;
                }
                node.Children.Add(child);
                Prune(child, frequencyThreshold);
            }
        }
Пример #4
0
        private static void AddProgram(ITreeNode program, InfoTreeNode node, InfoTreeNode rootNode)
        {
            if (program == null)
            {
                return;
            }
            node.Value++;

            if (program.Children == null)
            {
                return;
            }
            for (var i = 0; i < program.Children.Count; i++)
            {
                if (i >= node.Children.Count)
                {
                    node.Children.Add(new InfoTreeNode(rootNode));
                }
                AddProgram(program.Children[i], node.Children[i], rootNode);
            }
        }
Пример #5
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);
    }
Пример #6
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;
    }
Пример #7
0
 /// <summary>
 ///     Creates a new <see cref="InfoTreeNode" /> with the given root node.
 /// </summary>
 /// <param name="rootNode">The root node of the tree that this node belongs to.</param>
 public InfoTreeNode(InfoTreeNode rootNode)
 {
     this.RootNode = rootNode;
     this.Children = new List <InfoTreeNode>();
 }
Пример #8
0
        private static uint GetNodeCount(InfoTreeNode node)
        {
            var sum = node.Value + node.Children?.Sum(child => GetNodeCount(child));

            return((uint)(sum ?? 0));
        }