private void DeleteNodes()
 {
     for (int i = this.m_nodeList.Count - 1; i >= 0; --i)
     {
         if (this.m_nodeList[i].IsClick)
         {
             DataTreeEditCtr.RemoveLineByNode(this.m_nodeList[i].Idx);
             this.m_nodeList.Remove(this.m_nodeList[i]);
         }
     }
 }
    private void ClearEditTreeData()
    {
        this.m_idx            = -1;
        this.m_configNodeData = null;

        for (int i = this.m_nodeList.Count - 1; i >= 0; --i)
        {
            DataTreeEditCtr.RemoveLineByNode(this.m_nodeList[i].Idx);
            this.m_nodeList.Remove(this.m_nodeList[i]);
        }
        DataTreeEditCtr.ClearAllData();
    }
    private bool MouseZoom()
    {
        Vector2 vector;

        if (!this.GetMousePositionInGraph(out vector))
        {
            return(false);
        }
        float num = -Event.current.delta.y / 150f;

        this.mGraphZoom += num;
        this.mGraphZoom  = Mathf.Clamp(this.mGraphZoom, 0.4f, 1f);
        Vector2 vector2;

        this.GetMousePositionInGraph(out vector2);
        this.mGraphOffset         += vector2 - vector;
        this.mGraphScrollPosition += vector2 - vector;
        DataTreeEditCtr.AdjustNodeList(this.m_nodeList, (vector2 - vector), this.mGraphZoom);
        return(true);
    }
示例#4
0
    public virtual void Show(Vector2 vector, bool flag = false)
    {
        if (flag)
        {
            AdjustNode(vector, 1);

            if (GUI.Button(new Rect(this.m_posUp, this.m_btnSize), "", m_buttonDownStyle))
            {
                Node node = new Node();
                node.state = NodeState.In;
                node.idx   = this.m_idx;
                DataTreeEditCtr.AddNode(node);
            }
            if (GUI.Button(new Rect(this.m_posDown, this.m_btnSize), "", m_buttonDownStyle))
            {
                Node node = new Node();
                node.state = NodeState.Out;
                node.idx   = this.m_idx;
                DataTreeEditCtr.AddNode(node);
            }
        }
        this.HandleEvents();
    }
    private void ExportToFile()
    {
        if (!Directory.Exists(outputPath))
        {
            Directory.CreateDirectory(outputPath);
        }

        string path = outputPath + this.mName + "Tree.txt";

        if (this.mName.Contains("Tree"))
        {
            path = outputPath + this.mName + ".txt";
        }
        using (FileStream stream = File.Open(path, FileMode.OpenOrCreate, FileAccess.Write))
        {
            stream.SetLength(0);

            byte[] bys = System.Text.Encoding.UTF8.GetBytes(DataTreeEditCtr.GenTreeInfos());
            stream.Write(bys, 0, bys.Length);
            stream.Close();

            EditorUtility.DisplayDialog("提示", "数据导出完毕!", "确定");
        }
    }
    public void InitData(string name)
    {
        this.mName       = name;
        this.m_init      = false;
        this.m_selectKey = -1;
        this.m_idx       = -1;
        this.m_conDic.Clear();
        this.m_conList.Clear();
        this.m_nodeList.Clear();
        DataTreeEditCtr.ClearAllData();

        if (this.graphBackgroundGUIStyle == null)
        {
            this.InitGraphBackgroundGUIStyle();
        }

        if (this.mGridMaterial == null)
        {
            this.mGridMaterial                  = new Material(Shader.Find("Hidden/Behavior Designer/Grid"));
            this.mGridMaterial.hideFlags        = HideFlags.HideAndDontSave;
            this.mGridMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
        }

        if (this.mLineMaterial == null)
        {
            this.mLineMaterial                  = new Material(Shader.Find("DataTreeEditor/Line"));
            this.mLineMaterial.hideFlags        = HideFlags.HideAndDontSave;
            this.mLineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
        }

        if (name.Equals("Config") || name.Equals("ConfigTree"))
        {
            if (this.m_configDataList == null)
            {
                this.m_configDataList = new List <ConfigData>();
            }
            else
            {
                this.m_configDataList.Clear();
            }
            DataTreeEditTool.LoadCsv_List <ConfigData>("Config", this.m_configDataList);

            this.m_init = true;

            this.m_conDic.Add(-1, true);
            for (int i = 0; i < this.m_configDataList.Count; ++i)
            {
                if (!this.m_conDic.ContainsKey(this.m_configDataList[i].GetconfigDataCondition()))
                {
                    this.m_conDic.Add(this.m_configDataList[i].GetconfigDataCondition(), false);
                }
            }

            this.m_conList = new List <int>(this.m_conDic.Keys);

            if (name.Equals("ConfigTree"))
            {
                this.LoadFileData();
            }
        }
    }
    private void GenTankTree()
    {
        for (int i = 0; i < this.m_treeList.Count; ++i)
        {
            Queue <TreeNode> queue = this.m_treeList[i];
            int level = 0;
            while (queue.Count > 0)
            {
                List <TreeNode> nodeList = new List <TreeNode>();
                while (queue.Count > 0)
                {
                    TreeNode node = queue.Dequeue();
                    bool     flag = true;
                    for (int j = 0; j < nodeList.Count; ++j)
                    {
                        if (nodeList[j].idx == node.idx)
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        nodeList.Add(node);
                    }
                }
                for (int j = 0; j < nodeList.Count; ++j)
                {
                    TreeNode treeNode = nodeList[j];

                    if (!this.CheckNodeUsed(treeNode.idx))
                    {
                        ConfigNodeData dataNode = new ConfigNodeData(this.GetConfigDataByIdx(treeNode.idx), new Vector2(500 + (j - (nodeList.Count - 1) / 2.0f) * 200, 300 + level * 200));
                        this.m_nodeList.Add(dataNode);
                    }

                    for (int k = 0; k < treeNode.childList.Count; ++k)
                    {
                        TreeNode tNode = new TreeNode();
                        tNode.idx = treeNode.childList[k];

                        if (this.m_nodeDic.ContainsKey(treeNode.childList[k]))
                        {
                            tNode.childList = this.m_nodeDic[treeNode.childList[k]];
                        }
                        else
                        {
                            tNode.childList = new List <int>();
                        }

                        queue.Enqueue(tNode);

                        Node inNode = new Node();
                        inNode.state = NodeState.In;
                        inNode.idx   = treeNode.childList[k];

                        Node outNode = new Node();
                        outNode.state = NodeState.Out;
                        outNode.idx   = treeNode.idx;

                        DataTreeEditCtr.AddNode(inNode);
                        DataTreeEditCtr.AddNode(outNode);
                    }
                }

                ++level;
            }
        }
    }