public void Save_record() { GameObject record = transform.GetChild(1).GetChild(4).gameObject; if (!record.activeInHierarchy) { return; } List <int> records = Menu_functions.Read_records(gameObject.scene.name); List <string> record_names = Menu_functions.Read_record_names(gameObject.scene.name); for (int i = 0; i < records.Count + 1; i++) { if ((i == records.Count) || (Time_show.Time_sec() > records[i])) { string name = record.transform.GetChild(2).gameObject.GetComponent <UnityEngine.UI.Text>().text; // not GetChild(1), because the caret appears name = name == "" ? (Translator.language == "russian" ? "Космонавт" : "Cosmonaut") : name; records.Insert(i, Time_show.Time_sec()); record_names.Insert(i, name); break; } } string planet = gameObject.scene.name; for (int i = 0; (i < records.Count) && (i < 5); i++) { PlayerPrefs.SetInt(planet + i.ToString(), records[i]); PlayerPrefs.SetString(planet + i.ToString() + "_name", record_names[i]); } }
public void Game_over() { Cursor.visible = true; Time.timeScale = 0; main_screen.SetActive(false); AudioListener.pause = true; game_over_screen.SetActive(true); game_over_screen.transform.GetChild(2).GetChild(1).gameObject.GetComponent <UnityEngine.UI.Text>().text = Time_show.Time_min_sec(); game_over_screen.transform.GetChild(2).GetChild(2).GetChild(0).gameObject.GetComponent <UnityEngine.UI.Text>().text = Star_counter.stars.ToString(); List <int> records = Menu_functions.Read_records(gameObject.scene.name); if ((records.Count == 0) || records[0] < Time_show.Time_sec()) { game_over_screen.transform.GetChild(4).gameObject.SetActive(true); game_over_screen.transform.GetChild(1).gameObject.SetActive(false); game_over_screen.transform.GetChild(6).gameObject.SetActive(false); game_over_screen.transform.GetChild(7).gameObject.SetActive(true); } else if ((records.Count < Menu_functions.records_count) || (records[records.Count - 1] < Time_show.Time_sec())) { game_over_screen.transform.GetChild(4).gameObject.SetActive(true); game_over_screen.transform.GetChild(1).gameObject.SetActive(false); game_over_screen.transform.GetChild(6).gameObject.SetActive(true); game_over_screen.transform.GetChild(7).gameObject.SetActive(false); } else { game_over_screen.transform.GetChild(4).gameObject.SetActive(false); game_over_screen.transform.GetChild(1).gameObject.SetActive(true); game_over_screen.transform.GetChild(6).gameObject.SetActive(false); game_over_screen.transform.GetChild(7).gameObject.SetActive(false); } }