public virtual void SelectSlot(int indexNumber)
        {
            if (indexNumber < 0 || indexNumber >= slots.Count)
            {
                return;
            }

            selectedSlot = slots[indexNumber];
            EventSystem.current.SetSelectedGameObject(selectedSlot.gameObject);
        }
        /// <summary>
        /// Assigns the passed save data to the passed slot, changing the former's slot
        /// number if necessary.
        /// </summary>
        public virtual void ForceSetSlotWith(GameSaveData saveData, SaveSlot slot)
        {
            ValidateSaveData(saveData);

            if (slot == null)
            {
                throw new System.ArgumentException("Cannot set save data to a null slot.");
            }

            saveData.SlotNumber = slot.Number;
            slot.SaveData       = saveData;
        }
Пример #3
0
        /// <summary>
        /// Loads the save data assigned to the passed slot. Returns true if successful, false
        /// otherwise.
        /// </summary>
        public virtual bool LoadSave(SaveSlot slot)
        {
            // Validate input.
            if (slot == null)
            {
                throw new System.NullReferenceException("Cannot load save data from a null slot.");
            }

            if (slot.SaveData == null)
            {
                Debug.LogWarning("Cannot load save data from " + slot.name + "; it has no save data assigned to it.");
                return(false);
            }

            return(LoadSave(slot.SaveData));
        }
Пример #4
0
        /// <summary>
        /// Erases the save data linked to the passed slot.
        /// </summary>
        public virtual bool EraseSave(SaveSlot slot)
        {
            if (slot == null)
            {
                Debug.Log("Cannot erase save of a null slot.");
                return(false);
            }

            var saveData = slot.SaveData;

            if (saveData == null)
            {
                Debug.Log(slot.name + " has no save data to delete.");
                return(false);
            }

            return(EraseSave(saveData));
        }
Пример #5
0
        /// <summary>
        /// Creates and registers new save data with the passed slot's number, then writing it to disk
        /// if set to do so. Save replacement may happen depending on the aforementioned number.
        /// </summary>
        public virtual bool AddSave(SaveSlot slot, bool writeToDisk = true)
        {
            if (!savingEnabled)
            {
                if (warnOnUnallowedSave)
                {
                    Debug.LogWarning(this.name + "'s SaveManager is set to not add saves.");
                }
                return(false);
            }

            if (slot == null)
            {
                throw new System.NullReferenceException("Cannot register a save with a null slot's number.");
            }

            return(AddSave(slot.Number, writeToDisk));
        }
 protected virtual void OnSaveSlotClicked(SaveSlot slotClicked)
 {
     selectedSlot = slotClicked;
 }
Пример #7
0
 /// <summary>
 /// Creates and returns save data for the whole game, set for the passed save slot.
 /// </summary>
 public virtual GameSaveData CreateSave(SaveSlot saveSlot)
 {
     return(CreateSave(saveSlot.Number));
 }
 public virtual void LoadFromSlot(SaveSlot slot)
 {
     saveManager.LoadSave(slot);
 }
 public virtual void SaveToSlot(SaveSlot slot)
 {
     saveManager.AddSave(slot, true);
 }
 public virtual void ClearSlot(SaveSlot slot)
 {
     saveManager.EraseSave(slot);
 }