public override void OnOpen()
    {
        base.OnOpen();

        foreach (JudgmentType type in System.Enum.GetValues(typeof(JudgmentType)))
        {
            var nodeName = type.ToString();
            var typeNode = Transform.Find(nodeName);
            if (!typeNode)
            {
                continue;
            }
            mJudgmentNode[type] = new TypeNodeInfo
            {
                HitCount = GetComponent <Text>(nodeName + "/HitCount"),
                Percent  = GetComponent <Text>(nodeName + "/Percent"),
            };
        }
        mMaxComboNode = new TypeNodeInfo
        {
            HitCount = GetComponent <Text>("MAXCOMBO/HitCount"),
            Percent  = GetComponent <Text>("MAXCOMBO/Percent"),
        };
        UpdateText(mCurrentGrade);
    }
示例#2
0
    private void DrawNode(Node node)
    {
        DrawCurve(node.BoundaryCurve);
        var bb = node.BoundingBox;

        var delta = graphToScreen.MultiplyVector((bb.RightBottom - bb.LeftTop).V3());

        delta.x = Mathf.Abs(delta.x);
        delta.y = Mathf.Abs(delta.y);

        TypeNodeInfo info = node.UserData as TypeNodeInfo;

        if (info == null)
        {
            return;
        }

        float ratio    = delta.x / info.baseSize.x;
        int   fontSize = (int)(TypeNodeInfo.baseFontSize * ratio);

        if (fontSize > 300)
        {
            fontSize = 300;
        }

        if (fontSize < 2)
        {
            return;
        }

        TypeNodeInfo.style.fontSize = fontSize;

        Vector3 left = 0.5f * (bb.LeftBottom.V3() + bb.LeftTop.V3());
        var     pos  = left + 0.5f * new Vector3(0, (float)bb.Height);

        Handles.Label(pos, node.UserData.ToString(), TypeNodeInfo.style);
    }
 void DrawTypeNode(TypeNodeInfo typeNode, int hitNumber, int hitPercentage)
 {
     typeNode.HitCount.text = BuildDrawNumber(hitNumber, 4);
     typeNode.Percent.text  = BuildDrawNumber(hitPercentage, 3) + "%";
 }
示例#4
0
    internal void CreateClassGraph()
    {
        graph = new GeometryGraph();

        var typeNodes = new Dictionary <string, Node>();


        ProcessTypeDelegate processType = type =>
        {
            //string typeNamespace = type.Namespace;
            //if (!string.IsNullOrEmpty(typeNamespace))
            //{
            //    if (typeNamespace.StartsWith("Unity")
            //    || typeNamespace.StartsWith("TMPro")
            //       || typeNamespace.StartsWith("TMPro")
            //    )
            //        return;
            //}

            char start = type.Name[0];
            if (start == '<' || start == '$')
            {
                return;
            }

            //if(!type.Name.Contains("Singleton"))
            //    return;

            TypeNodeInfo info = new TypeNodeInfo(type);

            var node = new Node(CurveFactory.CreateRectangle(info.baseSize.x,
                                                             info.baseSize.y, new Point()))
            {
                UserData = info
            };
            graph.Nodes.Add(node);

            Node doublonByNameToBeFixedOneDayIWillGiveAFuck;
            if (!typeNodes.TryGetValue(info.ToString(), out doublonByNameToBeFixedOneDayIWillGiveAFuck))
            {
                typeNodes.Add(info.ToString(), node);
            }
        };

        AssemblyScanner.Register(processType, AssemblyScanner.OnlyProject);
        AssemblyScanner.Scan();

        foreach (var kvp in typeNodes)
        {
            Node node     = kvp.Value;
            Type baseType = (node.UserData as TypeNodeInfo).type.BaseType;
            if (baseType == null)
            {
                continue;
            }

            string baseTypeName = GetTypeName(baseType);

            Node parentNode;
            if (typeNodes.TryGetValue(baseTypeName, out parentNode))
            {
                graph.Edges.Add(new Edge(node, parentNode));
            }
        }

        for (int i = graph.Nodes.Count; --i >= 0;)
        {
            if (graph.Nodes[i].Edges.Any())
            {
                continue;
            }
            graph.Nodes.RemoveAt(i);
        }
    }