Ejemplo n.º 1
0
    public BarSeries(string label, int score, DynamicRect rect, Color color)        //param 2: List<float> values
    {
        this.label = label;
        //this.values = values;
        this.score = score;
        this.rect  = rect;
        this.color = color;

        this.colorHex = Functions.ColorToHex(color);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新动态渲染格
 /// 不需要public
 /// </summary>
 /// <param name="count"></param>
 void _UpdateDynmicRects(int count)
 {
     mDict_dRect = new Dictionary <int, DynamicRect>();
     for (int i = 0; i < count; ++i)
     {
         int         row    = i / ColumnCount;
         int         column = i % ColumnCount;
         DynamicRect dRect  = new DynamicRect(column * GetBlockSizeX(), -row * GetBlockSizeY() - CellSize.y, CellSize.x, CellSize.y, i);
         mDict_dRect[i] = dRect;
     }
 }
Ejemplo n.º 3
0
    public SeriesSet(string label, DynamicRect rect, bool isActive = true)
    {
        this.label    = label;
        this.rect     = rect;
        this.isActive = isActive;
        this.color    = new Color(Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f));

        this.colorHex = Functions.ColorToHex(color);

        seriesList = new List <BarSeries>();
    }
Ejemplo n.º 4
0
    public SeriesSet(string label, DynamicRect rect, bool isActive = true)
    {
        this.label = label;
        this.rect = rect;
        this.isActive = isActive;
        this.color = new Color(Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f));

        this.colorHex = Functions.ColorToHex(color);

        seriesList = new List<BarSeries>();
    }
Ejemplo n.º 5
0
    public BarSeries(string label, int score, DynamicRect rect, Color color)
    {
        //param 2: List<float> values
        this.label = label;
        //this.values = values;
        this.score = score;
        this.rect = rect;
        this.color = color;

        this.colorHex = Functions.ColorToHex(color);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 通过动态格子获得动态渲染器
    /// </summary>
    /// <param name="rect"></param>
    /// <returns></returns>
    DynamicInfinityItem GetDynmicItem(DynamicRect rect)
    {
        int len = mList_items.Count;

        for (int i = 0; i < len; ++i)
        {
            DynamicInfinityItem item = mList_items[i];
            if (item.DRect == null)
            {
                continue;
            }
            if (rect.Index == item.DRect.Index)
            {
                return(item);
            }
        }
        return(null);
    }
Ejemplo n.º 7
0
 /// <summary>
 /// 是否相交
 /// </summary>
 /// <param name="otherRect"></param>
 /// <returns></returns>
 public bool Overlaps(DynamicRect otherRect)
 {
     return(mRect.Overlaps(otherRect.mRect));
 }
Ejemplo n.º 8
0
    private void DrawSeriesSet(SeriesSet seriesSet, int index = 0)
    {
        float xPos;

        xPos = hStart.x + interBarWidth / 2 + (index * (barWidth + interBarWidth));

        seriesSet.rect.x = xPos;
        seriesSet.rect.y = hStart.y - 1;

        GUI.color = (seriesSet.label == selected) ? Color.gray : Color.white;

        // Rotate -90 degrees to allow Rect to expand upwards by adjusting the width
        Matrix4x4 matrix = GUI.matrix;
        Vector2   origin = new Vector2(seriesSet.rect.x, seriesSet.rect.y);

        GUIUtility.RotateAroundPivot(-90, origin);
        // Draw Series Set
        GUI.BeginGroup(seriesSet.rect.GetRect());
        float yNext = 0;

        foreach (BarSeries series in seriesSet.seriesList)
        {
            float barHeight = ((float)series.score / (float)yRange) * yAxisLength;                //prev series.GetSum()
            // Draw horizontally, then rotate vertically
            DynamicRect barRect = series.GetRect();
            barRect.x     = yNext;
            barRect.width = barHeight;
            // Next stacking position
            yNext += barHeight - 1f;

            Functions.DrawBackground(barRect.GetRect(), barTexture, series.color);
        }
        GUI.EndGroup();
        // Restore Rotation
        GUI.matrix = matrix;
        // Expand "Animation"
        if (Mathf.Abs(seriesSet.rect.width - yAxisLength) > 0.1f)
        {
            seriesSet.rect.width = Mathf.Lerp(0, yAxisLength, seriesSet.rect.deltaTime += Time.deltaTime * 0.4f);
        }
        else
        {
            // Create labels
            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.richText  = true;
            style.alignment = TextAnchor.LowerCenter;

            foreach (BarSeries series in seriesSet.seriesList)
            {
                DynamicRect barRect = series.GetRect();

                string text = series.score.ToString();                    //GetSum ().ToString ("F2");
//				GUI.Label(new Rect(seriesSet.rect.x - 65, yAxisLength - barRect.x - barRect.width / 2 - 9, 200, 60), text, style);
            }
        }

        {
            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.richText  = true;
            style.alignment = TextAnchor.UpperCenter;

            string xLabel = seriesSet.label;
            GUI.Label(new Rect(seriesSet.rect.x + (seriesSet.rect.height - 200) / 2, seriesSet.rect.y + 10, 200, 60), xLabel, style);
        }
    }