public bool LoadQuestionsFromFile(string moduleName, Difficulties difficulty) { //Moduldatei laden var mqObject = Persist.Load <ModuleQuestions>("Modules\\" + moduleName); //Prüfen ob Laden geklappt hat if (mqObject == null || !mqObject.Name.Equals(moduleName)) { Debug.LogError("Konnte Moduldatei: " + moduleName + " nicht öffnen/laden!"); return(false); } //Fragen entsprechend des Schwierigkeits abspeichern switch (difficulty) { case Difficulties.Easy: Questions = mqObject.QuestionsEasy; break; case Difficulties.Medium: Questions = mqObject.QuestionsMedium; break; case Difficulties.Hard: Questions = mqObject.QuestionsHard; break; default: Debug.LogError("difficulty = " + difficulty); return(false); } //Questions erfolgreich gesetzt für diesen Spieldurchlauf return(true); }
public List <string> GetModulesWithEnoughQuestionWarningAsList() { var tmpModuleList = new List <string>(module); var allModuls = Persist.GetModuleFiles(); for (var index = 0; index < allModuls.Count; index++) { var modul = allModuls[index]; var loadedModuleFile = Persist.Load <ModuleQuestions>("Modules\\" + modul); if (!loadedModuleFile.HasEnoughQuestions()) { tmpModuleList[index] += " (" + loadedModuleFile.GetCombinedNumberOfQuestions() + "/90 Fragen)"; } } return(tmpModuleList); }
public void AddQuestionToModule(Question q) { var moduleFile = Persist.Load <ModuleQuestions>("Modules\\" + q.Modul); if (moduleFile == null) { throw new FileNotFoundException("Modulfile konnte nicht geladen/geöffnet werden!"); } //Das Speichern sollte ab hier funktionieren - es müssen allerdings noch ein paar Werte angepasst werden: //Bilder hereinladen und Pfade ändern if (!string.IsNullOrEmpty(q.ImagePath)) //Wenn es eine Frage-Bild gibt { q.ImagePath = Persist.CopyPictureToResourcesFolder(q.ImagePath); //schreibt direkt den aktuellen Pfad herein } foreach (var a in q.Answers) { var answerImagePath = a.ImagePath; if (!string.IsNullOrEmpty(answerImagePath)) //Wenn es ein Antwort-Bild gibt { a.ImagePath = Persist.CopyPictureToResourcesFolder(answerImagePath); //siehe oben } } switch (q.Difficulty) { case Difficulties.Easy: moduleFile.QuestionsEasy.Add(q); break; case Difficulties.Medium: moduleFile.QuestionsMedium.Add(q); break; case Difficulties.Hard: moduleFile.QuestionsHard.Add(q); break; default: throw new UnityException("Ungültiger Schwierigkeitsgrad mitgegeben"); } moduleFile.LastUpdated = DateTime.Now.ToLocalTime(); //alle Infos hinzugefügt, jetzt wieder abspeichern Persist.Save(moduleFile, "Modules\\" + q.Modul); Debug.Log("Datei: " + q.Modul + ".dat erfolgreich aktualisiert!"); }
public void LoadGame(string nameOfSavegameFile) { Debug.Log("MyGameState.Load(" + nameOfSavegameFile + ") aufgerufen"); GameStateObject = Persist.Load <GameState>(nameOfSavegameFile); //Weiterleitung zu inbetweenLevels Debug.Log(GameStateObject != null ? "GSO ist nicht null" : "GSO ist null!"); InBetweenLevelsDialogController._firstTimeUseOfScript = true; //Muss resettet werden da sonst falsche Sachen von dem Skript gemacht werden InBetweenLevelsDialogController._loadingASaveGame = true; PlayerScript._loadingASavedGame = true; Master.Instance().MyQuestion.SetQuestionFromSavegame(GameStateObject.LevelState.Questions); //Steinchen-Lotterie an damaligen Stand anpassen //das was der Spieler besitzt oder besessen hat abziehen (0 sonst 1 wenn noch nicht) if (PortalStonePinkIsInPossession || PortalStonePinkHasBeenUsed) { portalStein1 = 0; } if (PortalStoneBlueIsInPossession || PortalStoneBlueHasBeenUsed) { portalStein2 = 0; } if (PortalStoneGreenIsInPossession || PortalStoneGreenHasBeenUsed) { portalStein3 = 0; } //Nachdem man weiß wieviele Portalsteine noch gewonnen werden können var numOfChestsWon = 0; Debug.LogWarning(portalStein2); var numOfPortalStonesWon = portalStein1 + portalStein2 + portalStein3; Debug.LogWarning(portalStein2); numOfPortalStonesWon = 3 - numOfPortalStonesWon; foreach (var chest in ChestCheckArray) { if (chest) // == ist locked { numOfChestsWon++; } } anzahlHinweissteine -= (numOfChestsWon - numOfPortalStonesWon); SceneManager.LoadScene("InBetweenLevels"); EnterNewGameOrSaveGame.Invoke(); }
public List <SavegameInfo> GetAllGSIs() { var listOfSGIFileNames = Persist.GetAllSGIFileNames(); var listOfSGIs = new List <SavegameInfo>(); foreach (var sgiFileName in listOfSGIFileNames) { var sgiFile = Persist.Load <SavegameInfo>("SaveGames\\" + sgiFileName); if (sgiFile != null && sgiFile.GetType() == typeof(SavegameInfo)) { listOfSGIs.Add(Persist.Load <SavegameInfo>("SaveGames\\" + sgiFileName)); } else { Debug.LogWarning("Fehler beim Laden von: " + sgiFileName); } } return(listOfSGIs); }
void Awake() { //Wenn wir in dieser Szene sind muss der Player ebenfalls gekillt werden if (PlayerScript.GetInstance() != null) { Destroy(PlayerScript.GetInstance().gameObject); } //Wenn Spiel gewonnen if (Master.Instance().MyGameState.GameIsWon) { highscoreliste = Persist.Load <List <Highscore> >(Name); if (highscoreliste != null) //Wenn highscores erfolgreich geladen { if (highscoreliste.Count == 0 || (Master.Instance().MyGameState.ScoreCurrent > highscoreliste[highscoreliste.Count - 1].Score)) //TODO reicht es Scores zu vergleichen? Was ist mit der Zeit? //Wenn es noch keine Highscores gibt oder wenn der erreichte Score ein Highscore ist { nextWindow = 11; loseOrWin.text = "Sie haben Gewonnen\nund einen Highscore erzielt!"; } else { nextWindow = 0; loseOrWin.text = "Sie haben Gewonnen"; } } else { Debug.LogError("Laden der HighscoreListe fehlgeschlagen!"); //Debug.Break(); nextWindow = 11; } Debug.Log("Jetzt müsste dort eine Meldung stehen"); } else { loseOrWin.text = "Game over!\n Versuchs Nochmal!"; nextWindow = 0; } }
/// <summary> /// Loads a shortcut from the specified file, and allows flags controlling /// the UI behaviour if the shortcut's target isn't found to be set. If /// no SLR_NO_UI is specified, you can also specify a timeout. /// </summary> /// <param name="linkFile">The shortcut file (.lnk) to load</param> /// <param name="hWnd">The window handle of the application's UI, if any</param> /// <param name="resolveFlags">Flags controlling resolution behaviour</param> /// <param name="timeOut">Timeout if SLR_NO_UI is specified, in ms.</param> public static ShellLink FromFile(string linkFile, IntPtr hWnd, EShellLinkResolveFlags resolveFlags, ushort timeOut) { uint flags; if ((resolveFlags & EShellLinkResolveFlags.SLR_NO_UI) == EShellLinkResolveFlags.SLR_NO_UI) { flags = (uint)((int)resolveFlags | (timeOut << 16)); } else { flags = (uint)resolveFlags; } var ret = new ShellLink(); if (ret.Wrapped.IsPersistFile(out var Persist)) { Persist.Load(linkFile, 0); //STGM_DIRECT) ret.Wrapped.Resolve(hWnd, flags); } return(ret); }
public void NextWindowOnClick() { if (SceneManager.GetActiveScene().name == "InsertHighscoreEndOfGame" || SceneManager.GetActiveScene().name == "InsertHighscoreEndOFGame") { try { if (Persist.Load <List <Highscore> >(Name) == null) { highscoreliste = new List <Highscore>(); } else { highscoreliste = Persist.Load <List <Highscore> >(Name); } } catch (Exception e) { Debug.LogError(e); highscoreliste = new List <Highscore>(); } string time = Master.Instance().MyGameState.TimeTakenUntilNow.Hours.ToString().PadLeft(2, '0') + ":" + Master.Instance().MyGameState.TimeTakenUntilNow.Minutes.ToString().PadLeft(2, '0') + ":" + Master.Instance().MyGameState.TimeTakenUntilNow.Seconds.ToString().PadLeft(2, '0'); Highscore neu = new Highscore() { PlayerName = string.IsNullOrEmpty(playerName.text) ? oldPlayerName.text : playerName.text, Zeit = time, Score = Master.Instance().MyGameState.ScoreCurrent }; highscoreliste.Add(neu); //highscoreliste.OrderBy(x => Convert.ToInt32(x.Score)).Take(10).ToList(); highscoreliste = Order(highscoreliste); Persist.Save <List <Highscore> >(highscoreliste, Name); LeaveWithoutInsert(); //Macht das gleiche } }
private static readonly string Name = @"Highscores\highscores"; //"/Speicher/Highscores/highscoreliste"; // Use this for initialization //nur beim Highscoreboard genutzt private void Awake() { if (SceneManager.GetActiveScene().name == "Highscore") { if (Persist.InitializeHighscoreList()) //if (Persist.Load<List<Highscore>>(Name) != null) -> funktioniert schmeißt aber einen Fehler beim Laden, wenn keine Datei da ist und verursacht im Moment einen Debug.Break() { highscoreliste = Persist.Load <List <Highscore> >(Name); } //Wenn Liste voll ist if (highscoreliste.Count >= 10) { p1.text = " 1. " + highscoreliste[0].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[0].PlayerName.PadRight(20, ' ') + " " + highscoreliste[0].Zeit; p2.text = " 2. " + highscoreliste[1].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[1].PlayerName.PadRight(20, ' ') + " " + highscoreliste[1].Zeit; p3.text = " 3. " + highscoreliste[2].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[2].PlayerName.PadRight(20, ' ') + " " + highscoreliste[2].Zeit; p4.text = " 4. " + highscoreliste[3].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[3].PlayerName.PadRight(20, ' ') + " " + highscoreliste[3].Zeit; p5.text = " 5. " + highscoreliste[4].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[4].PlayerName.PadRight(20, ' ') + " " + highscoreliste[4].Zeit; p6.text = " 6. " + highscoreliste[5].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[5].PlayerName.PadRight(20, ' ') + " " + highscoreliste[5].Zeit; p7.text = " 7. " + highscoreliste[6].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[6].PlayerName.PadRight(20, ' ') + " " + highscoreliste[6].Zeit; p8.text = " 8. " + highscoreliste[7].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[7].PlayerName.PadRight(20, ' ') + " " + highscoreliste[7].Zeit; p9.text = " 9. " + highscoreliste[8].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[8].PlayerName.PadRight(20, ' ') + " " + highscoreliste[8].Zeit; p10.text = "10. " + highscoreliste[9].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[9].PlayerName.PadRight(20, ' ') + " " + highscoreliste[9].Zeit; } //Es git Einträge Liste ist aber nicht voll else if (highscoreliste.Count > 0) { var anzahl = highscoreliste.Count; var i = 0; for (; i < anzahl; i++) { if (i == 0) { p1.text = " 1. " + highscoreliste[0].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[0].PlayerName.PadRight(20, ' ') + " " + highscoreliste[0].Zeit; } if (i == 1) { p2.text = " 2. " + highscoreliste[1].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[1].PlayerName.PadRight(20, ' ') + " " + highscoreliste[1].Zeit; } if (i == 2) { p3.text = " 3. " + highscoreliste[2].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[2].PlayerName.PadRight(20, ' ') + " " + highscoreliste[2].Zeit; } if (i == 3) { p4.text = " 4. " + highscoreliste[3].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[3].PlayerName.PadRight(20, ' ') + " " + highscoreliste[3].Zeit; } if (i == 4) { p5.text = " 5. " + highscoreliste[4].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[4].PlayerName.PadRight(20, ' ') + " " + highscoreliste[4].Zeit; } if (i == 5) { p6.text = " 6. " + highscoreliste[5].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[5].PlayerName.PadRight(20, ' ') + " " + highscoreliste[5].Zeit; } if (i == 6) { p7.text = " 7. " + highscoreliste[6].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[6].PlayerName.PadRight(20, ' ') + " " + highscoreliste[6].Zeit; } if (i == 7) { p8.text = " 8. " + highscoreliste[7].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[7].PlayerName.PadRight(20, ' ') + " " + highscoreliste[7].Zeit; } if (i == 8) { p9.text = " 9. " + highscoreliste[8].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[8].PlayerName.PadRight(20, ' ') + " " + highscoreliste[8].Zeit; } if (i == 9) { p10.text = "10. " + highscoreliste[9].Score.ToString().PadLeft(6, '0') + " " + highscoreliste[9].PlayerName.PadRight(20, ' ') + " " + highscoreliste[9].Zeit; } } //Liste ist leer, es gibt keien Einträge for (; i < 10; i++) { if (i == 0) { p1.text = " 1. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 1) { p2.text = " 2. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 2) { p3.text = " 3. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 3) { p4.text = " 4. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 4) { p5.text = " 5. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 5) { p6.text = " 6. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 6) { p7.text = " 7. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 7) { p8.text = " 8. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 8) { p9.text = " 9. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } if (i == 9) { p10.text = "10. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } } } else { p1.text = " 1. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p2.text = " 2. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p3.text = " 3. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p4.text = " 4. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p5.text = " 5. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p6.text = " 6. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p7.text = " 7. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p8.text = " 8. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p9.text = " 9. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; p10.text = "10. " + 0.ToString().PadLeft(6, '0') + " " + "-empty-".PadRight(20, ' ') + " " + "00:00:00"; } } }
public void Load(Persist gameObject) { gameObject.Load(SavedGameObjects[gameObject.PersistenceKey]); NotifyLoad(gameObject); }