Ejemplo n.º 1
0
        public static void LoadFromSave(Creature creature)
        {
            playerCreature = creature;
            if (File.Exists(Path.Combine(Application.streamingAssetsPath, "Mods/IceSpell/Saves/IceStatSave.json")))
            {
                string       json = File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "Mods/IceSpell/Saves/IceStatSave.json"));
                IceStatsJSON ice  = JsonConvert.DeserializeObject <IceStatsJSON>(json);

                level       = ice.level;
                levelPoints = ice.levelPoints;
                xp          = ice.xp;

                foreach (Ability kvp in abilities)
                {
                    if (ice.unlocked.Contains(kvp.abilityEnum))
                    {
                        kvp.Unlock();
                    }
                }

                chargeSpeed = (float)(1f / Math.Pow(1.1f, level));
                spikeSpeed  = (float)(5 + Math.Sqrt(level) / 4);
            }
            else
            {
                SaveToJSON();
            }
        }
Ejemplo n.º 2
0
        public static void SaveToJSON()
        {
            IceStatsJSON ice = new IceStatsJSON()
            {
                level       = level,
                levelPoints = levelPoints,
                xp          = xp
            };

            foreach (KeyValuePair <AbilitiesEnum, Ability> kvp in abilityDict)
            {
                if (kvp.Value.unlocked)
                {
                    ice.unlocked.Add(kvp.Key);
                }
            }

            string json = JsonConvert.SerializeObject(ice, Formatting.Indented);

            File.WriteAllText(Path.Combine(Application.streamingAssetsPath, "Mods/IceSpell/Saves/IceStatSave.json"), json);
        }