Linked Rotator with Pink Field

This commit is contained in:
brausjonas
2023-04-14 17:16:41 +02:00
parent 9e709c03bd
commit 0742ff15b4
16 changed files with 281 additions and 103 deletions
+22 -8
View File
@@ -13,17 +13,13 @@ public class RandomRotator : MonoBehaviour
private int currentIndex = 0;
private float lastTimeSwitched = 0;
private int stopIndex = 0;
public UIHandler uiHandler;
public void SetOptionsText(int index, string text)
{
textOptions[index].text = text;
}
private void Start()
{
StartRandom();
}
private void ColorOption(int index)
{
for (int i = 0; i < options.Length; i++)
@@ -39,16 +35,17 @@ public class RandomRotator : MonoBehaviour
}
}
private float slowDown = 0.5f;
private void Update()
{
if (started)
{
if (Time.time - lastTimeSwitched > 0.1f)
if (Time.time - lastTimeSwitched > 0.2f)
{
lastTimeSwitched = Time.time;
ColorOption(currentIndex);
currentIndex++;
if (currentIndex > options.Length - 1)
if (currentIndex > options.Length)
{
currentIndex = 0;
}
@@ -56,7 +53,24 @@ public class RandomRotator : MonoBehaviour
}
else
{
ColorOption(stopIndex);
if (currentIndex != stopIndex)
{
if (Time.time - lastTimeSwitched > slowDown)
{
slowDown += 0.2f;
lastTimeSwitched = Time.time;
ColorOption(currentIndex);
currentIndex++;
if (currentIndex > options.Length)
{
currentIndex = 0;
}
}
}
else
{
ColorOption(stopIndex);
}
}
}