public LevelInfoBox CreateLevelInfoBox(Level level, RectTransform parent, LevelInfoBox prefab) { var newPrefabLevelInfoBox = Instantiate(prefab); newPrefabLevelInfoBox.transform.SetParent(parent, false); newPrefabLevelInfoBox.transform.localScale = new Vector3(1, 1, 1); newPrefabLevelInfoBox.name = level.SceneName; var levelNameText = newPrefabLevelInfoBox.GetComponentsInChildren <Text>().First(); levelNameText.text = level.SceneName; var bestTimeText = newPrefabLevelInfoBox.GetComponentsInChildren <Text>().Last(); bestTimeText.text = "Best time: " + TimeFormatter.GetTimeInMmssffFormat(level.BestTime); var tempButton = newPrefabLevelInfoBox.GetComponentInChildren <Button>(); tempButton.onClick.AddListener(() => OnClick((int)level.LevelEnum)); return(newPrefabLevelInfoBox); }
public void CheckIfBestTime() { if (InterfaceHandler.GetTimerTime() < Level.BestTime || Level.BestTime.Equals(0)) { BestLevelTime.SaveBestTimeForLevel(SceneManager.GetActiveScene().buildIndex, InterfaceHandler.GetTimerTime()); InterfaceHandler.SetVictoryScreenText(String.Format("{0} {1}", "New record:", TimeFormatter.GetTimeInMmssffFormat(InterfaceHandler.GetTimerTime()))); InterfaceHandler.SetBestTimeDisplay(InterfaceHandler.GetTimerTime()); } else { InterfaceHandler.SetVictoryScreenText(LanguageManager.Instance.GetTextValue("NoNewRecord")); } }
public string GetTimeInMmssffFormat() { return(TimeFormatter.GetTimeInMmssffFormat(TimeSinceStarted)); }