Example #1
0
        /**
         * This deserializes a byte stream we've retrieved from other sources (used on the main menu)
         */
        public static bool LoadFromBytes(byte[] bytes, out DeathRunSaveData target)
        {
            try
            {
                string @jsonData = Encoding.UTF8.GetString(bytes);

                var jsonSerializerSettings = new JsonSerializerSettings
                {
                    MissingMemberHandling = MissingMemberHandling.Ignore,
                    NullValueHandling     = NullValueHandling.Ignore,
                };


                // This deserializes the whole saveData object all at once.
                target = JsonConvert.DeserializeObject <DeathRunSaveData>(jsonData, jsonSerializerSettings);
            }
            catch (Exception e)
            {
                CattleLogger.GenericError(e);
                CattleLogger.Message("Death Run thumbnail data not found - using defaults");
                CattleLogger.Message(e.StackTrace);

                target = null;
                return(false);
            }

            return(true);
        }
Example #2
0
        public static void RegisterSave(string slotName, DeathRunSaveData saveData)
        {
            DeathRunSaveData already = new DeathRunSaveData();

            if (saveList.TryGetValue(slotName, out already))
            {
                saveList.Remove(slotName);
            }

            try
            {
                saveList.Add(slotName, saveData);
            }
            catch (Exception ex)
            {
                CattleLogger.Message("Failed to add to dictionary");
                CattleLogger.GenericError(ex);
            }
        }
Example #3
0
 public void updateFromSave(DeathRunSaveData saveData)
 {
     RunTime = saveData.playerSave.allLives;
     Deaths  = saveData.playerSave.numDeaths + 1;
     calcScore();
 }