42 lines
1018 B
C#
42 lines
1018 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
public class ButtonsMinigame : MonoBehaviour
|
|
{
|
|
public Light[] lights;
|
|
public int round = 1;
|
|
public float glowDuration = 0.4f;
|
|
public float gapBetween = 0.15f;
|
|
private List<int> sequence = new List<int>();
|
|
|
|
void Generatesequence()
|
|
{
|
|
sequence.Clear();
|
|
for (int i = 0; i < round; i++)
|
|
{
|
|
int randomButton = Random.Range(0,5);
|
|
sequence.Add(randomButton);
|
|
}
|
|
}
|
|
|
|
IEnumerator Playsequence()
|
|
{
|
|
for (int i = 0; i < sequence.Count; i++)
|
|
{
|
|
int buttonIndex = sequence[i];
|
|
lights[buttonIndex].gameObject.SetActive(true);
|
|
yield return new WaitForSeconds (glowDuration);
|
|
lights[buttonIndex].gameObject.SetActive(false);
|
|
yield return new WaitForSeconds (gapBetween);
|
|
}
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
Generatesequence();
|
|
StartCoroutine(Playsequence());
|
|
}
|
|
|
|
}
|