internal void StopEverything() { gameOver = true; playerController.enabled = false; Launcher.enabled = false; rotateTurret.enabled = false; fire.SetActive(false); StopAllCoroutines(); MakeTankGreen(); medkitSpawnerScript.StopAllCoroutines(); medkitSpawner.SetActive(false); enemySpawnerScript.StopAllCoroutines(); enemySpawner.SetActive(false); damageSmoke.SetActive(false); engineNoise.enabled = false; HUD.SetActive(false); musicManager.StopMusic(); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("EnemyProjectile")) { Destroy(collision.gameObject); if (Health > minHealth) { Health -= healthDecrementer; hitSound.Play(); } else { Health = minHealth; } healthText.text = $"Structural Integrity: {Health}%"; if (gameOver == false && Health <= minHealth) { gameOver = true; Health = minHealth; playerController.enabled = false; Launcher.enabled = false; rotateTurret.enabled = false; fire.SetActive(false); explosion.SetActive(true); deathSmoke.SetActive(true); StopAllCoroutines(); tankMaterial.mainTexture = greenTankTexture; medkitSpawnerScript.StopAllCoroutines(); medkitSpawner.SetActive(false); enemySpawnerScript.StopAllCoroutines(); enemySpawner.SetActive(false); powerupSpawnerScript.StopAllCoroutines(); powerupSpawner.SetActive(false); damageSmoke.SetActive(false); engineNoise.enabled = false; HUD.SetActive(false); gameOverScreen.SetActive(true); finalScoreDisplayer.Invoke("ShowFinalScore", 0); } } if (collision.gameObject.CompareTag("Medkit")) { Destroy(collision.gameObject); if (Health < maxHealth) { if (!gameOver) { repairNoise.Play(); } } Health += maxHealth; if (Health >= maxHealth) { Health = maxHealth; } healthText.text = $"Structural Integrity: {Health}%"; } if (collision.gameObject.CompareTag("Powerup")) { if (!gameOver) { repairNoise.Play(); Destroy(collision.gameObject); StartCoroutine("Powerup"); playerController.StartCoroutine("Powerup"); Launcher.StartCoroutine("Powerup"); powerupSpawnerScript.StartCoroutine("PowerupMusic"); } else { Destroy(collision.gameObject); } } if (Health > hiHealth) { healthText.color = hiHealthColor; lowHealthNoise.enabled = false; damageSmoke.SetActive(false); fire.SetActive(false); } else if (Health > loHealth) { healthText.color = medHealthColor; lowHealthNoise.enabled = false; damageSmoke.SetActive(true); fire.SetActive(false); } else if (!gameOver) { healthText.color = loHealthColor; lowHealthNoise.enabled = true; damageSmoke.SetActive(false); fire.SetActive(true); } }