Ejemplo n.º 1
0
 void updateNumberRings()
 {
     if (numRingsChanged)
     {
         // Create rings based on values data
         for (int i = 0; i < values.Count; i++)
         {
             if (labels.Count <= i)
             {
                 labels.Add("Ring " + (i + 1));
             }
             if (bandColors.Count <= i)
             {
                 bandColors.Add(bandColor);
             }
             if (rings.Count <= i)
             {
                 GameObject obj = GameObject.Instantiate(ringPrefab) as GameObject;
                 changeSpriteParent(obj, ringsParent);
                 WMG_Ring ring = obj.GetComponent <WMG_Ring>();
                 ring.initialize(this);
                 rings.Add(ring);
             }
         }
         for (int i = rings.Count - 1; i >= 0; i--)
         {
             if (rings[i] != null && i >= values.Count)
             {
                 Destroy(rings[i].label);
                 Destroy(rings[i].gameObject);
                 rings.RemoveAt(i);
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void WMG_Ring_MouseEnter_2(GameObject go, bool state)
 {
     if (WMG_Ring_MouseEnter != null)
     {
         WMG_Ring ring = go.transform.parent.GetComponent <WMG_Ring>();
         WMG_Ring_MouseEnter(ring, state);
     }
 }
Ejemplo n.º 3
0
 private void WMG_Ring_Click_2(GameObject go, PointerEventData pointerEventData)
 {
     if (WMG_Ring_Click != null)
     {
         WMG_Ring ring = go.transform.parent.GetComponent <WMG_Ring>();
         WMG_Ring_Click(ring, pointerEventData);
     }
 }
Ejemplo n.º 4
0
 private void WMG_Ring_MouseDownUp_2(GameObject go, bool down, PointerEventData pointerEventData)
 {
     if (WMG_Ring_MouseDownUp != null)
     {
         WMG_Ring ring = go.transform.parent.GetComponent <WMG_Ring>();
         WMG_Ring_MouseDownUp(ring, down, pointerEventData);
     }
 }
Ejemplo n.º 5
0
 private void WMG_Ring_Click_2(GameObject go)
 {
     if (WMG_Ring_Click != null)
     {
         WMG_Ring ring = go.transform.parent.GetComponent <WMG_Ring>();
         WMG_Ring_Click(ring);
     }
 }
Ejemplo n.º 6
0
    void labelRotationComplete(WMG_Ring ring, float degOffset, int numOverlapping)
    {
        bool labelsOverlap = numOverlapping > 0;

        if (labelsOverlap)           // if label is overlapping only update at the end
        {
            updateLabelLineBasedOnOverlap(ring, numOverlapping);
            updateLabelRotationAndPosition(ring, degOffset, numOverlapping, true);
        }
    }
Ejemplo n.º 7
0
    void MyCoolRingDownUpFunction(WMG_Ring ring, bool down, UnityEngine.EventSystems.PointerEventData pointerEventData)
    {
//		Debug.Log ("Down: " + down + " Ring: " + ring.ringIndex + " value: " + ring.graph.values[ring.ringIndex] + " label: " + ring.graph.labels[ring.ringIndex]);
        WMG_Ring hoverRing = null;

        if (pointerEventData.pointerEnter != null && pointerEventData.pointerEnter.transform.parent != null)
        {
            hoverRing = pointerEventData.pointerEnter.transform.parent.gameObject.GetComponent <WMG_Ring>();
        }
        graph.changeSpriteColor(ring.band, down ? mouseDownColor : (hoverRing == ring ? hoverColor : graph.bandColors [ring.ringIndex]));
    }
Ejemplo n.º 8
0
 void updateRingsActive()
 {
     SetActive(extraRing, bandMode);
     for (int i = 0; i < rings.Count; i++)
     {
         WMG_Ring ring          = rings[i];
         bool     shouldNotHide = !hideRings [i];
         if (bandMode)
         {
             SetActive(ring.band, shouldNotHide);
         }
         SetActive(ring.ring, shouldNotHide);
         SetActive(ring.label, shouldNotHide);
     }
 }
Ejemplo n.º 9
0
    void updateLabelLineBasedOnOverlap(WMG_Ring ring, int numOverlapping)
    {
        changeSpriteWidth(ring.textLine, 2 + 20 * numOverlapping);
        bool labelsOverlap = numOverlapping > 0;

        if (!labelsOverlap)
        {
            SetActiveImage(ring.line, true);
            changeSpritePivot(ring.textLine, WMGpivotTypes.Bottom);
            setTexture(ring.textLine, labelLineSprite);
            setAnchor(ring.labelBackground, new Vector2(0, 1), new Vector2(1, 0), Vector2.zero);
        }
        else
        {
            SetActiveImage(ring.line, false);
        }
    }
Ejemplo n.º 10
0
    void updateLabelRotationAndPosition(WMG_Ring ring, float degOffset, int numOverlapping, bool onComplete)
    {
        bool labelsOverlap = numOverlapping > 0;

        if (ring.label.transform.localEulerAngles.z < 180)
        {
            if (labelsOverlap)
            {
                changeSpritePivot(ring.textLine, WMGpivotTypes.BottomLeft);
                setTexture(ring.textLine, botRightCorners);
                setAnchor(ring.labelBackground, Vector2.one, new Vector2(1, 0), Vector2.zero);
            }
            if (!onComplete)
            {
                if (degOffset == 0 || degOffset == 90)
                {
                    ring.textLine.transform.localEulerAngles = new Vector3(ring.textLine.transform.localEulerAngles.x,
                                                                           ring.textLine.transform.localEulerAngles.y,
                                                                           ring.textLine.transform.localEulerAngles.z - 180);
                }
                ring.labelBackground.transform.localEulerAngles = new Vector3(0, 0, 90);
            }
            changeSpritePivot(ring.labelBackground, WMGpivotTypes.BottomRight);
        }
        else
        {
            if (labelsOverlap)
            {
                changeSpritePivot(ring.textLine, WMGpivotTypes.BottomRight);
                setTexture(ring.textLine, botLeftCorners);
                setAnchor(ring.labelBackground, new Vector2(0, 1), new Vector2(1, 0), Vector2.zero);
            }
            if (!onComplete)
            {
                if (degOffset == -90)
                {
                    ring.textLine.transform.localEulerAngles = new Vector3(ring.textLine.transform.localEulerAngles.x,
                                                                           ring.textLine.transform.localEulerAngles.y,
                                                                           ring.textLine.transform.localEulerAngles.z + 180);
                }
                ring.labelBackground.transform.localEulerAngles = new Vector3(0, 0, -90);
            }
            changeSpritePivot(ring.labelBackground, WMGpivotTypes.BottomLeft);
        }
    }
Ejemplo n.º 11
0
 void labelRotationUpdated(WMG_Ring ring, float degOffset, int numOverlapping)
 {
     updateLabelLineBasedOnOverlap(ring, 0);
     updateLabelRotationAndPosition(ring, degOffset, 0, false);
 }
Ejemplo n.º 12
0
	void labelRotationComplete(WMG_Ring ring, float degOffset, int numOverlapping) {
		bool labelsOverlap = numOverlapping > 0;
		if (labelsOverlap) { // if label is overlapping only update at the end
			updateLabelLineBasedOnOverlap (ring, numOverlapping);
			updateLabelRotationAndPosition (ring, degOffset, numOverlapping, true);
		}
	}
Ejemplo n.º 13
0
    void MyCoolRingHoverFunction(WMG_Ring ring, bool hover)
    {
//		Debug.Log ("Hover: " + hover + " Ring: " + ring.ringIndex + " value: " + ring.graph.values[ring.ringIndex] + " label: " + ring.graph.labels[ring.ringIndex]);
    }
Ejemplo n.º 14
0
 void MyCoolRingClickFunction(WMG_Ring ring, UnityEngine.EventSystems.PointerEventData pointerEventData)
 {
     Debug.Log("Ring: " + ring.ringIndex + " value: " + ring.graph.values[ring.ringIndex] + " label: " + ring.graph.labels[ring.ringIndex]);
 }
Ejemplo n.º 15
0
 void labelRotationUpdated(WMG_Ring ring, float degOffset)
 {
     if (ring.label.transform.localEulerAngles.z < 180) {
         if (degOffset == 0 || degOffset == 90) {
             ring.textLine.transform.localEulerAngles = new Vector3 (ring.textLine.transform.localEulerAngles.x,
                                                                     ring.textLine.transform.localEulerAngles.y,
                                                                     ring.textLine.transform.localEulerAngles.z - 180);
         }
         ring.labelBackground.transform.localEulerAngles = new Vector3 (0, 0, 90);
         changeSpritePivot (ring.labelBackground, WMGpivotTypes.BottomRight);
     }
     else {
         if (degOffset == -90) {
             ring.textLine.transform.localEulerAngles = new Vector3 (ring.textLine.transform.localEulerAngles.x,
                                                                     ring.textLine.transform.localEulerAngles.y,
                                                                     ring.textLine.transform.localEulerAngles.z + 180);
         }
         ring.labelBackground.transform.localEulerAngles = new Vector3 (0, 0, -90);
         changeSpritePivot (ring.labelBackground, WMGpivotTypes.BottomLeft);
     }
 }
Ejemplo n.º 16
0
	void updateLabelLineBasedOnOverlap(WMG_Ring ring, int numOverlapping) {
		changeSpriteWidth (ring.textLine, 2 + 20 * numOverlapping);
		bool labelsOverlap = numOverlapping > 0;
		if (!labelsOverlap) {
			SetActiveImage (ring.line, true);
			changeSpritePivot (ring.textLine, WMGpivotTypes.Bottom);
			setTexture (ring.textLine, labelLineSprite);
			setAnchor (ring.labelBackground, new Vector2 (0, 1), new Vector2 (1, 0), Vector2.zero);
		} else {
			SetActiveImage (ring.line, false);
		}
		
	}
Ejemplo n.º 17
0
	void updateLabelRotationAndPosition(WMG_Ring ring, float degOffset, int numOverlapping, bool onComplete) {
		bool labelsOverlap = numOverlapping > 0;
		if (ring.label.transform.localEulerAngles.z < 180) {
			if (labelsOverlap) {
				changeSpritePivot (ring.textLine, WMGpivotTypes.BottomLeft);
				setTexture (ring.textLine, botRightCorners);
				setAnchor (ring.labelBackground, Vector2.one, new Vector2 (1, 0), Vector2.zero);
			}
			if (!onComplete) {
				if (degOffset == 0 || degOffset == 90) {
					ring.textLine.transform.localEulerAngles = new Vector3 (ring.textLine.transform.localEulerAngles.x, 
					                                                        ring.textLine.transform.localEulerAngles.y, 
					                                                        ring.textLine.transform.localEulerAngles.z - 180);
				}
				ring.labelBackground.transform.localEulerAngles = new Vector3 (0, 0, 90);
				
			}
			changeSpritePivot (ring.labelBackground, WMGpivotTypes.BottomRight);
		} 
		else {
			if (labelsOverlap) {
				changeSpritePivot (ring.textLine, WMGpivotTypes.BottomRight);
				setTexture (ring.textLine, botLeftCorners);
				setAnchor (ring.labelBackground, new Vector2 (0, 1), new Vector2 (1, 0), Vector2.zero);
			}
			if (!onComplete) {
				if (degOffset == -90) {
					ring.textLine.transform.localEulerAngles = new Vector3 (ring.textLine.transform.localEulerAngles.x, 
					                                                        ring.textLine.transform.localEulerAngles.y, 
					                                                        ring.textLine.transform.localEulerAngles.z + 180);
				}
				ring.labelBackground.transform.localEulerAngles = new Vector3 (0, 0, -90);
				
			}
			changeSpritePivot (ring.labelBackground, WMGpivotTypes.BottomLeft);
		}
	}
Ejemplo n.º 18
0
    void updateDegreesAring(int i)
    {
        Vector3 baseRotation = new Vector3(0, 0, -degrees / 2);
        float   newFill      = (360 - degrees) / 360f;

        // extra ring
        changeRadialSpriteRotation(extraRing, baseRotation);
        changeSpriteFill(extraRing, newFill);


        bool ringIsZero = false;

        WMG_Ring ring = rings[i];

        // rings
        changeRadialSpriteRotation(rings[i].ring, baseRotation);
        changeSpriteFill(rings[i].ring, newFill);
        // bands
        float valPercent = values[i] / (maxValue - minValue);

        changeRadialSpriteRotation(rings[i].band, baseRotation);
        changeSpriteFill(rings[i].band, 0);
        if (animateData)
        {
            WMG_Anim.animFill(rings[i].band, animDuration, animEaseType, newFill * valPercent);
        }
        else
        {
            changeSpriteFill(rings[i].band, newFill * valPercent);
        }
        if (valPercent == 0)
        {
            ringIsZero = true;
        }
        // labels
        int numOverlapping = 0;

        for (int j = i - 1; j >= 0; j--)
        {
            float valPercentPrev = values[j] / (maxValue - minValue);
            if (Mathf.Abs(valPercent - valPercentPrev) < 0.01f)                // within 1%
            {
                numOverlapping++;
                valPercent = valPercentPrev;
            }
        }

        Vector3 labelRotation = new Vector3(0, 0, -valPercent * (360 - degrees));

        if (animateData)
        {
            if (DOTween.IsTweening(rings[i].label.transform))               // if already animating, then don't animate relative to current rotation
            {
                updateLabelRotationAndPosition(ring, 0, numOverlapping, false);
                float degOffset = 90;
                if (ring.label.transform.localEulerAngles.z < 180)
                {
                    degOffset *= -1;
                }
                WMG_Anim.animRotation(rings[i].label, animDuration, animEaseType, labelRotation + new Vector3(0, 0, 360) + baseRotation, false);
                WMG_Anim.animRotationCallbacks(rings[i].textLine, animDuration, animEaseType, -labelRotation - baseRotation + new Vector3(0, 0, degOffset), false, () => labelRotationUpdated(ring, degOffset, numOverlapping), () => labelRotationComplete(ring, degOffset, numOverlapping));
            }
            else
            {
                rings[i].label.transform.localEulerAngles    = baseRotation;
                rings[i].textLine.transform.localEulerAngles = -baseRotation + new Vector3(0, 0, 90);
                WMG_Anim.animRotation(rings[i].label, animDuration, animEaseType, labelRotation, true);
                WMG_Anim.animRotationCallbacks(rings[i].textLine, animDuration, animEaseType, -labelRotation, true, () => labelRotationUpdated(ring, 0, numOverlapping), () => labelRotationComplete(ring, 0, numOverlapping));
            }
        }
        else
        {
            updateLabelLineBasedOnOverlap(ring, numOverlapping);
            rings[i].label.transform.localEulerAngles    = labelRotation + baseRotation;
            rings[i].textLine.transform.localEulerAngles = -labelRotation - baseRotation + new Vector3(0, 0, 90);
            updateLabelRotationAndPosition(ring, 0, numOverlapping, false);
        }

        // zero line
        zeroLine.transform.localEulerAngles     = baseRotation;
        zeroLineText.transform.localEulerAngles = -baseRotation;
        if (i == 0)
        {
            SetActive(zeroLine, !ringIsZero);
        }
        else
        {
            if (zeroLine.activeSelf)               // previously not 0
            {
                SetActive(zeroLine, !ringIsZero);
            }
            else                 // there was a zero at one point in the past, always hide
            {
                SetActive(zeroLine, false);
            }
        }
    }
Ejemplo n.º 19
0
	void labelRotationUpdated(WMG_Ring ring, float degOffset, int numOverlapping) {
		updateLabelLineBasedOnOverlap (ring, 0);
		updateLabelRotationAndPosition (ring, degOffset, 0, false);
	}
Ejemplo n.º 20
0
    void MyCoolRingHoverFunction(WMG_Ring ring, bool hover)
    {
//		Debug.Log ("Hover: " + hover + " Ring: " + ring.ringIndex + " value: " + ring.graph.values[ring.ringIndex] + " label: " + ring.graph.labels[ring.ringIndex]);
        graph.changeSpriteColor(ring.band, hover ? hoverColor : graph.bandColors [ring.ringIndex]);
    }