Exemple #1
0
        /// <summary>
        /// Set the active save slot
        /// </summary>
        /// <param name="slot"> Target save slot </param>
        /// <param name="notifyListeners"> Send a message to all saveables to load the new save file </param>
        public static void SetSlot(int slot, bool notifyListeners, SaveGame saveGame = null)
        {
            // if (activeSlot == slot && saveGame == null)
            // {
            //     Debug.LogWarning("Already loaded this slot.");
            //     return;
            // }

            // Ensure the current game is saved, and write it to disk, if that is wanted behaviour.
            if (SaveSettings.Get().autoSaveOnSlotSwitch&& activeSaveGame != null)
            {
                WriteActiveSaveToDisk();
            }

            if (slot < 0 || slot > SaveSettings.Get().maxSaveSlotCount)
            {
                Debug.LogWarning("SaveMaster: Attempted to set illegal slot.");
                return;
            }

            activeSlot     = slot;
            activeSaveGame = (saveGame == null) ? SaveFileUtility.LoadSave(slot, true) : saveGame;

            if (notifyListeners)
            {
                SyncLoad();
            }

            PlayerPrefs.SetInt("SM-LastUsedSlot", slot);
        }
Exemple #2
0
        public static SaveGame GetSave(int slot, bool createIfEmpty = true)
        {
            if (slot == activeSlot)
            {
                return(activeSaveGame);
            }

            return(SaveFileUtility.LoadSave(slot, createIfEmpty));
        }
Exemple #3
0
        /// <summary>
        /// Delete a save file based on a specific slot.
        /// </summary>
        /// <param name="slot"></param>
        public static void DeleteSave(int slot)
        {
            SaveFileUtility.DeleteSave(slot);

            if (slot == activeSlot)
            {
                activeSlot     = -1;
                activeSaveGame = null;
            }
        }
Exemple #4
0
        public IndexUC(IndexForm _mainForm)
        {
            InitializeComponent();
            mainForm = _mainForm;


            //Ici, on gère la récupération de l'avancement possible de l'utilisateur
            evalResult = EvaluationResult.Instance;
            saveFile   = SaveFileUtility.Instance;
            evalResult = saveFile.GetCurrentProgression();
        }
Exemple #5
0
        /// <summary>
        /// Sets the slot, but does not save the data in the previous slot. This is useful if you want to
        /// save the active game to a new save slot. Like in older games such as Half-Life.
        /// </summary>
        /// <param name="slot"> Slot to switch towards, and copy the current save to </param>
        /// <param name="saveGame"> Set this if you want to overwrite a specific save file </param>
        public static void SetSlotAndCopyActiveSave(int slot)
        {
            OnSlotChangeBegin.Invoke(slot);

            activeSlot     = slot;
            activeSaveGame = SaveFileUtility.LoadSave(slot, true);

            SyncReset();
            SyncSave();

            OnSlotChangeDone.Invoke(slot);
        }
Exemple #6
0
        /// <summary>
        /// Attempts to set the slot to the first unused slot. Useful for creating a new game.
        /// </summary>
        /// <param name="notifyListeners"></param>
        /// <param name="slot"></param>
        /// <returns></returns>
        public static bool SetSlotToNewSlot(bool notifyListeners, out int slot)
        {
            int availableSlot = SaveFileUtility.GetAvailableSaveSlot();

            if (availableSlot == -1)
            {
                slot = -1;
                return(false);
            }
            else
            {
                SetSlot(availableSlot, notifyListeners);
                slot = availableSlot;
                return(true);
            }
        }
Exemple #7
0
        public QCMUC(IndexForm _mainForm, int _questionLeft)
        {
            InitializeComponent();

            mainForm        = _mainForm;
            questionHandler = QuestionHandler.Instance;

            questionLeft = _questionLeft;
            evalResult   = EvaluationResult.Instance;
            result       = evalResult.currentScoreQCM;

            //Utilisé pour écrire les résultats
            saveFile = SaveFileUtility.Instance;

            StartEvaluating();
        }
Exemple #8
0
        /// <summary>
        /// Automatically done on application quit or pause.
        /// Exposed in case you still want to manually write the active save.
        /// </summary>
        public static void WriteActiveSaveToDisk()
        {
            if (activeSaveGame != null)
            {
                for (int i = 0; i < saveables.Count; i++)
                {
                    saveables[i].OnSaveRequest(activeSaveGame);
                }

                SaveFileUtility.WriteSave(activeSaveGame, activeSlot);
            }
            else
            {
                if (Time.frameCount != 0)
                {
                    Debug.Log("No save game is currently loaded... So we cannot save it");
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Set the active save slot. (Do note: If you don't want to auto save on slot switch, you can change this in the save setttings)
        /// </summary>
        /// <param name="slot"> Target save slot </param>
        /// <param name="reloadSaveables"> Send a message to all saveables to load the new save file </param>
        public static void SetSlot(int slot, bool reloadSaveables, SaveGame saveGame = null)
        {
            if (activeSlot == slot && saveGame == null)
            {
                Debug.LogWarning("Already loaded this slot.");
                return;
            }

            // Ensure the current game is saved, and write it to disk, if that is wanted behaviour.
            if (SaveSettings.Get().autoSaveOnSlotSwitch&& activeSaveGame != null)
            {
                WriteActiveSaveToDisk();
            }

            if (SaveSettings.Get().cleanSavedPrefabsOnSlotSwitch)
            {
                ClearActiveSavedPrefabs();
            }

            if (slot < 0 || slot > SaveSettings.Get().maxSaveSlotCount)
            {
                Debug.LogWarning("SaveMaster: Attempted to set illegal slot.");
                return;
            }

            OnSlotChangeBegin.Invoke(slot);

            activeSlot     = slot;
            activeSaveGame = (saveGame == null) ? SaveFileUtility.LoadSave(slot, true) : saveGame;

            if (reloadSaveables)
            {
                SyncLoad();
            }

            SyncReset();

            PlayerPrefs.SetInt("SM-LastUsedSlot", slot);

            OnSlotChangeDone.Invoke(slot);
        }
Exemple #10
0
 public static bool IsSlotUsed(int slot)
 {
     return(SaveFileUtility.IsSlotUsed(slot));
 }
Exemple #11
0
 public static int[] GetUsedSlots()
 {
     return(SaveFileUtility.GetUsedSlots());
 }
Exemple #12
0
 /// <summary>
 /// Checks if there are any unused save slots.
 /// </summary>
 /// <returns></returns>
 public static bool HasUnusedSlots()
 {
     return(SaveFileUtility.GetAvailableSaveSlot() != -1);
 }