/// <summary> /// Method to build the circle. Each part of the circle is an UI Image, type = fill image. We use the fill amout property to create the parts of the circle /// </summary> void BuildCircle() { float countAngle = 0f; float sizePart = 1f / numOfPart; for (int i = 0; i < numOfPart; i++) { float angle = i * 360 * sizePart; Color c = Color.white; int numColor = i; while (numColor >= listColorReordered.Count) { numColor -= listColorReordered.Count; } c = listColorReordered[numColor]; CirclePart circle = InstantiateCircle(sizePart, angle, c); circle.name = i.ToString(); countAngle += angle; allCircles.Add(circle); } }
/// <summary> /// Check if the player tap at the good moment on the screen, ie. check if the color of the ball = the color of the part of the circle below the ball /// </summary> public bool CheckIfBallColorEqualCircleColor() { CirclePart selection = allCircles[0]; selection = GetSelection(); // print("selection = " + selection.name + " - angle = " + selection.GetMiddleAngle()); if (selection.image.color.IsEqual(ball.color)) { var initialPos = selection.transform.localPosition; selection.transform.DOMoveY(selection.transform.position.y - 30f, 0.1f).SetLoops(2, LoopType.Yoyo).OnComplete(() => { selection.transform.localPosition = initialPos; }); return(true); } else { return(false); } }