private void SaveEquipment() { try { string saveData = "[items]" + Environment.NewLine; for (int i = 0; i < equip.equipmentSlots.Count; i++) { if (equip.equipmentSlots[i] != null) { saveData += equip.equipmentSlots[i].GetComponent <UI_Item>().itemID + Environment.NewLine; } else { saveData += "-1" + Environment.NewLine; } } saveData += "[/items]"; string encrypted = USecurity.EncryptString(saveData, encryptPassword); saveData = "0"; PlayerPrefs.SetString(saveName + ".eqm", encrypted); } catch (Exception ex) { Debug.LogException(ex); } }
public void SaveInventory() { try { string saveData = "[ver]" + UI_Inventory.currentVersion + "[/ver]" + Environment.NewLine + "[force_ver]" + forceVer.ToString() + "[/force_ver]" + Environment.NewLine + "[items]" + Environment.NewLine; for (int i = 0; i < inv.allSlots.Count; i++) { if (inv.allSlots[i] != null) { saveData += inv.allSlots[i].GetComponent <UI_Item>().itemID + Environment.NewLine; } else { saveData += "-1" + Environment.NewLine; } } saveData += "[/items]" + Environment.NewLine + "[stack]" + Environment.NewLine; for (int i = 0; i < inv.allSlotsStack.Count; i++) { if (inv.allSlots[i] != null) { saveData += inv.allSlotsStack[i] + Environment.NewLine; } else { saveData += "-1" + Environment.NewLine; } } saveData += "[/stack]" + Environment.NewLine + "[dur]" + Environment.NewLine; for (int i = 0; i < inv.allDur.Count; i++) { if (inv.allSlots[i] != null) { saveData += inv.allDur[i] + Environment.NewLine; } else { saveData += "-1" + Environment.NewLine; } } saveData += "[/dur]" + Environment.NewLine; string encrypted = USecurity.EncryptString(saveData, encryptPassword); saveData = "0"; PlayerPrefs.SetString(saveName, encrypted); } catch (Exception ex) { Debug.LogException(ex); } SaveHotbar(); SaveEquipment(); }
//Don't call this functions seperate, use the SaveInventory / Load Inventory ! private void SaveHotbar() { try { string saveData = "[items]" + Environment.NewLine; for (int i = 0; i < htbar.hotSlotsGO.Count; i++) { if (htbar.hotbarSlots[i] != null) { saveData += htbar.hotbarSlots[i].GetComponent <UI_Item>().itemID + Environment.NewLine; } else { saveData += "-1" + Environment.NewLine; } } saveData += "[/items]" + Environment.NewLine + "[stack]" + Environment.NewLine; for (int i = 0; i < htbar.hotSlotsGO.Count; i++) { if (htbar.hotbarSlots[i] != null) { saveData += htbar.hotbarStack[i] + Environment.NewLine; } else { saveData += "-1" + Environment.NewLine; } } saveData += "[/stack]" + Environment.NewLine + "[dur]" + Environment.NewLine; for (int i = 0; i < htbar.hotSlotsGO.Count; i++) { if (htbar.hotbarSlots[i] != null) { saveData += htbar.hotDurability[i] + Environment.NewLine; } else { saveData += "-1" + Environment.NewLine; } } saveData += "[/dur]"; string encrypted = USecurity.EncryptString(saveData, encryptPassword); saveData = "0"; PlayerPrefs.SetString(saveName + ".htb", encrypted); } catch (Exception ex) { Debug.LogException(ex); } }