// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (showLoad == true) { showLoad = false; showMenu = true; return; } if (showSave == true) { if (selectedSaveGameIndex != -99) { selectedSaveGameIndex = -99; Debug.Log("sdf"); } else { showSave = false; showMenu = true; } return; } if (showMenu == true) { showMenu = false; return; } else { if (showLoad == false || showSave == false) { showMenu = true; return; } } } //The classic hotkeys for quicksaving and quickloading if (Input.GetKeyDown(KeyCode.F5)) { slu.SaveGame(slu.quickSaveName); //Use this for quicksaving, which is basically just using a constant savegame name. } if (Input.GetKeyDown(KeyCode.F9)) { slu.LoadGame(slu.quickSaveName); //Use this for quickloading, which is basically just using a constant savegame name. } }
public void ReloadGameStatus() { int activeScene = SceneManager.GetActiveScene().buildIndex; if (postCombatFlag && activeScene == 3) { postCombatFlag = false; slu.LoadGame(slu.quickSaveName); } }
void Start() { audios = GetComponents <AudioSource>(); countSound = audios[0]; goSound = audios[1]; game = GameState.pause; if (gm != null) { slu = gm.GetComponent <SaveLoadUtility>(); slu.LoadGame(ghostSave); } StartCoroutine(Countdown(rotationAngle, rotationTime)); //for (int i = 0; i < 25; i++) { // leaderBoard.Add(new Top10("test", Random.Range(0f, 100f))); //} }
void OnGUI() { if (showMenu == false && showLoad == false && showSave == false) { if (GUILayout.Button("Menu")) { showMenu = true; return; } } if (showMenu == true) { GUILayout.BeginVertical(GUILayout.MinWidth(300)); if (GUILayout.Button("Save")) { showMenu = false; showLoad = false; saveGames = SaveLoad.GetSaveGames(slu.saveGamePath, slu.usePersistentDataPath); showSave = true; return; } if (GUILayout.Button("Load")) { showSave = false; showMenu = false; saveGames = SaveLoad.GetSaveGames(slu.saveGamePath, slu.usePersistentDataPath); if (saveGames.Count >= 0) { showLoad = true; } else { showMenu = true; } return; } if (GUILayout.Button("Close")) { showSave = false; showMenu = false; showLoad = false; return; } if (GUILayout.Button("Exit to Windows")) { Application.Quit(); return; } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); } if (showLoad == true) { GUILayout.BeginVertical(GUILayout.MinWidth(300)); foreach (SaveGame saveGame in saveGames) { if (GUILayout.Button(saveGame.savegameName + " (" + saveGame.saveDate + ")")) { slu.LoadGame(saveGame.savegameName); showLoad = false; return; } } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Back", GUILayout.MaxWidth(100))) { showLoad = false; showMenu = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); } if (showSave == true) { GUILayout.BeginVertical(GUILayout.MinWidth(300)); for (int i = -1; i < saveGames.Count; i++) { if (i == selectedSaveGameIndex) { GUILayout.BeginHorizontal(GUILayout.MinWidth(300)); string str = GUILayout.TextField(saveGameName, GUILayout.MinWidth(200)); if (regularExpression.IsMatch(str)) { if (str.IndexOfAny(newLine) != -1) { //New Line detected if (i >= 0) { SaveLoad.DeleteFile(slu.saveGamePath, saveGames[i].savegameName); } slu.SaveGame(saveGameName, null, null, null); selectedSaveGameIndex = -99; return; } else { saveGameName = str; //All OK, copy } } else { Debug.Log("Irregular expression detected"); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Save", GUILayout.MaxWidth(50))) { if (i >= 0) { SaveLoad.DeleteFile(slu.saveGamePath, saveGames[i].savegameName); } slu.SaveGame(saveGameName, null, null, null); selectedSaveGameIndex = -99; saveGames = SaveLoad.GetSaveGames(slu.saveGamePath, slu.usePersistentDataPath); return; } if (GUILayout.Button("Cancel", GUILayout.MaxWidth(50))) { selectedSaveGameIndex = -99; return; } GUILayout.EndHorizontal(); } else { if (i == -1) { if (GUILayout.Button("(New)")) { selectedSaveGameIndex = i; saveGameName = ""; return; } } else { if (GUILayout.Button(saveGames[i].savegameName + " (" + saveGames[i].saveDate + ")")) { selectedSaveGameIndex = i; saveGameName = saveGames[i].savegameName; return; } } } } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Back", GUILayout.MaxWidth(100))) { if (selectedSaveGameIndex != -99) { selectedSaveGameIndex = -99; } else { showSave = false; showMenu = true; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); } }