示例#1
0
 public void CutNode()
 {
     mCopyNode = null;
     mCutNode  = mSelectedNode;
     if (mSelectedNode != null)
     {
         BehaviorTreeTipsHelper.ShowMessage("剪切节点" + mSelectedNode.NodeData.Id);
     }
 }
示例#2
0
 public void SaveAll()
 {
     if (!CheckHasTreeDesc())
     {
         return;
     }
     if (!CheckSatisfyInput())
     {
         return;
     }
     SavePrefabTree();
     Log.Info("保存成功!");
     BehaviorTreeTipsHelper.ShowMessage("保存成功!");
 }
示例#3
0
        public void HandleEvents()
        {
            Event e = Event.current;

            switch (e.type)
            {
            case EventType.MouseDown:
                GUI.FocusControl("");
                mMousePos = e.mousePosition;
                if (!BTEditorWindow.windowRect.Contains(mMousePos))
                {
                    BTEditorWindow.Instance.CloseSubWin();
                }
                if (BTEditorWindow.windowRect.Contains(mMousePos) && BTEditorWindow.IsShowSubWin)
                {
                    break;
                }
                //单击选中
                if (e.button == 0)
                {
                    CheckMouseInNode();
                }
                //双击折叠
                if (e.button == 0 && e.clickCount == 2 && mState != State.ConnectLeft && mState != State.ConnectRight)
                {
                    mSelectedNode?.Fold();
                    CalcGraphRect();
                }
                //右键
                if (e.button == 1)
                {
                    //取消选中
                    mSelectedNode?.onSelect(false);
                    mSelectedNode = null;
                    //重新选中
                    CheckMouseInNode();

                    //右键菜单
                    PopMenu();
                }
                if (e.button == 0 && e.mousePosition.x < mLeftWidth + 30 && e.mousePosition.x > mLeftWidth)
                {
                    mDragingLeftBorder = true;
                }
                if (e.button == 0 && e.mousePosition.x < mLeftWidth + mBorderRect.width && e.mousePosition.x > mLeftWidth + mBorderRect.width - 30)
                {
                    mDragingRightBorder = true;
                }

                break;

            case EventType.MouseUp:
                if (BTEditorWindow.windowRect.Contains(mMousePos) && BTEditorWindow.IsShowSubWin)
                {
                    break;
                }
                if (e.button == 0 && e.shift)
                {
                    mSelectedNode.Offset = mSrcOffset;
                    mSelectedNode.Parent.AutoSort();
                    CheckMouseInNode();
                }
                if (e.button == 0)
                {
                    CheckMouseInNode();
                }
                mState              = State.Normal;
                mDragingLeftBorder  = false;
                mDragingRightBorder = false;
                break;

            case EventType.MouseDrag:
                //中键
                if (e.button == 2 || (e.button == 0 && e.alt))
                {
                    mScrollPosition.x -= e.delta.x;
                    mScrollPosition.y -= e.delta.y;
                    mState             = State.Normal;
                    return;
                }
                if (e.button == 0 && e.shift)
                {
                    if (mSelectedNode != null)
                    {
                        mSrcOffset = mSelectedNode.Offset;
                        mSelectedNode.onDrag(e.delta);
                        mState = State.Shift;
                    }

                    return;
                }
                if (e.button == 0 && e.control)
                {
                    if (mSelectedNode != null)
                    {
                        mSrcOffset = mSelectedNode.Offset;
                        mSelectedNode.onDrag(e.delta);
                        mState = State.Ctrl;
                    }
                    return;
                }
                if (mDragingLeftBorder)
                {
                    mLeftWidth += e.delta.x;
                    return;
                }
                if (mDragingRightBorder)
                {
                    mRightWidth -= e.delta.x;
                    Game.EventSystem.Run(EventIdType.BehaviorTreeRightDesignerDrag, e.delta.x);
                    return;
                }

                //左键
                if (e.button == 0 && (e.control || !mLock))
                {
                    if (mSelectedNode != null)
                    {
                        mSelectedNode.onDrag(e.delta);
                        mState = State.Drag;
                        DrawMouseIcon("DragIcon");
                    }
                }
                break;

            case EventType.KeyUp:
                //F1自动排序
                if (e.keyCode == KeyCode.F1)
                {
                    RootNode?.AutoSort();
                    RootNode.UpdateChildren();
                }
                if (e.keyCode == KeyCode.F2)
                {
                    mLock = !mLock;
                    if (mLock)
                    {
                        BehaviorTreeTipsHelper.ShowMessage("节点位置已锁定");
                    }
                    else
                    {
                        BehaviorTreeTipsHelper.ShowMessage("节点位置已解锁");
                    }
                }
                if (e.keyCode == KeyCode.Delete)
                {
                    RemoveNode();
                }
                break;

            case EventType.MouseMove:
                DrawMouseIcon("DragIcon2");
                break;
            }
        }