Exemplo n.º 1
0
        public float PercentNextTier(float progress)
        {
            float currentTier = this.Tier(progress);
            float a           = Table.Progress(currentTier, this.threshold);
            float b           = Table.Progress(Math.Min(currentTier + 1, this.maxTier), this.threshold);

            return((progress - a) / (b - a));
        }
Exemplo n.º 2
0
        private void PaintPlot(Rect rectPlot, float maxResult, float threshold)
        {
            float plotWidth = Mathf.Max(
                (maxResult) * (BAR_WIDTH + BAR_SPACE),
                rectPlot.width
                );

            Rect rectView = new Rect(
                rectPlot.x,
                rectPlot.y,
                plotWidth,
                PLOT_HEIGHT
                );

            this.scroll = GUI.BeginScrollView(rectPlot, this.scroll, rectView);
            EditorGUI.DrawRect(rectView, PLOT_COLOR);

            float maxValue = Table.Progress(maxResult, threshold);

            for (float i = 1f; i <= maxResult; ++i)
            {
                float value  = Table.Progress(i, threshold);
                float height = (value / maxValue) * (PLOT_HEIGHT - 10f);

                float x       = rectView.x + ((i - 1f) * (BAR_WIDTH + BAR_SPACE));
                Rect  rectBar = new Rect(
                    x,
                    rectView.y + (PLOT_HEIGHT - height),
                    BAR_WIDTH,
                    height
                    );

                Rect rectHighlight = new Rect(
                    x,
                    rectView.y,
                    BAR_WIDTH,
                    PLOT_HEIGHT
                    );

                if (this.selectIndex == (int)i)
                {
                    EditorGUI.DrawRect(rectHighlight, BAR_HIGH_COLOR);
                    this.selectText = string.Format(SELECT_FMT, i, value);
                }

                EditorGUI.DrawRect(rectBar, BAR_NORM_COLOR);
            }

            if (UnityEngine.Event.current.type == EventType.MouseUp &&
                rectView.Contains(UnityEngine.Event.current.mousePosition))
            {
                this.selectIndex = Mathf.FloorToInt(
                    (UnityEngine.Event.current.mousePosition.x - rectPlot.x) /
                    (BAR_WIDTH + BAR_SPACE)
                    ) + 1;

                UnityEngine.Event.current.Use();
            }

            GUI.EndScrollView();

            if (!string.IsNullOrEmpty(selectText))
            {
                EditorGUI.LabelField(rectPlot, this.selectText, EditorStyles.whiteLargeLabel);
            }
        }