Example #1
0
 /// <summary>
 /// Saves the shortcut to the specified file
 /// </summary>
 /// <param name="linkFile">The shortcut file (.lnk)</param>
 public void Save(string linkFile)
 {
     if (Wrapped.IsPersistFile(out var Persist))
     {
         Persist.Save(linkFile, true);
     }
 }
        public void SaveGame(string nameOfSavegameFile)
        {
            //PlayerPos auslesen
            Debug.Log(PlayerPosCurrent);
            Debug.Log(PlayerScript.GetInstance().GetPosition());
            PlayerPosCurrent = PlayerScript.GetInstance().GetPosition();
            Debug.Log(PlayerPosCurrent);

            //Fragen abspeichern
            GameStateObject.LevelState.Questions = Master.Instance().MyQuestion.GetQuestionField();

            var sgi = new SavegameInfo
            {
                ChosenDifficulty = this.DifficultyChosen,
                ChosenModule     = this.ModuleChosen,
                CustomName       = nameOfSavegameFile,
                PlayerName       = this.PlayerName,
            };
            var timeCode = new TimeSpan(DateTime.Now.Ticks).Ticks;

            var gsoFileName = "SaveGames\\" + timeCode + "_gso"; //GameStateObject File
            var sgiFileName = "SaveGames\\" + timeCode + "_sgi"; //SaveGameInfo File

            //in sgi den Link auf sgo speichern & timecode für bessere Erreichbarkeit ablegen
            sgi.FilenameOfGameStateSave = gsoFileName;
            sgi.FilenameOfSaveGameInfo  = sgiFileName;
            sgi.TimeCode = timeCode;

            Persist.Save(GameStateObject, gsoFileName);
            Persist.Save(sgi, sgiFileName);
        }
        public bool CreateNewModuleFile(string newModuleName)
        {
            //.dat Datei zur Speicherung der Fragen anlegen
            var moduleSaveFile = new ModuleQuestions(newModuleName);

            Persist.Save(moduleSaveFile, "Modules\\" + newModuleName);
            var success = Persist.GetModuleFiles().Contains(newModuleName);

            Debug.Log("Erstellen der Modul-Speicher-Datei war erfolgreich? " + success);
            return(success);
        }
Example #4
0
        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 OverwriteGame(SavegameInfo sgi)
        {
            //PlayerPos auslesen
            Debug.Log(PlayerPosCurrent);
            Debug.Log(PlayerScript.GetInstance().GetPosition());
            PlayerPosCurrent = PlayerScript.GetInstance().GetPosition();
            Debug.Log(PlayerPosCurrent);

            //Fragen abspeichern
            GameStateObject.LevelState.Questions = Master.Instance().MyQuestion.GetQuestionField();

            // Zeit abspeichern
            sgi.TimeCode = new TimeSpan(DateTime.Now.Ticks).Ticks;

            Persist.Save(GameStateObject, sgi.FilenameOfGameStateSave);
            Persist.Save(sgi, sgi.FilenameOfSaveGameInfo);
        }
        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
            }
        }