Exemple #1
0
        private void NodeMakeTransition(NodeValue currentNode, List <NodeValue> nodeList)
        {
            Event _event = Event.current;

            mousePosition = _event.mousePosition;

            if (_event.type == EventType.MouseDown)
            {
                if (_event.button == 0)  // 鼠标左键
                {
                    if (makeTransitionMode)
                    {
                        NodeValue nodeValue = GetMouseInNode(nodeList);
                        // 如果按下鼠标时,选中了一个节点,则将 新选中根节点 添加为 selectNode 的子节点
                        if (null != nodeValue && currentNode.id != nodeValue.id)
                        {
                            DataNodeHandler dataNodeHandler = new DataNodeHandler();
                            dataNodeHandler.NodeAddChild(currentNode.id, nodeValue.id);
                        }

                        // 取消连线状态
                        makeTransitionMode = false;
                    }
                    else
                    {
                        NodeValue nodeValue = GetMouseInNode(nodeList);
                        ClickNode(nodeValue);
                    }
                }

                if (_event.button == 1)  // 鼠标右键
                {
                    if ((!makeTransitionMode))
                    {
                        NodeValue nodeValue = GetMouseInNode(nodeList);
                        ShowMenu(currentNode, nodeValue);
                    }
                }
            }

            if (makeTransitionMode && currentNode != null)
            {
                RectT mouseRect = new RectT(mousePosition.x, mousePosition.y, 10, 10);
                DrawNodeCurve(currentNode.position, mouseRect);
            }
        }
Exemple #2
0
        public void ChangeSubTreeEntryNode(int subTreeNodeId, int nodeId)
        {
            NodeValue nodeValue = BehaviorDataController.Instance.GetNode(nodeId);

            if (null == nodeValue)
            {
                return;
            }

            NodeValue subTreeNode = BehaviorDataController.Instance.GetNode(subTreeNodeId);

            if (null == subTreeNode)
            {
                return;
            }

            List <NodeValue> nodeList = BehaviorDataController.Instance.NodeList;

            for (int i = 0; i < nodeList.Count; ++i)
            {
                if (nodeList[i].parentSubTreeNodeId == nodeValue.parentSubTreeNodeId)
                {
                    if (nodeList[i].subTreeEntry)
                    {
                        RemoveParentNode(nodeList[i].id);
                    }

                    nodeList[i].subTreeEntry = (nodeList[i].id == nodeId);
                    if (nodeList[i].subTreeEntry)
                    {
                        subTreeNode.childNodeList.Clear();
                        subTreeNode.childNodeList.Add(nodeId);
                    }
                }
            }

            DataNodeHandler dataNodeHandler = new DataNodeHandler();

            dataNodeHandler.NodeAddChild(subTreeNodeId, nodeValue.id);
        }