using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; using UnityEngine.SceneManagement; [Serializable] public class ShopBuildModel { [NonSerialized] public string ShopName; // npc name [SerializeField] public List> Content = new List>(); public ShopBuildModel(string ownerName, List> shopContent) { ShopName = ownerName; Content.Clear(); foreach (IndexValuePair item in shopContent) { Content.Add( new IndexValuePair(item.Key, item.Value) ); } } public Shop MapBuildModelToShop() { var shop = new Shop( SceneManager.GetActiveScene().name, ShopName ); shop.Content = new List>(); foreach (var ChestElement in Content) { var castedObject = ChestElement.Value as EquippableItem; if (castedObject == null) shop.Content.Add( new IndexValuePair(ChestElement.Key, new EquippableItem(ChestElement.Value)) ); else shop.Content.Add( new IndexValuePair(ChestElement.Key, castedObject) ); } return shop; } }