public void Init(CircleSizes size, CircleColors color, int score) { this.size = size; this.color = color; this.score = score; SetActualSize(); }
/// <summary> /// Draws the circle, outer glow, and inner glow. /// </summary> /// <param name="vbo">Vertex Buffer Object.</param> /// <param name="radiusInside">Radius inside.</param> /// <param name="radiusOutside">Radius outside.</param> /// <param name="circleType">Circle type.</param> protected void DrawCircle(List <UIVertex> vbo, Vector3 offset, float radiusInside, float radiusOutside, Color mainColor, CircleType circleType) { int angle = 360; int subdivisions = 7; int angleOffset = 0; //Calculate the actual amount of subdivisions int adjustedSubdivisions = UIUtility.GetAdjustedSubdivisions(subdivisions); //Positon Vector3 prevX = Vector3.zero; Vector3 prevY = Vector3.zero; Vector3 center = Vector2.Scale((rectTransform.pivot - (Vector2.one * .5f)), rectTransform.sizeDelta); center -= offset; //Angle float anglePercent = ((float)angle) / 360f; bool resetPositions = true; //Circle for (int i = 0; i < 361; i += adjustedSubdivisions) { float absolutePercent = ((float)i) / 360f; float relativePercent = absolutePercent / anglePercent; //Position float radians = Mathf.Deg2Rad * (i + angleOffset); float cosValue = Mathf.Cos(radians); float sinValue = Mathf.Sin(radians); Vector3 innerPosition = new Vector3(radiusInside * cosValue, radiusInside * sinValue, 0) - center; Vector3 outerPosition = new Vector3(radiusOutside * cosValue, radiusOutside * sinValue, 0) - center; //We want to prevent weird stretching when there are gaps if (resetPositions) { prevX = outerPosition; prevY = innerPosition; resetPositions = false; } //Get colors CircleColors circleColors = GetCircleColors(circleType, mainColor, absolutePercent, relativePercent); //Draw //InnerLeft,OuterLeft,OuterRight,InnerRight Vector3[] positions = new Vector3[] { prevX, prevY, outerPosition, innerPosition }; Color[] colors = new Color[] { circleColors.innerColor, circleColors.outerColor, circleColors.outerColor, circleColors.innerColor }; //Actually add the quads to the VBO for drawing StoreQuad(positions, colors); //Save values for next quad prevX = innerPosition; prevY = outerPosition; } }
private Color GetColorValue(CircleColors color) { switch (color) { case CircleColors.Red: return(Color.red); case CircleColors.Green: return(Color.green); case CircleColors.Blue: return(Color.blue); case CircleColors.Yellow: return(Color.yellow); case CircleColors.Magenta: return(Color.magenta); case CircleColors.Cyan: return(Color.cyan); default: throw new ArgumentOutOfRangeException("color", color, null); } }
private void InitCircleView(CircleView circleView) { CircleSizes size = Model.GetSize(); CircleColors color = Model.GetColor(); int score = Model.GetScore(size); circleView.Init(size, color, score); var texture = resourceManager.GetTexture(size, color); circleView.Renderer.material.SetTexture("_MainTex", texture); }
/////////////////////////////////////////////////////////////////////////// // // UICircle Functions // /// <summary> /// Draws the circle, outer glow, and inner glow. /// </summary> /// <param name="vbo">Vertex Buffer Object.</param> /// <param name="radiusInside">Radius inside.</param> /// <param name="radiusOutside">Radius outside.</param> /// <param name="circleType">Circle type.</param> protected void DrawCircle(List <UIVertex> vbo, float radiusInside, float radiusOutside, CircleType circleType) { //Calculate the actual amount of subdivisions int adjustedSubdivisions = UIUtility.GetAdjustedSubdivisions(subdivisions); //Positon Vector3 prevX = Vector3.zero; Vector3 prevY = Vector3.zero; Vector3 center = Vector2.Scale((rectTransform.pivot - (Vector2.one * .5f)), rectTransform.sizeDelta); //Angle float anglePercent = ((float)angle) / 360f; bool resetPositions = true; //Circle for (int i = 0; i < 361; i += adjustedSubdivisions) { float absolutePercent = ((float)i) / 360f; float absolutePercentNext = ((float)(i + adjustedSubdivisions)) / 360f; //Adjust for world space coloring if (worldSpace) { absolutePercent = ((((float)i) + angleOffset) % 359) / 360f; } float relativePercent = absolutePercent / anglePercent; float relativePercentNext = absolutePercentNext / anglePercent; //Check if we maxed out our repetitions if (i >= ((angle + repeatInterval) * repetitions)) { break; } //Check if it is within our angle limit int remainder = i % (angle + repeatInterval); if (remainder <= angle) { //Set the percent relative to the piece of the circle we are drawing if (repeatInterval != 360) { relativePercent = ((float)remainder) / angle; } } else { //If it should not be drawn we want to reset the prevX/prevY variables on the next draw resetPositions = true; continue; } //Position float radians = Mathf.Deg2Rad * (i + angleOffset); float cosValue = Mathf.Cos(radians); float sinValue = Mathf.Sin(radians); Vector3 innerPosition = new Vector3(radiusInside * cosValue, radiusInside * sinValue, 0) - center; Vector3 outerPosition = new Vector3(radiusOutside * cosValue, radiusOutside * sinValue, 0) - center; //We want to prevent weird stretching when there are gaps if (resetPositions) { prevX = outerPosition; prevY = innerPosition; resetPositions = false; } //Get colors CircleColors circleColors = GetCircleColors(circleType, absolutePercent, relativePercent); CircleColors circleColorsNext = GetCircleColors(circleType, absolutePercentNext, relativePercentNext); //Draw if (drawDots) //Draw the dots { DrawDot(vbo, outerPosition, circleColors.outerColor, dotRadius, dotSubdivisions); } else { //InnerLeft,OuterLeft,OuterRight,InnerRight Vector3[] positions = new Vector3[] { prevX, prevY, outerPosition, innerPosition }; Color[] colors = new Color[] { circleColors.innerColor, circleColors.outerColor, circleColorsNext.outerColor, circleColorsNext.innerColor }; //Actually add the quads to the VBO for drawing AddQuad(vbo, positions, colors); //Save values for next quad prevX = innerPosition; prevY = outerPosition; } } }
public Texture GetTexture(CircleSizes size, CircleColors color) { var key = new TextureKey(size, color); return(texturesCache.ContainsKey(key) ? texturesCache[key] : null); }
public TextureKey(CircleSizes size, CircleColors color) { this.size = size; this.color = color; }