// Update is called once per frame void Update() { int minutes = Mathf.FloorToInt(timeLeft / 60F); int seconds = Mathf.FloorToInt(timeLeft - minutes * 60); string niceTime = string.Format("{0:0}:{1:00}", minutes, seconds); countdownText.text = (niceTime); if (timeLeft <= 0) { StopCoroutine("LoseTime"); countdownText.text = "Times Up!"; AllyPortHP = AllyPort.GetComponent <PortHealth> ().health; EnemyPortHP = EnemyPort.GetComponent <PortHealth> ().health; if (EnemyPortHP < AllyPortHP) { gameover.SetActive(true); finalstate.GetComponent <Text> ().text = "Kalah!\nWaktu Habis, Markas mu berhasil dihancurkan"; Time.timeScale = 0; } else if (AllyPortHP < EnemyPortHP) { gameover.SetActive(true); finalstate.GetComponent <Text> ().text = "Menang!\nWaktu habis, Markas musuh berhasil dihancurkan"; Time.timeScale = 0; } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (!isPause) { PauseMenu.SetActive(true); isPause = true; Time.timeScale = 0; } else if (isPause) { PauseMenu.SetActive(false); isPause = false; Time.timeScale = 1; } } AllyPortHP = AllyPort.GetComponent <PortHealth> ().health; EnemyPortHP = EnemyPort.GetComponent <PortHealth> ().health; Scene scene = SceneManager.GetActiveScene(); if (scene.name != "Pengujian") // name of scene { if (AllyPortHP <= 0) { GameOver.SetActive(true); FinalState.GetComponent <Text> ().text = "Kalah!\nMarkasmu sudah dihancurkan musuh"; Time.timeScale = 0; } else if (EnemyPortHP <= 0) { GameOver.SetActive(true); FinalState.GetComponent <Text> ().text = "Menang!\nMarkas musuh berhasil dihancurkan"; Time.timeScale = 0; } } SteelText.text = System.Convert.ToString(GetRes.SteelRes); FuelText.text = System.Convert.ToString(GetRes.FuelRes); }