Exemple #1
0
    private void Awake()
    {
        // Load Audio Settings from PlayerPrefs and add it to an object of type AudioSettings.
        AudioHandler.AudioSettings myAudioSettings = new AudioHandler.AudioSettings();

        myAudioSettings = SaveHandler <AudioHandler.AudioSettings> .Load(SaveHandler <AudioHandler.AudioSettings> .SaveFileName.audioSettings);



        // Checks if there's an audiosettings at all in playerprefs. if there isnt, set all volume to 100% and saves that to PlayerPrefs

        if (myAudioSettings == null)
        {
            myAudioSettings = new AudioHandler.AudioSettings {
                vfxVolume = 1f
            };



            SaveHandler <AudioHandler.AudioSettings> .Save(myAudioSettings, SaveHandler <AudioHandler.AudioSettings> .SaveFileName.audioSettings);
        }

        if (myAudioSettings.vfxVolume == 1f)
        {
            GameObject.Find("VolumeToggleBtn").GetComponent <Image>().sprite = GameObject.Find("VolumeToggleBtn").GetComponent <Button>().spriteState.selectedSprite;
        }
        else
        {
            GameObject.Find("VolumeToggleBtn").GetComponent <Image>().sprite = GameObject.Find("VolumeToggleBtn").GetComponent <Button>().spriteState.disabledSprite;
        }
    }
Exemple #2
0
    public void AddLevelCompletionInfo(SceneHandler.Scene scene, int score, float time)
    {
        bool sceneExists = false;
        LevelCompletionEntry levelCompletionEntry = new LevelCompletionEntry {
            scene = scene, score = score, time = time
        };
        LevelCompletionInfo levelCompletionInfo = new LevelCompletionInfo();

        levelCompletionInfo = levelCompletionInfo.Load();
        for (int i = 0; i < levelCompletionInfo.LevelCompletionEntryList.Count; i++)
        {
            if (levelCompletionInfo.LevelCompletionEntryList[i].scene == scene)
            {
                sceneExists = true;
                if (levelCompletionInfo.LevelCompletionEntryList[i].score < score)
                {
                    levelCompletionInfo.LevelCompletionEntryList[i] = levelCompletionEntry;
                }
                else if (levelCompletionInfo.LevelCompletionEntryList[i].score == score && levelCompletionInfo.LevelCompletionEntryList[i].time > time)
                {
                    levelCompletionInfo.LevelCompletionEntryList[i] = levelCompletionEntry;
                }
            }
        }

        if (!sceneExists)
        {
            levelCompletionInfo.LevelCompletionEntryList.Add(levelCompletionEntry);
        }
        SaveHandler <LevelCompletionInfo> .Save(levelCompletionInfo, SaveHandler <LevelCompletionInfo> .SaveFileName.levelCompletionInfo);
    }
Exemple #3
0
    public void SortAndTrim(HighScores myTempHighScores)
    {
        for (int i = 0; i < myTempHighScores.highScoreEntryList.Count; i++)
        {
            for (int j = i + 1; j < myTempHighScores.highScoreEntryList.Count; j++)
            {
                if (myTempHighScores.highScoreEntryList[j].score > myTempHighScores.highScoreEntryList[i].score)
                {
                    // Swap
                    HighScores.HighScoreEntry tmp = myTempHighScores.highScoreEntryList[i];
                    myTempHighScores.highScoreEntryList[i] = myTempHighScores.highScoreEntryList[j];
                    myTempHighScores.highScoreEntryList[j] = tmp;
                }
            }
        }

        //// After sorting only keep the top9
        if (myTempHighScores.highScoreEntryList.Count > 9)
        {
            myTempHighScores.highScoreEntryList.RemoveRange(9, myTempHighScores.highScoreEntryList.Count - 9);



            SaveHandler <HighScores> .Save(myTempHighScores, SaveHandler <HighScores> .SaveFileName.highScoreTable);
        }
    }
Exemple #4
0
 public void AttemptAutoSave()
 {
     if (autoSaveEnabled && !loading)
     {
         saveHandler.Save();
     }
 }
Exemple #5
0
    private void AddHighScoreEntry(int score)
    {
        // create HighScoreEntry
        HighScores.HighScoreEntry highScoreEntry = new HighScores.HighScoreEntry {
            score = score
        };


        // Load saved HighScores
        HighScores highScores = SaveHandler <HighScores> .Load(SaveHandler <HighScores> .SaveFileName.highScoreTable);



        // Add new entry to HighScores
        highScores.highScoreEntryList.Add(highScoreEntry);



        // Save updated highscores

        SaveHandler <HighScores> .Save(highScores, SaveHandler <HighScores> .SaveFileName.highScoreTable);

        //string json = JsonUtility.ToJson(highScores);
        //PlayerPrefs.SetString("highScoreTable", json);
        //PlayerPrefs.Save();
    }
    private void Awake()
    {
        // Load Audio Settings from PlayerPrefs and add it to an object of type AudioSettings.
        AudioSettings myAudioSettings = new AudioSettings();

        myAudioSettings = SaveHandler <AudioSettings> .Load(SaveHandler <AudioSettings> .SaveFileName.audioSettings);


        // Checks if there's an audiosettings at all in playerprefs. if there isnt, set all volume to 100% and saves that to PlayerPrefs

        if (myAudioSettings == null)
        {
            myAudioSettings = new AudioSettings {
                vfxVolume = 1f
            };



            SaveHandler <AudioSettings> .Save(myAudioSettings, SaveHandler <AudioSettings> .SaveFileName.audioSettings);
        }



        //Debug.Log("vfx volume " + myAudioSettings.vfxVolume);

        foreach (Sound s in sounds)
        {
            s.source        = gameObject.AddComponent <AudioSource>();
            s.source.clip   = s.clip;
            s.source.volume = s.volume * myAudioSettings.vfxVolume;
            s.source.pitch  = s.pitch;
            s.source.loop   = s.loop;
        }
    }
        private void BtnExportAll_Click(object sender, RoutedEventArgs e)
        {
            _exportingAll = true;
            var saveHandler = new SaveHandler();

            saveHandler.Save(Screens, typeof(List <Screen>), saveHandler.ScreensFile);
            saveHandler.Save(Companions, typeof(List <Companion>), saveHandler.CompanionsFile);
            saveHandler.Save(Items, typeof(List <Item>), saveHandler.ItemsFile);
            saveHandler.Save(Shops, typeof(List <Shop>), saveHandler.ShopsFile);
            _exportingAll = false;
            MessageBox.Show("Everything has been exported successfully!\n\nSee Files:\n\n" +
                            saveHandler.ScreensFile + "\n" +
                            saveHandler.CompanionsFile + "\n" +
                            saveHandler.ItemsFile + "\n" +
                            saveHandler.ShopsFile);
        }
Exemple #8
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "EnemyProjectile")
        {
            Data.ChangePlayerHP();
            int currentHp = Data.GetCurrentHP();
            SaveHandler.Save();

            if (currentHp <= 0)
            {
                foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Enemy"))
                {
                    Destroy(obj);
                }
                foreach (GameObject obj in GameObject.FindGameObjectsWithTag("EnemyProjectile"))
                {
                    Destroy(obj);
                }
                Player.position = Vector2.zero;
                SaveHandler.SaveDefaultValues();
                SaveHandler.LoadAll();
                ShowDeathMenu();
            }
        }
    }
Exemple #9
0
 public void PauseTheGame()
 {
     Time.timeScale = 0;
     PauseText.text = "Pause";
     PauseMenu.SetActive(true);
     SaveHandler.Save();
 }
Exemple #10
0
    private void SavePlayerCurrentNode()
    {
        CurrentNodeInfo myCurrentNodeInfo = new CurrentNodeInfo();

        myCurrentNodeInfo.currentNodePosition = m_PlayerNodeMovement.GetCurrentNode().transform.position;
        myCurrentNodeInfo.currentNodeName     = m_PlayerNodeMovement.GetCurrentNode().GetNodeName();
        SaveHandler <CurrentNodeInfo> .Save(myCurrentNodeInfo, SaveHandler <CurrentNodeInfo> .SaveFileName.currentPlayerNode);
    }
Exemple #11
0
        private void ExitGame()
        {
            SaveData data = new SaveData();

            data.SaveProgress(achControl);
            SaveHandler.Save(data, "save_file"); //!
            game.Exit();
        }
        private void BtnExportShops_Click(object sender, RoutedEventArgs e)
        {
            var saveHandler = new SaveHandler();

            saveHandler.Save(Shops, typeof(List <Shop>), saveHandler.ShopsFile);

            if (!_exportingAll)
            {
                MessageBox.Show("Shops have been exported successfully!\n\nSee File:\n\n" + saveHandler.ShopsFile);
            }
        }
        public void UpdatePlayerInventory2(CombinedWearables combinedWearable, int addOrSubtractAmount)
        {
            var id       = GetName(combinedWearable);
            var wearable = combinedWearable;

            if (!CombinedWearableExists(id))
            {
                wearable = GenerateNewCombinedWearable(wearable);
                combinedWearableDataToSave.Add(id, inventoryData.StatList(wearable));
                temporaryData.Add(id, inventoryData.StatList(wearable));
            }

            wearable.Amount += addOrSubtractAmount;

            EventBroker.Instance().SendMessage(new EventUpdateAmount(id, wearable.Amount));
            if (CombinedWearableAmountIsZero(wearable))
            {
                if (!Predefined(id))
                {
                    combinedWearableDataToSave.Remove(id);
                    temporaryData.Remove(id);
                    UpdateHud(wearable);
                    saveHandler.Save(this);
                    EventBroker.Instance().SendMessage(new EventDestroyCombinedWearable(id));
                    return;
                }
            }

            wearable.ShouldBeInteractable();

            AssignNewValues(id, wearable);

            wearable.ReduceAlpha();

            UpdateHud(wearable);

            combinedWearableDataToSave[id] = temporaryData[id];
            EventBroker.Instance().SendMessage(new EventSortInventory());
            EventBroker.Instance().SendMessage(new EventUpdateAmount(id, Convert.ToInt32(temporaryData[id][InventoryData.Amount])));
            // saveHandler.Save(this);
        }
Exemple #14
0
    public LevelCompletionInfo Load()
    {
        LevelCompletionInfo myTempLevelCompletionInfo;

        myTempLevelCompletionInfo = SaveHandler <LevelCompletionInfo> .Load(SaveHandler <LevelCompletionInfo> .SaveFileName.levelCompletionInfo);

        if (myTempLevelCompletionInfo == null)
        {
            myTempLevelCompletionInfo = new LevelCompletionInfo();
            SaveHandler <LevelCompletionInfo> .Save(myTempLevelCompletionInfo, SaveHandler <LevelCompletionInfo> .SaveFileName.levelCompletionInfo);
        }
        return(myTempLevelCompletionInfo);
    }
Exemple #15
0
    public void Save()
    {
        string errorMessage;

        if (!SaveHandler.Save(out errorMessage))
        {
            DisplayMessage($"Erreur de création de la sauvegarde : {errorMessage}", true);
        }
        else
        {
            isSaved = true;
        }
        //Resume();
    }
Exemple #16
0
    public void AddHighScoreEntry(int score)
    {
        HighScoreEntry highScoreEntry = new HighScoreEntry {
            score = score
        };

        HighScores highScores = new HighScores();

        highScores = highScores.Load();

        highScores.highScoreEntryList.Add(highScoreEntry);

        highScores.SortAndTrim(highScores);

        SaveHandler <HighScores> .Save(highScores, SaveHandler <HighScores> .SaveFileName.highScoreTable);
    }
Exemple #17
0
    public HighScores Load()
    {
        HighScores myTempHighScores;

        myTempHighScores = SaveHandler <HighScores> .Load(SaveHandler <HighScores> .SaveFileName.highScoreTable);


        if (myTempHighScores == null)
        {
            myTempHighScores = new HighScores();
            myTempHighScores.highScoreEntryList = new List <HighScores.HighScoreEntry>()
            {
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
                new HighScores.HighScoreEntry {
                    score = 0
                },
            };

            SaveHandler <HighScores> .Save(myTempHighScores, SaveHandler <HighScores> .SaveFileName.highScoreTable);
        }

        return(myTempHighScores);
    }
Exemple #18
0
 private async void  CheckOsuFolder()
 {
     myLogger.AddLoggerLine("checking osu folder...", Severity.Information);
     if (SAVE_HANDLER.IsDirectoryAvailable == false) // check if the config has the directory in it
     {
         StartupCheck sc   = new StartupCheck();
         string       path = sc.GetDirectoryString();
         if (path == "NOTFOUND")
         {
             myViewModel.OsuFolder = "Osu Folder not found...please specify manually!";
             var controllerMessage = await this.ShowMessageAsync("Oops...", "Could not find your osu directory :( Please specify it manually!", MessageDialogStyle.Affirmative);
         }
         else
         {
             myViewModel.OsuFolder = path;
             SAVE_HANDLER.Save(myViewModel.OsuFolder);
         }
     }
 }
Exemple #19
0
 /// <summary>
 /// Saves the timeStamp to the saveHandler
 /// </summary>
 public void Save()
 {
     saveHandler.Save(this);
 }
 void UpdateFollowers(UpdateFollowersMessage followersMessage)
 {
     followers += followersMessage.amountToUpdate;
     saveHandler.Save(this);
     EventBroker.Instance().SendMessage(new UpdateUIFollowersMessage(followers));
 }
Exemple #21
0
 private static void Save_Prefix(GameV12 p_gameState) => SaveHandler.Save(p_gameState);
 private void SaveInfo()
 {
     SaveHandler <GameSettingsInfo> .Save(myGameSettingsInfo, SaveHandler <GameSettingsInfo> .SaveFileName.gameSettingsInfo);
 }
Exemple #23
0
        public static void TestFileSaving()
        {
            var screen1 = new Screen
            {
                Id = 1,
                ScreenIntroMessage = "Wow, so this is screen 1, eh? A little barren, don't you think?",
                Options            = new List <TextOption>
                {
                    new TextOption
                    {
                        Id            = 1,
                        Text          = "Let's spruce this place up a bit!",
                        ShowCondition = new Condition
                        {
                            Type      = ConditionType.HasGold,
                            Parameter = 10
                        },
                        Actions = new List <Action>
                        {
                            new Action
                            {
                                Type      = ActionType.ChangeScreen,
                                Parameter = 2
                            }
                        }
                    },
                    new TextOption
                    {
                        Id      = 2,
                        Text    = "Meh, I'm bored.",
                        Actions = new List <Action>
                        {
                            new Action
                            {
                                Type = ActionType.EndGame
                            }
                        }
                    }
                }
            };
            var screen2 = new Screen
            {
                Id = 2,
                ScreenIntroMessage = "You bought so many nice things for the room! Too bad you can't see them...",
                Options            = new List <TextOption>
                {
                    new TextOption
                    {
                        Id      = 1,
                        Text    = "Welp... Bye then.",
                        Actions = new List <Action>
                        {
                            new Action
                            {
                                Type      = ActionType.DisplayMessage,
                                Parameter = "It sure was fun having you decorate my room! Goodbye!"
                            },
                            new Action
                            {
                                Type = ActionType.EndGame
                            }
                        }
                    }
                }
            };

            var screens = new List <Screen>();

            screens.Add(screen1);
            screens.Add(screen2);

            var saveHandler = new SaveHandler();

            saveHandler.Save(screens, typeof(List <Screen>), saveHandler.ScreensFile);
        }
 public override void onPress(string args)
 {
     saveHandler.Save();
 }