Esempio n. 1
0
        public void Save()
        {
            // Create a new Equipment_Data.
            Equipment_Data data = new Equipment_Data();

            // Save the data.
            data.weaponID   = weaponID;
            data.armourID   = armourID;
            data.ringID     = ringID;
            data.braceletID = braceletID;
            // Turn the Equipment_Data to Json data.
            string equipmentToJson = JsonUtility.ToJson(data);

            // Save the information.
            PlayerPrefs.SetString("Equipment", equipmentToJson);
        }
Esempio n. 2
0
        public void Load()
        {
            // Grab the encrypted Equipment string.
            string equipmentJson = PlayerPrefs.GetString("Equipment");

            // IF there is nothing in this string.
            if (String.IsNullOrEmpty(equipmentJson))
            {
                // GTFO of here we done son!
                return;
            }
            // Turn the json data to represent Equipment_Data.
            Equipment_Data data = JsonUtility.FromJson <Equipment_Data> (equipmentJson);

            // IF a weapon exists.
            if (data.weaponID != -1)
            {
                // Set the ID of the weapon.
                weaponID = data.weaponID;
                // Load the weapon Item.
                weapon = database.FetchItemByID(weaponID);
            }
            if (data.armourID != -1)
            {
                // Set the ID of the armour.
                armourID = data.armourID;
                // Load the armour Item.
                armour = database.FetchItemByID(armourID);
            }
            if (data.ringID != -1)
            {
                // Set the ID of the ring.
                ringID = data.ringID;
                // Load the ring Item.
                ring = database.FetchItemByID(ringID);
            }
            if (data.braceletID != -1)
            {
                // Set the ID of the bracelet.
                braceletID = data.braceletID;
                // Load the bracelet Item.
                bracelet = database.FetchItemByID(braceletID);
            }
        }