// Update is called once per frame void Update() { //Update in-game timer saveData = LocalData.UpdateTimer(saveData); //If there are less than 10 seconds in the minute, add a 0 to the front for the width to be consistent if (saveData.getSeconds() < 10) { timerText.text = "" + saveData.getMinutes() + ":0" + saveData.getSeconds(); } else { timerText.text = "" + saveData.getMinutes() + ":" + saveData.getSeconds(); } CheckKeyCollection(); CheckWinState(); }
public static LoadingData UpdateTimer(LoadingData gameData) { gameData.setTimer(gameData.getTimer() + Time.deltaTime); gameData.setSeconds((int)(gameData.getTimer() % 60)); //If the seconds are equal to or more than 60, a minute has passed. Update accordingly if (gameData.getTimer() >= 60) { gameData.setTimer(0); gameData.setMinutes(gameData.getMinutes() + 1); } return(gameData); }//end of UpdateTimer