Exemplo n.º 1
0
 private void Clear()
 {
     mDragNode   = null;
     mSelectNode = null;
     mEditorNode = null;
     mTempNode   = null;
 }
Exemplo n.º 2
0
    private void _DrawNodeLine(FArpgMachine.FArpgNode node, List <FArpgMachine.FArpgNode> overNode, bool isDrawLine = false)
    {
        if (overNode.Contains(node))
        {
            return;
        }
        overNode.Add(node);

        if (node.mSkipNode != null)
        {
            Handles.color = Color.red;
            DrawTowNode(node, node.mSkipNode);
        }

        for (int i = 0; i < node.mNextData.Count; i++)
        {
            if (isDrawLine)
            {
                Handles.color = node.mSkipNode == null ? Color.white : new Color(0.6f, 0.6f, 0.6f, 0.8f);
                DrawTowNode(node, node.mNextData[i]);
            }

            _DrawNodeLine(node.mNextData[i], overNode, true);
        }
    }
Exemplo n.º 3
0
    private void DrawTowNode(FArpgMachine.FArpgNode start, FArpgMachine.FArpgNode end)
    {
        float   width    = 2;
        var     nextNode = end;
        Vector2 offse    = Vector2.zero;

        if (nextNode.mNextData.Contains(start))
        {
            Vector2 tempDir = start.mRect.center - nextNode.mRect.center;
            tempDir.Normalize();
            tempDir = Quaternion.Euler(0, 0, 90) * tempDir;
            offse  += tempDir * 10;
        }

        Vector2 startPoint = start.mRect.center + offse;
        Vector2 endPoint   = nextNode.mRect.center + offse;

        //画线
        Handles.DrawAAPolyLine(width, startPoint, endPoint);
        //画小三角
        Vector3 dir = startPoint - endPoint;

        dir.Normalize();
        Vector2[] buffs       = new Vector2[2];
        float     des         = Vector2.Distance(startPoint, endPoint) / 2;
        Vector3   tempVector3 = startPoint;

        tempVector3 -= dir * des;
        buffs[0]     = tempVector3 + Quaternion.Euler(0, 0, 45) * dir * 10;
        buffs[1]     = tempVector3 + Quaternion.Euler(0, 0, -45) * dir * 10;
        Handles.DrawAAPolyLine(width, buffs[0], tempVector3, buffs[1]);
    }
Exemplo n.º 4
0
    private void LoadFile(string path)
    {
        mAutoPath = path;
        Clear();
        string tempPath = "." + ResConfig.ARPGEX;

        if (!path.EndsWith(tempPath))
        {
            path += tempPath;
        }
        var config = mFArpgMachine.LoadFile(path, FFilePath.FP_Abs);
        var ass    = Assembly.Load("Assembly-CSharp");

        System.Type type = ass.GetType(config);
        mCurSelectType = type;//mStateType[config.type];
        mHeadNode      = mFArpgMachine.GetCurNode();
    }
Exemplo n.º 5
0
    private void DrawNode()
    {
        var root = mFArpgMachine.GetRoots();
        //画线
        List <FArpgMachine.FArpgNode> overNode = new List <FArpgMachine.FArpgNode>();
        Color lastColor = Handles.color;

        Handles.color = Color.white;
        _DrawNodeLine(root, overNode, false);
        Handles.color = lastColor;


        //画节点
        Color oldColor = GUI.backgroundColor;

        foreach (var k in root.mMainBuffs)
        {
            var node = k.Value;
            GUI.backgroundColor = new Color(1, 0, 0, 1);
            if (mHeadNode == null)
            {
                mHeadNode = node;
            }

            if (mHeadNode == node)
            {
                GUI.backgroundColor = new Color(0, 1, 0, 1);
            }

            if (GUI.Button(node.mRect, k.Key))
            {
                mEditorNode = node;
                mTempNode   = new FArpgMachine.FArpgNode(null, mFArpgMachine);
                mTempNode.mFArgpBaseData = node.mFArgpBaseData.GetCloneInistane();
            }
        }
        GUI.backgroundColor = oldColor;
    }
Exemplo n.º 6
0
    private void SelectOperation()
    {
        //Debug.LogError(mCurEventType+"---------"+mSelectNode);
        //右键菜单
        if (mCurEventType == EventType.MouseDown && mEventButton == 1)
        {
            var mousePos   = mEvent.mousePosition;
            var selectNode = GetNode(mousePos);
            if (selectNode != null)
            {
                mSelectNode = selectNode;
            }
            else
            {
                if (mScreenRect.Contains(mousePos))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(new GUIContent("添加节点"), false, CreateNode, mousePos);
                    menu.ShowAsContext();
                }
            }
        }
        else if (mCurEventType == EventType.MouseUp && mEventButton == 1)
        {
            if (mSelectNode != null)
            {
                var tempNode = GetNode(mEvent.mousePosition);
                if (tempNode != mSelectNode)
                {
                    if (mEvent.shift)
                    {
                        if (mSelectNode.mSkipNode == tempNode)
                        {
                            mSelectNode.mSkipNode = null;
                        }
                        else
                        {
                            mSelectNode.mSkipNode = tempNode;
                        }
                    }
                    else
                    {
                        mSelectNode.Regs(tempNode, true);
                    }
                }
                mSelectNode = null;
            }
        }
        else if (mSelectNode != null)
        {
            Color lastColor = Handles.color;
            Handles.color = mEvent.shift?Color.red:Color.green;
            Handles.DrawAAPolyLine(5, mSelectNode.mRect.center, mEvent.mousePosition);
            Handles.color = lastColor;
        }


        //左键键按下
        if (mCurEventType == EventType.MouseDown && mEventButton == 0)
        {
            if (GUIUtility.keyboardControl != 0)
            {
                KeepNode();
            }
            GUIUtility.keyboardControl = 0;
            mDragNode = GetNode(mEvent.mousePosition);
        }
        else if (mDragNode != null && mCurEventType == EventType.MouseDrag)
        {
            mDragNode.mRect.center += mEvent.delta;
            mDragLen += Vector2.Distance(Vector2.zero, mEvent.delta);
        }
        else if (mCurEventType == EventType.MouseUp && mEventButton == 0)
        {
            if (mDragLen > 0.3f)
            {
                Event.current.Use();
            }
            mDragLen  = 0;
            mDragNode = null;
        }

        //按键操作

        //删除节点操作
        if (mKeyCode == KeyCode.Delete)
        {
            if (mEditorNode != null)
            {
                mFArpgMachine.RemoveNode(mEditorNode);
                if (mHeadNode == mEditorNode)
                {
                    mHeadNode = null;
                }
                Clear();
                Repaint();
            }
        }
        else if (mKeyCode == KeyCode.S)
        {
            if (mEditorNode != null)
            {
                mHeadNode = mEditorNode;
                Repaint();
            }
        }

        //按钮

        if (GUI.Button(new Rect(mScreenRect.width - 100, 0, 100, 20), "另存文件"))
        {
            string path = MyEdior.SaveFilePanel(ResConfig.ARPGEX);
            if (path == "")
            {
                return;
            }
            mAutoPath = path;
            KeepFile(path);
        }


        if (GUI.Button(new Rect(mScreenRect.width - 100, 22, 100, 20), "读取文件"))
        {
            string path = MyEdior.OpenFilePanel(ResConfig.ARPGEX);
            if (path == "")
            {
                return;
            }
            LoadFile(path);
        }

        if (mAutoPath != "")
        {
            if (GUI.Button(new Rect(mScreenRect.width - 100, 44, 100, 20), "保存文件"))
            {
                KeepFile(mAutoPath);
            }
        }
    }