Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Quiz : MonoBehaviour
- {
- public GameObject bottoniera;
- public GameObject esatta;
- public GameObject sbagliata;
- public string chiave = "1324";
- public string codice = "";
- public float timeout = 0;
- // Start is called before the first frame update
- void Start()
- {
- bottoniera.SetActive(true);
- esatta.SetActive(false);
- sbagliata.SetActive(false);
- codice = "";
- timeout = 0;
- }
- public void clickBottone(string bottone)
- {
- codice += bottone;
- if(codice == chiave)
- {
- click_esatta();
- } else
- {
- timeout = 2;
- }
- }
- public void click_esatta()
- {
- bottoniera.SetActive(false);
- esatta.SetActive(true);
- StartCoroutine(timer());
- }
- public void click_sbagliata()
- {
- bottoniera.SetActive(false);
- sbagliata.SetActive(true);
- StartCoroutine(timer());
- }
- // Update is called once per frame
- void Update()
- {
- if (timeout > 0)
- {
- timeout -= Time.deltaTime;
- if (timeout <= 0)
- {
- timeout = 0;
- codice = "";
- }
- }
- }
- IEnumerator timer()
- {
- yield return new WaitForSeconds(2);
- Start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement