55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class ChestBuildModel
|
|
{
|
|
[SerializeField] public string ChestName;
|
|
|
|
[SerializeField] public GameObject ChestPrefab;
|
|
|
|
[SerializeField] public Vector3 Position;
|
|
|
|
[SerializeField] public List<IndexValuePair<Item>> Content;
|
|
|
|
|
|
public ChestPrefabAsset MapBuildModelToPrefabAssetModel()
|
|
{
|
|
ChestPrefabAsset chestPrefabAsset = new ChestPrefabAsset(
|
|
ChestName,
|
|
ChestPrefab.gameObject.name,
|
|
Position
|
|
);
|
|
|
|
chestPrefabAsset.Chest = new Chest(ChestPrefab.GetComponent<ChestWrapper>().Chest);
|
|
|
|
Debug.Log(chestPrefabAsset.Chest);
|
|
|
|
chestPrefabAsset.Chest.Name = ChestName;
|
|
Debug.Log(chestPrefabAsset.Chest.Name);
|
|
chestPrefabAsset.Chest.Content = new List<IndexValuePair<EquippableItem>>();
|
|
|
|
foreach (var ChestElement in Content)
|
|
{
|
|
var castedObject = ChestElement.Value as EquippableItem;
|
|
|
|
if (castedObject == null)
|
|
chestPrefabAsset.Chest.Content.Add(
|
|
new IndexValuePair<EquippableItem>(ChestElement.Key, new EquippableItem(ChestElement.Value))
|
|
);
|
|
else
|
|
chestPrefabAsset.Chest.Content.Add(
|
|
new IndexValuePair<EquippableItem>(ChestElement.Key, castedObject)
|
|
);
|
|
}
|
|
|
|
Debug.Log(chestPrefabAsset.Chest.Content.Count);
|
|
Debug.Log(chestPrefabAsset.Chest);
|
|
return chestPrefabAsset;
|
|
}
|
|
}
|