Ejemplo n.º 1
0
 public void SetBarProperties(BarProperty barProperty)
 {
     barProperty.barClickEvents.PointerDownOnBar  += OnBarPointerDown;
     barProperty.barClickEvents.PointerUpOnBar    += OnBarPointerUp;
     barProperty.barClickEvents.PointerEnterOnBar += OnBarPointerEnter;
     barProperty.barClickEvents.PointerExitOnBar  += OnBarPointerExit;
 }
Ejemplo n.º 2
0
        public IEnumerator GenerateGraphBarWithAnimTypeOne(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Color barColor)
        {
            if (barRef == null)
            {
                yield return(null);
            }

            barParent.transform.localScale = Vector3.one;
            //
            GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);

            bar.transform.parent = ListOfGroups[zIndex].transform;
            //Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z);
            // Debug.Log("Yes I am calling -----");
            Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);

            bar.transform.localPosition = pos;
            bar.transform.localScale    = bar.transform.localScale * graphScaleFactor;


            BarProperty barProperty = bar.GetComponent <BarProperty>();

            SetBarProperties(barProperty);
            barProperty.SetBarColor(barColor);

            ListOfGroups[zIndex].ListOfBar.Add(bar);
            float yscale = (yValue - ymin) * scaleFactor;

            yield return(StartCoroutine(AnimateBarsWithAnimTypeOne(barProperty, yscale, yValue, animSpeed, false)));


            yield return(new WaitForEndOfFrame());
        }
Ejemplo n.º 3
0
        public void GenerateBarWithAnimTypeTwo(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Material barMaterial)
        {
            if (barRef == null)
            {
                return;
            }

            GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);

            bar.transform.parent = ListOfGroups[zIndex].transform;
            //Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z);
            // Debug.Log("Yes I am calling -----");
            Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);

            bar.transform.localPosition = pos;
            bar.transform.localScale    = bar.transform.localScale * graphScaleFactor;

            BarProperty barProperty = bar.GetComponent <BarProperty>();

            SetBarProperties(barProperty);
            if (barMaterial != null)
            {
                barProperty.SetBarMat(barMaterial);
            }
            barProperty.SetBarLabel(yValue.ToString(), graphScaleFactor);

            float yscale = (yValue - ymin) * scaleFactor;

            bar.transform.localScale = new Vector3(bar.transform.localScale.x, yscale, bar.transform.localScale.z);

            ListOfGroups[zIndex].ListOfBar.Add(bar);
        }
Ejemplo n.º 4
0
        public void UpdateBarHeight(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, Color barColor, Color barStartColor)
        {
            GameObject  bar         = ListOfGroups[zIndex].ListOfBar[xIndex];
            BarProperty barProperty = bar.GetComponent <BarProperty>();
            float       yscale      = (yValue - ymin) * scaleFactor;

            barProperty.LabelContainer.SetActive(false);
            StartCoroutine(AnimateBarsWithAnimTypeThree(barProperty, yscale, yValue, animSpeed, true, barColor, barStartColor));
        }
Ejemplo n.º 5
0
        public IEnumerator AnimateBarsWithAnimTypeThree(BarProperty bar, float barScale, float yValue, float animSpeed, bool isUpdating, Color barColor, Color barStartColor)
        {
            while (true)
            {
                BarProperty barProperty = bar.GetComponent <BarProperty>();
                Color       barCol      = Color.Lerp(barProperty.GetBarColor(), barColor, Time.deltaTime * animSpeed * 0.4f);
                barProperty.SetBarColor(barCol);
                Vector3 targetScale = new Vector3(bar.transform.localScale.x, barScale, bar.transform.localScale.z);
                if (bar.transform.localScale.y > targetScale.y)
                {
                    Vector3 scale = bar.transform.localScale - new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, targetScale.y, yValue);
                    bar.transform.localScale = scale;



                    if (bar.transform.localScale.y <= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        barProperty.SetBarColor(barColor);
                        break;
                    }
                }
                else
                {
                    Vector3 scale = bar.transform.localScale + new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, 0, targetScale.y);
                    bar.transform.localScale = scale;


                    if (bar.transform.localScale.y >= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        barProperty.SetBarColor(barColor);
                        break;
                    }
                }



                yield return(new WaitForEndOfFrame());
            }

            if (isUpdating)
            {
                GraphUpdated();
            }

            yield return(new WaitForEndOfFrame());
        }
Ejemplo n.º 6
0
        public IEnumerator AnimateBarsWithAnimTypeOne(BarProperty bar, float barScale, float yValue, float animSpeed, bool isUpdating)
        {
            while (true)
            {
                Vector3     targetScale = new Vector3(bar.transform.localScale.x, barScale, bar.transform.localScale.z);
                BarProperty barProperty = bar.GetComponent <BarProperty>();

                if (bar.transform.localScale.y > targetScale.y)
                {
                    Vector3 scale = bar.transform.localScale - new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, targetScale.y, yValue);
                    Debug.Log($"y scale {scale.y} traget scale {targetScale.y} yvalue {yValue}");
                    bar.transform.localScale = scale;

                    if (bar.transform.localScale.y <= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        break;
                    }
                }
                else
                {
                    Vector3 scale = bar.transform.localScale + new Vector3(0, Time.deltaTime * animSpeed, 0);
                    scale.y = Mathf.Clamp(scale.y, 0, targetScale.y);

                    Debug.Log($"y scale {scale.y} traget scale {targetScale.y} yvalue {yValue}");
                    bar.transform.localScale = scale;
                    if (bar.transform.localScale.y >= targetScale.y)
                    {
                        barProperty.SetBarLabelVisible(yValue.ToString(), graphScaleFactor);
                        break;
                    }
                }

                yield return(new WaitForEndOfFrame());
            }

            if (isUpdating)
            {
                GraphUpdated();
            }

            yield return(new WaitForEndOfFrame());
        }
Ejemplo n.º 7
0
        //Animation All Together
        public void GenerateBarWithAnimTypeTwo(int xIndex, int zIndex, float yValue, float scaleFactor, float animSpeed, int ymin, int xMax, Color barColor)
        {
            if (barRef == null)
            {
                return;
            }


            GameObject bar = GameObject.Instantiate(barRef, transform.position, transform.rotation);

            //bar.transform.parent = ListOfGroups[zIndex].transform;
            bar.transform.SetParent(ListOfGroups[zIndex].transform);


            //Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.position.x, 0, ListOfZPoints[zIndex].transform.position.z);
            // Debug.Log("Yes I am calling -----");
            Vector3 pos = new Vector3(ListOfXPoint[xIndex].transform.localPosition.x, 0, 0);

            bar.transform.localPosition = pos;
            bar.transform.localScale    = bar.transform.localScale * graphScaleFactor;


            BarProperty barProperty = bar.GetComponent <BarProperty>();

            SetBarProperties(barProperty);
            barProperty.SetBarColor(barColor);
            barProperty.SetBarLabel(yValue.ToString(), graphScaleFactor);

            /*travando fator de escala da barra
             * if (float.IsInfinity(scaleFactor))
             * {
             *  scaleFactor = 1.5f;
             * }
             * if(Math.Round(scaleFactor,1) <= 0.33)
             * {
             *  scaleFactor = 0.6f;
             * }
             */
            float yscale = (yValue - ymin) * scaleFactor;  //retornando NaN quando escala e infinita

            if (float.IsNaN(yscale))
            {
                //Debug.Log("caiu no Is Nan");
                scaleFactor = 1;
                ymin        = int.Parse(yValue.ToString()) - 5;
                yscale      = (yValue - ymin) * scaleFactor;
            }
            else if (scaleFactor > 9)
            {
                //scaleFactor = 1;      ?
                //yscale = (yValue - ymin) * scaleFactor;
            }
            else if (yscale > 10)
            {
                // yscale = yscale / 2;  ?
            }


            //Debug.Log("yValue " + yValue.ToString() + "  ymin: " + ymin + "  scalefactor: " + scaleFactor + "  yscale: " + yscale);

            bar.transform.localScale = new Vector3(bar.transform.localScale.x, yscale, bar.transform.localScale.z);
            ///Acontecendo algo aqui em cima

            ListOfGroups[zIndex].ListOfBar.Add(bar);
        }