134 lines
3.9 KiB
C#
134 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class SceneChestDataManager : SceneBaseDataManager<ChestPrefabAsset>
|
|
{
|
|
protected override string OBJECT_FOLDER_NAME { get { return "Chest"; } }
|
|
protected override string OBJECT_LIST_NAME { get { return "ChestList"; } }
|
|
|
|
//protected new SceneBaseDataLoader<ChestPrefabAsset> DataLoader { get; set; }
|
|
protected SceneChestBuilder ChestBuilder { get; set; }
|
|
|
|
|
|
|
|
[SerializeField] Chest CurrentChest;
|
|
|
|
[SerializeField] public List<ChestPrefabAssetData> ElementsToBuildOnSceneList = new List<ChestPrefabAssetData>();
|
|
|
|
|
|
[SerializeField] List<ChestPrefabAsset> convertDataToAsset = new List<ChestPrefabAsset>();
|
|
|
|
|
|
// tmp var
|
|
bool NewGame = true;
|
|
|
|
public override void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
|
|
Instance = this;
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
Debug.Log("Start SceneChestData manager");
|
|
|
|
//TaskUIManager.FindOrCreateInstance();
|
|
var chestManager = ChestUIManager.Instance;
|
|
|
|
if (chestManager == null)
|
|
throw new NullReferenceException("ChestUIManager not found!!!");
|
|
|
|
StaticDataList = (new ChestDataListManager()).SetUiManager(ref chestManager);
|
|
DynamicDataList = (new ChestDataListManager()).SetUiManager(ref chestManager);
|
|
|
|
DataLoader = new SceneChestDataLoader(OBJECT_LIST_NAME, OBJECT_FOLDER_NAME);
|
|
|
|
ChestBuilder = new SceneChestBuilder();
|
|
//ChestBuilder.ElementsToBuildOnSceneList = ElementsToBuildOnSceneList;
|
|
|
|
//SaveData(StaticDataList.GetList(), SceneElementTypeEnum.None);
|
|
|
|
//LoadData(SceneElementTypeEnum.None, ref StaticDataList);
|
|
// LoadDynamicData();
|
|
|
|
//inventoryManager.SetList(StaticDataList.GetList());
|
|
|
|
//inventoryManager.OpenPanel();
|
|
|
|
if (NewGame)
|
|
{
|
|
foreach (ChestPrefabAssetData asset in ElementsToBuildOnSceneList) { convertDataToAsset.Add((ChestPrefabAsset)asset.MapDataToPrefabAssetModel()); }
|
|
|
|
ChestBuilder.ElementsToBuildOnSceneList = convertDataToAsset;
|
|
ChestBuilder.BuildList();
|
|
|
|
|
|
DynamicDataList.SetList(convertDataToAsset);
|
|
|
|
List<Chest> tmp = new List<Chest>();
|
|
foreach (ChestPrefabAsset asset in ChestBuilder.ElementsToBuildOnSceneList) { tmp.Add(asset.Chest); }
|
|
|
|
chestManager.SetList(tmp);
|
|
}
|
|
else
|
|
{
|
|
LoadDynamicData();
|
|
|
|
ChestBuilder.ElementsToBuildOnSceneList = DynamicDataList.GetList();
|
|
ChestBuilder.BuildList();
|
|
|
|
List<Chest> tmp = new List<Chest>();
|
|
foreach (ChestPrefabAsset asset in ChestBuilder.ElementsToBuildOnSceneList) { tmp.Add(asset.Chest); }
|
|
|
|
chestManager.SetList(tmp);
|
|
|
|
|
|
|
|
// BuildList();
|
|
|
|
// when chest detect player in near arrea and player press "c"
|
|
// open panel -> chest controller handle Open panel in Scene Chest Manager passing info about what Chest Palyer want to open
|
|
// Manager Build panel and pass info about chest content
|
|
}
|
|
}
|
|
|
|
// TODO - save ChestPrefabAsset (we need to save coords...) but in manager handle Chest data..
|
|
//
|
|
|
|
|
|
|
|
protected SceneBaseDataManager<ChestPrefabAsset> GetObjectType()
|
|
{
|
|
return GameObject.FindObjectOfType<SceneChestDataManager>();
|
|
}
|
|
|
|
protected SceneBaseDataManager<ChestPrefabAsset> CreateInstance(ref GameObject managerGameObject)
|
|
{
|
|
return managerGameObject.AddComponent<SceneChestDataManager>();
|
|
}
|
|
|
|
|
|
// TODO manager api
|
|
// open panel extend function
|
|
// close panel extend function
|
|
|
|
public void OpenPanel(string chestName)
|
|
{
|
|
|
|
}
|
|
// TODO chest api
|
|
// add to chest - find chest by its name np
|
|
// remove from chest - select chest by its name -
|
|
// chesk item in chest - check chest by tis name
|
|
|
|
}
|