using UnityEngine; using System.Collections.Generic; using Fungus; using UnityEngine.SceneManagement; namespace Fungus { [System.Serializable] public class SaveHistory { /// /// Version number of current save data format. /// protected const int SaveDataVersion = 1; [SerializeField] protected int version = SaveDataVersion; [SerializeField] protected List savePoints = new List(); #region Public methods public int NumSavePoints { get { return savePoints.Count; } } public void AddSavePoint(string savePointKey, string savePointDescription) { string sceneName = SceneManager.GetActiveScene().name; var savePointData = SavePointData.Encode(savePointKey, savePointDescription, sceneName); savePoints.Add(savePointData); } /// /// Removes the latest save point. /// public void RemoveSavePoint() { if (savePoints.Count > 0) { savePoints.RemoveAt(savePoints.Count - 1); } } public void LoadLatestSavePoint() { if (savePoints.Count > 0) { var savePointData = savePoints[savePoints.Count - 1]; SavePointData.Decode(savePointData); } } public void Clear() { savePoints.Clear(); } #endregion } }