Scriptum/Assets/Scripts/REFACTORING/Models/Shop/ShopData.cs

56 lines
1.5 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[System.Serializable]
public class ShopData : IModelMapper<Shop>
{
[SerializeField]
public List<IndexValuePair<int, EquippableItemData>> content = new List<IndexValuePair<int, EquippableItemData>>();
[SerializeField]
public string Map;
[SerializeField]
public string NpcName;
public ShopData(Shop shop)
{
Map = shop.Map;
NpcName = shop.Npc;
foreach (IndexValuePair<int, EquippableItem> item in shop.Content)
{
content.Add(
new IndexValuePair<int, EquippableItemData>(item.Key, new EquippableItemData(item.Value))
);
}
}
public Shop MapDataToObject()
{
var shop = new Shop(Map, NpcName);
shop.Content.Clear();
foreach (IndexValuePair<int, EquippableItemData> item in content)
{
var castedObject = item.Value.MapDataToObject() as EquippableItem;
if (castedObject == null)
shop.Content.Add(
new IndexValuePair<int, EquippableItem>(item.Key, new EquippableItem(item.Value.MapDataToObject()))
);
else
shop.Content.Add(
new IndexValuePair<int, EquippableItem>(item.Key, castedObject)
);
}
return shop;
}
public Shop MapDataToObject(string prefarbAssetName) { throw new System.NotImplementedException(); }
}