Beispiel #1
0
 void Start()
 {
     go        = GetComponent <GameObstacle> ();
     startTime = Time.time;
     waitTime  = Random.Range(minTimeBeforeSwitch, maxTimeBeforeSwitch);
     color     = startColor;
     go.SetColor(color);
 }
Beispiel #2
0
 void Update()
 {
     if (go == null)
     {
         go = GetComponent <GameObstacle> ();
     }
     if (go.GetColor() != color)
     {
         go.SetColor(color);
     }
     if (Time.time - startTime >= waitTime)
     {
         startTime = Time.time;
         waitTime  = Random.Range(minTimeBeforeSwitch, maxTimeBeforeSwitch);
         color     = color.r == 0f ? Color.white : Color.black;
         go.SetColor(color);
     }
 }
Beispiel #3
0
 void Update()
 {
     if (go == null)
     {
         go = GetComponent <GameObstacle> ();
     }
     if (Mathf.Floor(color.r * 100) == Mathf.Floor(nextColor.r * 100))
     {
         nextColor = new Color(Random.Range(0.2f, 0.8f), Random.Range(0.2f, 0.8f), Random.Range(0.2f, 0.8f), 1f);
     }
     color = Color.Lerp(color, nextColor, 0.1f);
     go.SetColor(color);
 }