Umänderungen, Packages installiert
This commit is contained in:
@@ -17,10 +17,10 @@ public class InventoryData
|
||||
//Gems
|
||||
public int gems;
|
||||
|
||||
public int standardHealth;
|
||||
|
||||
public int standardEnergy;
|
||||
|
||||
public int standardHealth;
|
||||
|
||||
public InventoryData(int energy, int health, int gems, int standardHealth, int standardEnergy)
|
||||
{
|
||||
this.energy = energy;
|
||||
@@ -47,10 +47,10 @@ public class InventoryScript : MonoBehaviour
|
||||
//Gems
|
||||
[SerializeField] int gems;
|
||||
|
||||
[SerializeField] int standardHealth;
|
||||
|
||||
[SerializeField] int standardEnergy;
|
||||
|
||||
[SerializeField] int standardHealth;
|
||||
|
||||
|
||||
|
||||
private void Awake()
|
||||
@@ -84,18 +84,19 @@ public class InventoryScript : MonoBehaviour
|
||||
set { gems = value; ValChanged(); }
|
||||
}
|
||||
|
||||
public int StandardHealth
|
||||
{
|
||||
get { return standardHealth; }
|
||||
set { standardHealth = value; ValChanged(); }
|
||||
}
|
||||
|
||||
public int StandardEnergy
|
||||
{
|
||||
get { return standardEnergy; }
|
||||
set { standardEnergy = value; ValChanged(); }
|
||||
}
|
||||
|
||||
public int StandardHealth
|
||||
{
|
||||
get { return standardHealth; }
|
||||
set { standardHealth = value; ValChanged(); }
|
||||
}
|
||||
|
||||
|
||||
// Achtung, ValChanged wird NICHT aufgerufen, wenn man die Werte im Inspector verändert,
|
||||
// weil das nur die Felder, nicht die Properties setzt.
|
||||
// Ändert man aber per Script die Property, wird ValChanged aufgerufen und sofort die Werte ins File gespeichert.
|
||||
@@ -117,10 +118,12 @@ public class InventoryScript : MonoBehaviour
|
||||
energy = inventoryData.energy;
|
||||
health = inventoryData.health;
|
||||
gems = inventoryData.gems;
|
||||
standardEnergy = inventoryData.standardEnergy;
|
||||
standardHealth = inventoryData.standardHealth;
|
||||
}
|
||||
private void SaveInventoryData()
|
||||
{
|
||||
inventoryData = new InventoryData(energy, health, gems, standardHealth, standardEnergy); // erstellt ein neues Objekt InventoryData aus den Werten dieses Scripts
|
||||
inventoryData = new InventoryData(energy, health, gems, standardEnergy, standardHealth); // erstellt ein neues Objekt InventoryData aus den Werten dieses Scripts
|
||||
string datastring = JsonUtility.ToJson(inventoryData); // macht einen JSON String aus diesem Objekt (dafür brauchen wir es auch nur)
|
||||
File.WriteAllText(path, datastring);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user