예제 #1
0
        private void NodeMakeTransition(SkillHsmConfigNodeData currentNode)
        {
            Event _event = Event.current;

            mousePosition = _event.mousePosition;

            if (_event.type == EventType.MouseDown)
            {
                if (_event.button == 0)  // 鼠标左键
                {
                    if (makeTransitionMode)
                    {
                        SkillHsmConfigNodeData nodeValue = GetMouseInNode(_nodeList);
                        // 如果按下鼠标时,选中了一个节点,则将 新选中根节点 添加为 selectNode 的子节点
                        bool nodeTypeValid = CheckTranshtion(currentNode, nodeValue);
                        if (null != nodeValue && currentNode.Id != nodeValue.Id && nodeTypeValid)
                        {
                            if (null != HSMManager.hSMNodeChangeTransition)
                            {
                                HSMManager.hSMNodeChangeTransition(currentNode.Id, nodeValue.Id, true);
                            }
                        }

                        // 取消连线状态
                        makeTransitionMode = false;
                    }
                    else
                    {
                        SkillHsmConfigNodeData nodeValue = GetMouseInNode(_nodeList);
                        if ((null != nodeValue))
                        {
                            ClickNode(nodeValue);
                        }
                    }
                }

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

            if (makeTransitionMode && currentNode != null)
            {
                SkillHsmConfigRectT mouseRect = new SkillHsmConfigRectT();
                mouseRect.X      = mousePosition.x;
                mouseRect.Y      = mousePosition.y;
                mouseRect.Width  = 10;
                mouseRect.Height = 10;

                DrawNodeCurve(currentNode.Position, mouseRect, Color.black);
            }
        }
예제 #2
0
        // 绘制线
        public static void DrawNodeCurve(SkillHsmConfigRectT start, SkillHsmConfigRectT end, Color color)
        {
            Vector3 startPos = Vector3.zero;
            Vector3 endPos   = Vector3.zero;
            Vector3 middle   = (startPos + endPos) * 0.5f;

            Handles.color = Color.white;
            CalculateTranstion(start, end, ref startPos, ref endPos);
            DrawArrow(startPos, endPos, color);
        }
예제 #3
0
        public static SkillHsmConfigRectT RectToRectT(Rect rect)
        {
            SkillHsmConfigRectT rectT = new SkillHsmConfigRectT();

            rectT.X      = rect.x;
            rectT.Y      = rect.y;
            rectT.Width  = rect.width;
            rectT.Height = rect.height;

            return(rectT);
        }
예제 #4
0
        private static void CalculateTranstion(SkillHsmConfigRectT start, SkillHsmConfigRectT end, ref Vector3 startPoint, ref Vector3 endPoint)
        {
            Vector3 startCenter = Vector3.zero;
            Vector3 endCenter   = Vector3.zero;

            CalculateTransitionPoint(start, end, ref startCenter, ref endCenter);

            Vector3 axis = Vector3.Cross((endCenter - startCenter), new Vector3(0, 0, 1)).normalized;

            startPoint = startCenter + 10 * axis;
            endPoint   = endCenter + 10 * axis;

            GUI.Box(new Rect(startPoint, Vector2.one * 10), "1");
            GUI.Box(new Rect(endPoint, Vector2.one * 10), "1");
        }
예제 #5
0
 public static Rect RectTToRect(SkillHsmConfigRectT rectT)
 {
     return(new Rect(rectT.X, rectT.Y, rectT.Width, rectT.Height));
 }
예제 #6
0
 private static void CalculateTransitionPoint(SkillHsmConfigRectT start, SkillHsmConfigRectT end, ref Vector3 startCenter, ref Vector3 endCenter)
 {
     startCenter = new Vector3(start.X + start.Width * coefficient, start.Y + start.Height * coefficient);
     endCenter   = new Vector3(end.X + end.Width * coefficient, end.Y + end.Height * coefficient);
 }