using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; [System.Serializable] public class ChestPrefarbAssetData { public string name; public string prefarbAssetName; public float[] position; public Dictionary content = new Dictionary(); public ChestPrefarbAssetData(ChestPrefarbAsset chestPrefarbAsset) { name = chestPrefarbAsset.name; prefarbAssetName = chestPrefarbAsset.prefarbAssetName; position = new float[3]; position[0] = chestPrefarbAsset.position.x; position[1] = chestPrefarbAsset.position.y; position[2] = chestPrefarbAsset.position.z; Debug.Log("ChestPrefarbAsset to ChestPrefarbAssetData - " + chestPrefarbAsset.name); foreach(KeyValuePair itemEntry in chestPrefarbAsset.content) { Debug.Log("Slot nr " + itemEntry.Key); this.content[itemEntry.Key] = this.EquippableItemPrefarbAssetToData(itemEntry.Value); } } public EquippableItemPrefarbAssetData EquippableItemPrefarbAssetToData(EquippableItemPrefarbAsset equippableItemPrefarbAsset) { return new EquippableItemPrefarbAssetData(equippableItemPrefarbAsset); } public ChestPrefarbAsset MapDataToChestPrefarbAsset() { ChestPrefarbAsset chestPrefarbAsset = new ChestPrefarbAsset(); chestPrefarbAsset.name = this.name; chestPrefarbAsset.prefarbAssetName = this.prefarbAssetName; chestPrefarbAsset.position = new Vector3(this.position[0], this.position[1], this.position[2]); foreach(KeyValuePair equippableItemPrefarbAssetDataEntry in this.content) { chestPrefarbAsset.content[equippableItemPrefarbAssetDataEntry.Key] = equippableItemPrefarbAssetDataEntry.Value.MapDataToEquippableItemPrefarbAsset(); } return chestPrefarbAsset; } }