// Update is called once per frame void Update() { if (Input.GetAxisRaw("Pause") == 0) { canPressPause = true; } if (canPressPause && Input.GetAxisRaw("Pause") > 0 && !victoryScreen.activeInHierarchy && !failureScreen.activeInHierarchy) { canPressPause = false; SetPaused(); } if (Input.GetAxisRaw("Restart") == 0) { canPressRestart = true; } if (canPressRestart && Input.GetAxisRaw("Restart") > 0) { canPressRestart = false; RetryLevel(); } if (textTip != null && textTip.Length > 0 && !victoryScreen.activeInHierarchy && !failureScreen.activeInHierarchy && !pauseScreen.activeInHierarchy) { textBox.SetActive(true); } else { textBox.SetActive(false); } if (isPaused) { return; } if (portraits == null) { portraits = FindObjectOfType <CannonScript>().portraits; } if (portraits != null) { setPortraitTimer -= Time.deltaTime; if (timeDrain) { if (failureScreen.activeInHierarchy) { portraitIcon.sprite = portraits[7]; } else { portraitIcon.sprite = portraits[6]; } } else if (failureScreen.activeInHierarchy) { portraitIcon.sprite = portraits[5]; } else if (victoryScreen.activeInHierarchy) { portraitIcon.sprite = portraits[3]; } else if (setPortraitTimer > 0f) { portraitIcon.sprite = portraits[setPortraitIndex]; } else if (timer < 20f) { portraitIcon.sprite = portraits[4]; } else { portraitIcon.sprite = portraits[0]; } } if (levelSetupScript == null) { levelSetupScript = FindObjectOfType <LevelSetupScript>(); if (levelSetupScript != null) { timerStart = levelSetupScript.startTime; if (!setTimer) { timer = timerStart; setTimer = true; } textTip = levelSetupScript.missionTip; missionName = levelSetupScript.missionName; levelIndex = levelSetupScript.index; } } if (DataTracker.originalControls) { controlsTutorialText.text = "STEER: Left/Right\nTHRUST: Up\nBRAKE: Down\nSHOOT BLOCK: Spacebar\nSPECIAL: Left Shift\nRETRY: R\nPAUSE: Escape"; } else { controlsTutorialText.text = "FLY SHIP: Left/Right/Up/Down\nSHOOT BLOCK: Spacebar\nSPECIAL: Left Shift\nRETRY: R\nPAUSE: Escape"; } LevelSelectScript.currentMenu = levelIndex; textBoxText.text = textTip; missionNameText.text = "CONTRACT: " + missionName; if (planet == null && timer > 0f) { PlanetScript[] allPlanets = FindObjectsOfType <PlanetScript>(); for (int i = 0; i < allPlanets.Length; i++) { if (allPlanets[i] != null && allPlanets[i].match >= 0) { planet = allPlanets[i]; break; } } levelWinTimer += Time.deltaTime; if (levelWinTimer > timeToDelay) { victoryScreen.SetActive(true); SetHighScore(); } } else { levelWinTimer = 0f; float mult = 1f; if (timeDrain) { mult = 600f; } if (stopTimer) { mult = 0f; } timer -= Time.deltaTime * mult; for (int t = 0; t < timeToPlay.Length && t < alreadyPlayedTime.Length; t++) { if (timer < timeToPlay[t] && !alreadyPlayedTime[t]) { alreadyPlayedTime[t] = true; GameObject snd = Instantiate <GameObject>(soundPrefab); snd.GetComponent <SFXScript>().sfx = lowTimeSFX; } } if (timer < 0) { timer = 0; if (!failureScreen.activeInHierarchy) { GameObject snd = Instantiate <GameObject>(soundPrefab); snd.GetComponent <SFXScript>().sfx = timeUpSFX; } levelLoseTimer += Time.deltaTime; if (levelLoseTimer > timeToDelay) { failureScreen.SetActive(true); } } } int roundedTimer = (int)(Mathf.Ceil(timer)); int minutes = roundedTimer / 60; int seconds = roundedTimer % 60; string minStr = "" + minutes; if (minutes < 10) { minStr = "0" + minStr; } string secStr = "" + seconds; if (seconds < 10) { secStr = "0" + secStr; } timerText.text = minStr + ":" + secStr; scoreText.text = "SCORE: " + score; if (spMove == null) { specialMoveText.text = ""; spMove = FindObjectOfType <SpecialMove>(); } else { string str = "SPECIAL : " + spMove.displayName; if (spMove.GetCanBeUsed()) { str += "\n[Press Left Shift]"; specialMoveIcon.sprite = spMove.iconReady; } else { str += "\nAlready used!"; specialMoveIcon.sprite = spMove.iconUsed; } specialMoveText.text = str; } }