using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class LevelDataManager : SingleBase<LevelDataManager>
{
public static int panelSize = 9;
static string _bundleName = "prototype";
static string _path = "Data/LevelData/";
static string _idiomPath = "Data/IdiomData/";
public void Init()
{
var dd = GetJsomData<IdiomData>(_idiomPath, "wordInfo");
}
public LevelData LoadLevelData(int id)
{
string fileName = "level_" + id;
return GetJsomData<LevelData>(_path, fileName);
}
private T GetJsomData<T>(string path, string fileName) where T : class
{
TextAsset textAsset = ResourceManagerCenter.GetInstance().LoadAssetToMemory<TextAsset>(path + fileName, _bundleName);
if (textAsset == null || textAsset.bytes == null)
{
Debug.LogError("LoadLevel Data error:" + fileName);
return null;
}
var jo = (JObject)JsonConvert.DeserializeObject(textAsset.text);
string idiom1 = jo["一手遮天"].ToString();
string idiom2 = jo["明明白白"].ToString();
T tt = JsonUtility.FromJson<T>(idiom1);
return tt;
}
}