// Update is called once per frame void Update() { if (!endGameScript.IsDead()) { if (waitForStartScript.HasStarted()) { timeLeft -= Time.deltaTime; } if (timeLeft <= 0) { endGameScript.EndTheGame(GameObject.Find("Tank")); timeLeft = 0; } } timeTextComponent.text = string.Format("Time: {0:00.00}s", timeLeft); scoreTextComponent.text = string.Format("Score: {0:00000}", scoreHandlerScript.GetScore()); }
// Update is called once per frame void Update() { if (!waitForStartScript.HasStarted()) { return; } if (checkModeScript.modeChanged()) { return; } if (Input.GetMouseButtonUp((int)MouseButton.LeftMouse)) { mouseUp = true; } Scene scene = SceneManager.GetActiveScene(); // If on the last level, stop shooting if (scene.name == "GameScene6") { return; } if (currentCooldown <= 0 && mouseUp && !endGameScript.IsDead()) { if (Input.GetMouseButton((int)MouseButton.LeftMouse)) { GameObject tankGameObject = GameObject.Find("Tank"); Vector3 cursorPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); spawnBulletScript.SpawnTheBullet(tankGameObject, cursorPosition, bulletSpeed); AudioSource.PlayClipAtPoint(Resources.Load <AudioClip>("GameScene/Audio/shoot"), new Vector3(0, 0, 0)); currentCooldown = cooldown; } } else { currentCooldown -= Time.deltaTime; } }