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

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

        return(treeNodeDict);
    }
Пример #2
0
    private void setNavigation()
    {
        clearNavigationNodes();

        WorldTreeNode currentNode = (WorldTreeNode)worldTree.getNode(worldTree.currentIndex);

        var worldNode = createNodeButton(currentNode);

        worldNodeList.Add(worldNode);

        foreach (var branch in currentNode.getBranchList(worldTree))
        {
            worldNode = createNodeButton((WorldTreeNode)worldTree.getNode(branch.linkIndex));
            worldNodeList.Add(worldNode);
        }
    }
Пример #3
0
    //clicking an icon on the map
    public void ClickZoneDetail(long index)
    {
        worldTree.SelectNode(index);

        WorldTreeNode clickedNode = (WorldTreeNode)worldTree.getNode(index);

        var text = detailZoneName.GetComponent <Text>();

        text.text = clickedNode.content.zoneName;

        var detail = detailZoneDescription.GetComponent <Text>();

        detail.text = clickedNode.content.description;

        var butt = detailZoneButton.GetComponent <Button>();

        butt.onClick.AddListener(() => ClickEnterZoneButton(clickedNode.content.linkIndex));

        setNavigation();
    }
Пример #4
0
    private GameObject createNodeButton(WorldTreeNode node)
    {
        GameObject worldNodeButton = (GameObject)Instantiate(worldButtonPrefab);

        worldNodeButton.transform.SetParent(uiCanvas.transform, false);

        int index = worldNodeButton.transform.GetSiblingIndex();

        worldNodeButton.transform.SetSiblingIndex(index - 3); //move before other menus in heirarchy

        var rect = worldNodeButton.GetComponent <RectTransform>();

        rect.anchoredPosition = new Vector3(node.content.x, node.content.y);

        var worldNodeButtonButt = worldNodeButton.GetComponent <Button>();

        worldNodeButtonButt.onClick.AddListener(() => ClickZoneDetail(node.index));

        return(worldNodeButton);
    }
Пример #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
    private GameObject createNodeButton(WorldTreeNode node)
    {
        GameObject worldNodeButton = (GameObject)Instantiate(worldButtonPrefab);
        worldNodeButton.transform.SetParent(uiCanvas.transform, false);

        int index = worldNodeButton.transform.GetSiblingIndex();
        worldNodeButton.transform.SetSiblingIndex(index - 3); //move before other menus in heirarchy

        var rect = worldNodeButton.GetComponent<RectTransform>();
        rect.anchoredPosition = new Vector3(node.content.x, node.content.y);
  
        var worldNodeButtonButt = worldNodeButton.GetComponent<Button>();
        worldNodeButtonButt.onClick.AddListener(() => ClickZoneDetail(node.index));

        return worldNodeButton;
    }