62 lines
1.4 KiB
C#
62 lines
1.4 KiB
C#
using Cfg;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
using Bright.Serialization;
|
|
using Cfg.Config;
|
|
using System.IO;
|
|
using UnityEngine.Networking;
|
|
using UnityEngine.Events;
|
|
using CaoCao.Runtime;
|
|
using Game.HotFix;
|
|
|
|
public class LubanComponent : GameComponent
|
|
{
|
|
public Tables tables = null;
|
|
|
|
public static string GetConfigBytesPath(string fileName)
|
|
{
|
|
return string.Format($"Assets/GameAssets/LubanTables/{fileName}.bytes", fileName);
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
LoadLocal();
|
|
}
|
|
|
|
private void LoadLocal()
|
|
{
|
|
tables = new Tables(LoadByteBuf);
|
|
}
|
|
|
|
private ByteBuf LoadByteBuf(string file)
|
|
{
|
|
string path = GetConfigBytesPath(file);
|
|
var ta = HotfixEntry.Resources.Load<TextAsset>(path);
|
|
if (ta == null)
|
|
return null;
|
|
|
|
//return new ByteBuf(File.ReadAllBytes(path));
|
|
return new ByteBuf(ta.bytes);
|
|
}
|
|
|
|
|
|
|
|
//Êý¾ÝÏêÇé»ñÈ¡
|
|
public TestData GetMonster(int id)
|
|
{
|
|
if (tables.TbTestMap.DataMap.ContainsKey(id))
|
|
return tables.TbTestMap.Get(id);
|
|
|
|
Debug.LogError($"the TbTestMap is not contain id({id})");
|
|
|
|
return null;
|
|
}
|
|
|
|
public Dictionary<int, TestData> GetTestMap()
|
|
{
|
|
return tables.TbTestMap.DataMap;
|
|
}
|
|
}
|