public void ClickedButton(int id) { if (miniGameStat != MGStat.play) { return; } if (select == id) { Debug.Log("Sucess"); miniGameStat = MGStat.win; } else { miniGameStat = MGStat.lost; DoShake(); Debug.Log("Fail"); } }
private void Update() { switch (miniGameStat) { default: case MGStat.none: break; case MGStat.start: colors.Shuffle(); for (int i = 0; i < images.Count; i++) { images[i].color = colors[i]; } select = Random.Range(0, images.Count); image.color = colors[select]; duration = 10; durationMax = duration; bulle.gameObject.SetActive(true); miniGameStat = MGStat.play; break; case MGStat.play: #region Timer duration -= Time.deltaTime; #endregion #region UI image.fillAmount = duration / durationMax; #endregion if (duration <= 0) { miniGameStat = MGStat.lost; } break; case MGStat.win: miniGameStat = MGStat.end; break; case MGStat.lost: DoShake(); miniGameStat = MGStat.end; break; case MGStat.end: image.fillAmount = 0; bulle.gameObject.SetActive(false); miniGameStat = MGStat.countdown; StartCoroutine(nameof(CountDownRestart)); break; } }
void Start() => miniGameStat = MGStat.start;
private void StartMiniGame() => miniGameStat = MGStat.start;
IEnumerator CountDownRestart() { yield return(new WaitForSeconds(1)); miniGameStat = MGStat.start; }