Esempio n. 1
0
        public bool CopyChild(NodeParam newRoot, NodeParam target)
        {
            NodeParam        rootParent = newRoot.Parent;
            NodeClassifyType rootType   = newRoot.NodeClassType;

            if (rootType == NodeClassifyType.Action || rootType == NodeClassifyType.Condition || rootType == NodeClassifyType.DataTransform)
            {
                return(false);
            }
            while (rootParent != null)
            {
                if (rootParent == target)
                {
                    return(false);
                }
                rootParent = rootParent.Parent;
            }

            NodeParam newNode = NodeParamClone(target);

            newNode.SetParent(newRoot);
            InitNodeOutputAvailable();

            return(true);
        }
Esempio n. 2
0
        ///菜单相关
        public void PopMenu()
        {
            var menu = new GenericMenu();

            menu.AddItem(new GUIContent("创建子节点"), false, this.PopUpCreate);
            menu.AddItem(new GUIContent("替换当前节点"), false, this.PopUpReplace);
            string selectNodeName = BehaviorManager.GetInstance().selectNodeName;
            string selectNodeType = BehaviorManager.GetInstance().selectNodeType;

            if (mSelectedNode != null && selectNodeName != "")
            {
                if (selectNodeType != NodeClassifyType.Root.ToString() && mSelectedNode.NodeData.Children.Count < mSelectedNode.NodeData.Proto.child_limit)
                {
                    menu.AddItem(new GUIContent(string.Format($"新建{selectNodeName}")), false, this.CreateNode);
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("新建"));
                }
                if (mSelectedNode.NodeData.Proto.classify == NodeClassifyType.Root.ToString())
                {
                    string menuName = string.Format($"替换成{selectNodeName}");
                    if (selectNodeType == NodeClassifyType.Root.ToString())
                    {
                        menu.AddItem(new GUIContent(menuName), false, this.ChangeNodeType);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent(menuName));
                    }
                }
                else
                {
                    string           menuName = string.Format($"替换成{selectNodeName}");
                    NodeClassifyType value    = (NodeClassifyType)Enum.Parse(typeof(NodeClassifyType), selectNodeType);
                    int count = ExportNodeTypeConfig.NodeTypeCountDict[value];
                    if (selectNodeType == NodeClassifyType.Root.ToString() || (count == 0 && mSelectedNode.NodeData.Proto.child_limit > 0))
                    {
                        menu.AddDisabledItem(new GUIContent(menuName));
                    }
                    else
                    {
                        menu.AddItem(new GUIContent(menuName), false, this.ChangeNodeType);
                    }
                }
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("新建"));
                menu.AddDisabledItem(new GUIContent("替换"));
            }
            menu.AddItem(new GUIContent("自动排序"), false, this.AutoSort);
            menu.AddItem(new GUIContent("复制"), false, this.CopyNode);
            menu.AddItem(new GUIContent("剪切"), false, this.CutNode);
            menu.AddItem(new GUIContent("粘贴"), false, this.PasteNode);
            menu.AddItem(new GUIContent("删除节点"), false, this.RemoveNode);
            menu.ShowAsContext();
        }
Esempio n. 3
0
        public void Replace(NodeParam newParam)
        {
            TypeDesc      = newParam.TypeDesc;
            NodeType      = newParam.NodeType;
            NodeClassType = newParam.NodeClassType;

            Fields.Clear();
            foreach (ParamInfo info in newParam.Fields)
            {
                Fields.Add(info.Clone());
            }

            Inputs.Clear();
            foreach (ParamInfoInput input in newParam.Inputs)
            {
                Inputs.Add(input.Clone());
            }

            Outputs.Clear();
            foreach (ParamInfoOutput output in newParam.Outputs)
            {
                Outputs.Add(output.Clone(this));
            }
        }
Esempio n. 4
0
 public NodeAttribute(NodeClassifyType classifyType, string desc = "")
 {
     this.ClassifytType = classifyType;
     this.Desc          = desc;
 }
Esempio n. 5
0
        private void CanvasRightClick(BeTreeNode e, bool isAdd)
        {
            RunTimeNodeData  data         = _datas[e.SrcTreeID];
            List <NodeParam> allParam     = NodeInfoManager.GetAllParam(data.IsClient);
            NodeParam        srcNodeParam = data[e.NodeID];
            NodeClassifyType classfiy     = srcNodeParam.NodeClassType;
            List <NodeParam> ps           = new List <NodeParam>();

            foreach (NodeParam param in allParam)
            {
                switch (classfiy)
                {
                case NodeClassifyType.Action:
                case NodeClassifyType.Condition:
                case NodeClassifyType.DataTransform:
                case NodeClassifyType.Error:
                    if (!isAdd)
                    {
                        if (param.NodeClassType != NodeClassifyType.Root)
                        {
                            ps.Add(param);
                        }
                    }
                    break;

                case NodeClassifyType.Composite:
                case NodeClassifyType.Decorator:
                    if (!isAdd)
                    {
                        if (param.NodeClassType == NodeClassifyType.Decorator || param.NodeClassType == NodeClassifyType.Composite)
                        {
                            ps.Add(param);
                        }
                    }
                    else
                    {
                        if (param.NodeClassType != NodeClassifyType.Root)
                        {
                            ps.Add(param);
                        }
                    }
                    break;

                case NodeClassifyType.Root:
                    if (isAdd)
                    {
                        if (param.NodeClassType != NodeClassifyType.Root)
                        {
                            ps.Add(param);
                        }
                    }
                    else
                    {
                        if (param.NodeClassType == NodeClassifyType.Root)
                        {
                            ps.Add(param);
                        }
                    }
                    break;
                }
            }

            _curOpenningCtrl.Canvas.ShowAddNodePanel(e, ps.ToArray(), isAdd);
        }