Exemple #1
0
        public bool ConnectNode(NodeEditor node)
        {
            if (node.MId == MId)
            {
                Debug.Log("不能连接自身》》》》》");
                return(false);
            }

            if (Json.ChildMaxCnt <= 0 || Json.ChildNodes.Count >= Json.ChildMaxCnt)
            {
                Debug.Log("节点数量不够》》》》》");
                return(false);
            }

            Json.ChildNodes.Add(node.Json);
            node.ParEditor = this;
            return(true);
        }
Exemple #2
0
        private void ShowCreateNodeMenu()
        {
            List <string> showStrs = new List <string>();

            //控制节点
            List <Type> controlTypes = LCReflect.GetClassByType <NodeControl>();

            for (int i = 0; i < controlTypes.Count; i++)
            {
                NodeAttribute nodeAttribute = LCReflect.GetTypeAttr <NodeAttribute>(controlTypes[i]);
                if (nodeAttribute != null)
                {
                    showStrs.Add("控制节点/" + nodeAttribute.ViewName);
                }
                else
                {
                    showStrs.Add("控制节点/" + controlTypes[i].FullName);
                }
            }

            //行为节点
            List <Type> actionTypes     = LCReflect.GetClassByType <NodeAction>();
            List <Type> actionShowTypes = new List <Type>();

            for (int i = 0; i < actionTypes.Count; i++)
            {
                NodeAttribute nodeAttribute = LCReflect.GetTypeAttr <NodeAttribute>(actionTypes[i]);
                if (nodeAttribute == null)
                {
                    showStrs.Add("基础行为节点/" + nodeAttribute.ViewName);
                    actionShowTypes.Add(actionTypes[i]);
                }
                else
                {
                    if (nodeAttribute.IsCommonAction)
                    {
                        showStrs.Add("基础行为/" + nodeAttribute.ViewName);
                        actionShowTypes.Add(actionTypes[i]);
                    }
                    else
                    {
                        if (ShowDec)
                        {
                            if (nodeAttribute.IsBevNode == false)
                            {
                                showStrs.Add("扩展行为/" + nodeAttribute.ViewName);
                                actionShowTypes.Add(actionTypes[i]);
                            }
                        }
                        else
                        {
                            if (nodeAttribute.IsBevNode)
                            {
                                showStrs.Add("扩展行为/" + nodeAttribute.ViewName);
                                actionShowTypes.Add(actionTypes[i]);
                            }
                        }
                    }
                }
            }

            EDPopMenu.CreatePopMenu(showStrs, (int index) =>
            {
                Debug.Log("创建节点》》》》》》》》》" + index + "  " + controlTypes.Count + "   >>" + actionShowTypes.Count);
                //创建控制
                if (index <= controlTypes.Count - 1)
                {
                    NodeDataJson node = CreateNodeJson(NodeType.Control, controlTypes[index].FullName, showStrs[index], curMousePos);
                    //创建显示
                    NodeEditor nodeEditor = new NodeEditor(new Rect(new Vector2((float)node.PosX, (float)node.PosY), new Vector2(200, 100)), node, null, NodeEventCallBack);
                    showNodeEditor.Add(nodeEditor);
                    GUI.changed = true;
                }
                //创建行为
                else
                {
                    Debug.Log("创建行为节点》》》》》》》》》" + (index - controlTypes.Count));
                    NodeDataJson node = CreateNodeJson(NodeType.Action, actionShowTypes[index - controlTypes.Count].FullName, showStrs[index], curMousePos);
                    //创建显示
                    NodeEditor nodeEditor = new NodeEditor(new Rect(new Vector2((float)node.PosX, (float)node.PosY), new Vector2(200, 100)), node, null, NodeEventCallBack);
                    showNodeEditor.Add(nodeEditor);
                    GUI.changed = true;
                }
            });
        }