Juckniz

Untitled

Mar 7th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. //CHIN SAVEPOTIONS
  2. public void SaveUsableItem()
  3. {
  4. InventoryUsableItem inventoryUsableItem = new InventoryUsableItem();
  5. for (int i = 0; i < AppController.instance.InventoryPotions.Count; ++i) {
  6. EquipableObject equipableObject = AppController.instance.InventoryPotions[i];
  7. UsableItem item = new UsableItem();
  8. item.id = equipableObject.ID;
  9. item.idObject = equipableObject.IDObject;
  10. item.name = equipableObject._Name;
  11. item.function = equipableObject._function;
  12. item.power = equipableObject.PW;
  13. item.isEquiped = equipableObject._Equipped;
  14. item.position = equipableObject._position;
  15. inventoryUsableItem.items.Add(item);
  16. }
  17. JsonData InventoryJson = new JsonData();
  18. //Part d'escriure en arxiu, hi ha dos, per editor i per compilació android, faltara provar en IOS
  19. #if UNITY_ANDROID && !UNITY_EDITOR
  20. InventoryJson = JsonMapper.ToJson (inventoryUsableItem);
  21. if (File.Exists (Application.persistentDataPath + "/InventoryUsableItem.json")) {
  22. File.Delete (Application.persistentDataPath + "/InventoryUsableItem.json");
  23. }
  24. File.WriteAllText (Application.persistentDataPath + "/InventoryUsableItem.json", InventoryJson.ToString ());
  25. #else
  26. InventoryJson = JsonMapper.ToJson(inventoryUsableItem);
  27. File.WriteAllText(Application.dataPath + "/Resources/JSON/InventoryUsableItem.json", InventoryJson.ToString());
  28. #endif
  29. }
Advertisement
Add Comment
Please, Sign In to add comment