File was renamed from Assets/Scripts/SaveData.cs |
| | |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | |
| | | #region player data |
| | | [Serializable] |
| | | public class SaveDataInventorySlot |
| | | { |
| | | public int itemId; |
| | | public string itemName; |
| | | public int quantity; |
| | | |
| | | public SaveDataInventorySlot(InventorySlot slot) |
| | | { |
| | | itemId = slot.item.itemId; |
| | | itemName = slot.item.itemName; |
| | | quantity = slot.quantity; |
| | | } |
| | | } |
| | | [Serializable] |
| | | public class SaveDataPlayer |
| | | { |
| | |
| | | public int health; |
| | | public float[] position; |
| | | public float[] velocity; |
| | | public SaveDataPlayer(PlayerController player) |
| | | public List<SaveDataInventorySlot> inventoryItems; |
| | | |
| | | public SaveDataPlayer(PlayerController player, Inventory inventory) |
| | | { |
| | | maxHealth = player.health.MaxHealth; |
| | | health = player.health.Health; |
| | | position = player.transform.position.ConvertToFloatArray(); |
| | | velocity = player.rb.velocity.ConvertToFloatArray(); |
| | | |
| | | // Save inventory items |
| | | inventoryItems = new List<SaveDataInventorySlot>(); |
| | | foreach (var slot in inventory.items) |
| | | { |
| | | inventoryItems.Add(new SaveDataInventorySlot(slot)); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region map data |
| | | [Serializable] |
| | | public class SaveDataMap |
| | | { |
| | |
| | | } |
| | | public int[] tileCoord; |
| | | } |
| | | #endregion |