Exemple #1
0
        /// <summary>
        /// Creates a single SaveDataItem from a single FlowchartData object.
        /// </summary>
        public virtual SaveDataItem CreateItem(FlowchartData data)
        {
            var jsonString = JsonUtility.ToJson(data, true);
            var newItem    = new SaveDataItem(saveType.Name, jsonString);

            return(newItem);
        }
        public virtual SaveDataItem ToSaveDataItem()
        {
            var thisAsJson = JsonUtility.ToJson(this, true);
            var typeOfThis = this.GetType();

            var newItem = new SaveDataItem(typeOfThis.Name, thisAsJson);

            return(newItem);
        }
        public static SaveDataItem CreateFrom <T>(T saveData) where T : SaveData
        {
            var saveType   = typeof(T);
            var dataAsJson = JsonUtility.ToJson(saveData, true);

            var newItem = new SaveDataItem(saveType.Name, dataAsJson);

            return(newItem);
        }
        /// <summary>
        /// Factory method to create a new SaveDataItem.
        /// </summary>
        public static SaveDataItem Create(string dataType, string data)
        {
            var item = new SaveDataItem();

            item.dataType = dataType;
            item.data     = data;

            return(item);
        }
Exemple #5
0
        public override IList <SaveDataItem> CreateItems()
        {
            // Create GameSaveData, and encode it into a SaveDataItem
            var gameSave = CreateSave();
            var jsonSave = JsonUtility.ToJson(gameSave, true);
            var newItem  = new SaveDataItem(saveType.Name, jsonSave);

            // The array has only one element, since we only made one GameSaveData
            return(new SaveDataItem[1] {
                newItem
            });
        }
Exemple #6
0
        public override IList <SaveDataItem> CreateItems()
        {
            // At the time of this writing, the NarrativeLog is a singleton, so we're setting up a
            // one-element array.
            var jsonData   = JsonUtility.ToJson(saveData, true);
            var singleItem = new SaveDataItem(saveType.Name, jsonData);
            var result     = new SaveDataItem[1] {
                singleItem
            };

            return(result);
        }
Exemple #7
0
        /// <summary>
        /// Encodes the passed FlowchartData group into an array of SaveDataItems.
        /// </summary>
        public virtual IList <SaveDataItem> CreateItems(IList <FlowchartData> dataGroup)
        {
            var itemGroup = new SaveDataItem[dataGroup.Count];

            for (int i = 0; i < dataGroup.Count; i++)
            {
                var fcData  = dataGroup[i];
                var newItem = CreateItem(fcData);
                itemGroup[i] = newItem;
            }

            return(itemGroup);
        }
Exemple #8
0
        public override IList <SaveDataItem> CreateItems()
        {
            var saves = CreateSaves();
            var items = new SaveDataItem[saves.Count];

            for (int i = 0; i < saves.Count; i++)
            {
                var currentSave = saves[i];
                items[i] = currentSave.ToSaveDataItem();
            }

            return(items);
        }
Exemple #9
0
        /// <summary>
        /// Encodes the flowcharts in the scene to an array of SaveDataItems, and returns it.
        /// </summary>
        public override IList <SaveDataItem> CreateItems()
        {
            var flowchartSaves = CreateSaves();
            var items          = new SaveDataItem[flowchartSaves.Count];

            for (int i = 0; i < flowchartSaves.Count; i++)
            {
                var flowchartSave = flowchartSaves[i];
                var newItem       = CreateItem(flowchartSave);
                items[i] = newItem;
            }

            return(items);
        }
 /// <summary>
 /// Tries to load the passed item. Returns true if
 /// successful, false otherwise.
 /// </summary>
 public abstract bool Load(SaveDataItem item);