예제 #1
0
        /// <summary>
        /// Choose a save slot. This slot will now act as the active save slot for
        /// any data transactions.
        /// </summary>
        /// <param name="index">The index of the save slot.</param>
        /// <returns>True if the slot exists. False otherwise.</returns>
        public static bool ChooseSlot(int index)
        {
            if (index < 0 || index >= slots.Count)
            {
                return(false);
            }

            activeSlot = slots[index];
            return(true);
        }
예제 #2
0
        /// <summary>
        /// Delete a save slot.
        /// </summary>
        /// <param name="filename">The name of the save file to delete.</param>
        public static void Delete(string filename)
        {
            SaveSlot file = slots.Find((SaveSlot slot) => slot.Name == filename);

            if (file != null)
            {
                file.DeleteFolder();
                slots.Remove(file);
            }
        }
예제 #3
0
        //-------------------------------------------------------------------------
        // Public Interface
        //-------------------------------------------------------------------------

        /// <summary>
        /// Saves game data for a certain save file out to disk.
        /// </summary>
        /// <param name="filename">The name of the save file to save.</param>
        public static bool Save(string filename)
        {
            SaveSlot file = slots.Find((SaveSlot slot) => slot.Name == filename);

            if (file != null)
            {
                return(file.Save());
            }

            return(false);
        }
예제 #4
0
        /// <summary>
        /// Choose a save slot. This slot will now act as the active save slot for
        /// any data transactions.
        /// </summary>
        /// <param name="filename">The name of the slot.</param>
        /// <returns>True if the slot exists. False otherwise.</returns>
        public static bool ChooseSlot(string filename)
        {
            SaveSlot slot = slots.Find((SaveSlot s) => s.Name == filename);

            if (slot != null)
            {
                activeSlot = slot;
                return(true);
            }

            return(false);
        }
예제 #5
0
        /// <summary>
        /// Load the list of available save files.
        /// </summary>
        /// <returns>True if the list of save files was loaded successfully.</returns>
        public static bool LoadSlots()
        {
            string[] paths = Directory.GetDirectories(directory);

            foreach (string path in paths)
            {
                SaveSlot file = new SaveSlot(path);
                slots.Add(file);
            }

            return(true);
        }
예제 #6
0
        /// <summary>
        /// Resets the Save Data system.
        /// </summary>
        /// <param name="ignoreFolders">Do not delete the physical folders.</param>
        public static void Reset(bool ignoreFolders = false)
        {
            activeSlot = null;
            if (!ignoreFolders)
            {
                foreach (SaveSlot slot in slots)
                {
                    slot.DeleteFolder();
                }
            }

            slots = new List <SaveSlot>();
        }
예제 #7
0
        /// <summary>
        /// Creates a new save slot.
        /// </summary>
        /// <param name="filename">The name of the save file to create.</param>
        public static void CreateSlot(string filename)
        {
            string path = IO.Path.Combine(Path, filename);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            SaveSlot file = new SaveSlot(path);

            slots.Add(file);
        }