// Update is called once per frame void Update() { if (restart) { if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(0); } } if (tie_destroyed_counter >= 7 && callTIEFighter) { Invoke("SpawnPowerUp", 1); Invoke("SpawnTIEFighter", 4); callTIEFighter = false; } if (tie_destroyed_counter >= 14) { callStarDestroyer = true; } if (callStarDestroyer && star_destroyer_counter == 1) { Invoke("SpawnPowerUp", 1); Invoke("SpawnStarDestroyer1", 3); star_destroyer_counter++; } else if (callStarDestroyer && star_destroyer_counter == 2) { Invoke("SpawnStarDestroyer2", 9); star_destroyer_counter++; } else if (callStarDestroyer && star_destroyer_counter == 3) { Invoke("SpawnStarDestroyer3", 17); star_destroyer_counter++; callStarDestroyer = false; } if (star_destroyer_counter >= 3 && callDeathStar) { callDeathStar = false; Invoke("SpawnDeathStar", 30); } if (DeathStarHP.GetHP() <= 0) { gameOver = true; } if (gameOver) { RestartText.text = "press 'r' for restart"; restart = true; } }
void CrashingDown() { int hp = DeathStarHP.GetHP(); if (hp == 0) { if (!explosion) { Instantiate(DeathStarExplosion, transform.position, Quaternion.identity); explosion = true; } invincible = true; isDestroyed = true; deathStarSpriteRenderer.sprite = DamagedDeathStar; } }