Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CHIN SAVEPOTIONS
- public void SaveUsableItem()
- {
- InventoryUsableItem inventoryUsableItem = new InventoryUsableItem();
- for (int i = 0; i < AppController.instance.InventoryPotions.Count; ++i) {
- EquipableObject equipableObject = AppController.instance.InventoryPotions[i];
- UsableItem item = new UsableItem();
- item.id = equipableObject.ID;
- item.idObject = equipableObject.IDObject;
- item.name = equipableObject._Name;
- item.function = equipableObject._function;
- item.power = equipableObject.PW;
- item.isEquiped = equipableObject._Equipped;
- item.position = equipableObject._position;
- inventoryUsableItem.items.Add(item);
- }
- JsonData InventoryJson = new JsonData();
- //Part d'escriure en arxiu, hi ha dos, per editor i per compilació android, faltara provar en IOS
- #if UNITY_ANDROID && !UNITY_EDITOR
- InventoryJson = JsonMapper.ToJson (inventoryUsableItem);
- if (File.Exists (Application.persistentDataPath + "/InventoryUsableItem.json")) {
- File.Delete (Application.persistentDataPath + "/InventoryUsableItem.json");
- }
- File.WriteAllText (Application.persistentDataPath + "/InventoryUsableItem.json", InventoryJson.ToString ());
- #else
- InventoryJson = JsonMapper.ToJson(inventoryUsableItem);
- File.WriteAllText(Application.dataPath + "/Resources/JSON/InventoryUsableItem.json", InventoryJson.ToString());
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment