// Use this for initialization void Start() { if (instance != null) { Debug.LogError("Error: Two FIghtManagers were created"); return; } instance = this; CreatePlayers(); if (player1 == null || player2 == null) { Debug.LogError("Error: Both players were not set"); return; } foreach (Image im in doubleUpImages) { im.enabled = false; FlickerImage flicker = im.GetComponent <FlickerImage> (); if (flicker != null) { flicker.Disable(); } } SetNextDoubleTime(); isDoubleTime = false; BeginRound(); }
IEnumerator AccessState(bool granted = false) { MainButton.interactable = false; foreach (PasswordThing pt in Passwords) { pt.InputField.interactable = false; } AccessGranted.gameObject.SetActive(granted); AccessDenied.gameObject.SetActive(!granted); FlickerImage f = (granted) ? AccessGranted : AccessDenied; yield return(new WaitForSeconds(f.time * f.amount)); if (!granted) { AccessDenied.gameObject.SetActive(false); MainButton.interactable = true; foreach (PasswordThing pt in Passwords) { pt.InputField.interactable = true; } } else { TransitionToMenuScreen(NextScreen); } yield return(null); }
// Update is called once per frame void FixedUpdate() { if (hasRoundEnded) { doubleTimeText.text = ""; return; } if (!isDoubleTime) { float timeLeft = nextDoubleTime - Time.time; doubleTimeText.text = "2X in: " + (int)timeLeft; if (Time.time >= nextDoubleTime) { // Begin double time foreach (Image im in doubleUpImages) { im.enabled = true; FlickerImage flicker = im.GetComponent <FlickerImage> (); if (flicker != null) { flicker.Enable(); } } Time.timeScale = 2; isDoubleTime = true; SetEndDoubleTime(); } } else { // In double time float timeLeft = endOfDoubleTime - Time.time; if (timeLeft <= 0) { // Double time has ended, generate next double time foreach (Image im in doubleUpImages) { im.enabled = false; FlickerImage flicker = im.GetComponent <FlickerImage> (); if (flicker != null) { flicker.Disable(); } } Time.timeScale = 1; isDoubleTime = false; SetNextDoubleTime(); doubleTimeText.text = ((int)nextDoubleTime).ToString(); } else { // Still in double time doubleTimeText.text = ((int)timeLeft).ToString(); } } if (testWinRound1) { testWinRound1 = false; WinRound(0); } else if (testWinRound2) { testWinRound2 = false; WinRound(1); } }