Scriptum/Assets/Scripts/REFACTORING/Models/Shop/ShopData.cs
kabix09 88ab6bcee7 Add Shop module
Add Shop panel & saving module
2022-12-19 03:34:45 +01:00

56 lines
1.5 KiB
C#

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(); }
}