19 private Material orbMaterial = null;
25 public bool TestStop =
false;
26 public bool HasAnimationFinished =
false;
28 private float timeElapsed;
29 private int deployedCount;
30 private bool timeUpdated;
31 private float[] angles;
32 private float timeSlice;
33 private float deg2rad = Mathf.PI / 180.0f;
34 private GameObject[] dots;
35 private bool stopRequested;
36 private float rotationWhenStopped;
37 private Material[] materials;
41 rotationWhenStopped = 0.0f;
42 stopRequested =
false;
47 angles =
new float[orbs.Length];
48 for (
int i = 0; i < angles.Length; ++i)
53 dots =
new GameObject[5];
54 materials =
new Material[dots.Length];
56 for (
int i = 0; i < orbs.Length; ++i)
58 materials[i] = (Material)Instantiate(orbMaterial);
59 materials[i].color =
new Color(1, 1, 1, 1);
60 dots[i] = orbs[i].transform.GetChild(0).gameObject;
61 materials[i] = dots[i].GetComponent<Renderer>().sharedMaterial = materials[i];
68 rotationWhenStopped = angles[0];
73 if (HasAnimationFinished ==
false)
84 private void UpdateTime()
86 if (timeUpdated ==
false)
94 timeSlice = Time.unscaledDeltaTime;
95 timeElapsed += timeSlice;
99 private void ControlDotStarts()
101 if (deployedCount < orbs.Length)
103 if (angles[deployedCount - 1] >= SpacingDegrees)
110 private void IncrementOrbs()
112 for (
int i = 0; i < deployedCount; ++i)
118 private void IncrementOrb(
int index)
120 float acceleratedDegrees = (RotationSpeedRawDegrees * (Acceleration + -Mathf.Cos(deg2rad * angles[index]))) * timeSlice;
121 orbs[index].gameObject.transform.Rotate(0, 0, acceleratedDegrees);
122 angles[index] += Mathf.Abs(acceleratedDegrees);
127 private void HandleFade(
int index)
129 Color adjustedColor = materials[index].color;
132 if (stopRequested ==
false && adjustedColor.a < 1.0f)
134 adjustedColor.a += (1.0f * timeSlice);
135 adjustedColor.a = Mathf.Min(1.0f, adjustedColor.a);
136 materials[index].color = adjustedColor;
139 else if (stopRequested && angles[index] > rotationWhenStopped)
141 adjustedColor.a -= (1.0f * timeSlice);
142 adjustedColor.a = Mathf.Max(0.0f, adjustedColor.a);
143 materials[index].color = adjustedColor;
147 private void HandleTestStop()
149 if (TestStop ==
true && stopRequested ==
false)
155 private void HandleStopping()
157 if (stopRequested ==
true && materials[orbs.Length - 1].color.a <= 0.01f)
159 HasAnimationFinished =
true;