此文件格式有了,但是内部参数的意思需要测试才能得出
贴代码吧,此资源类似表格数据,与其他模块相关性不大
using UnityEngine;
using System.Collections;
using System.IO;
using I18N.CJK;
using System.Collections.Generic;
public class MenuResLoader : Singleton {
//文件头 可能是 60 字节 第 53 字节开始 2 字节是项数 +2 字节是除去头 60 字节后文件剩余字节数
//对象[
// [武器]
// [动作]
// [物品]
// [镖物]
// [地图]
// ]
public List<Option> Info = new List<Option>();
public Option FindOpt(int idx, int type)
{
for (int i = 0; i < Info.Count; i++)
{
if (Info[i].Type == type && Info[i].Idx == idx)
return Info[i];
}
return null;
}
public void Init()
{
TextAsset asset = Resources.Load<TextAsset>("Meteor.res");
MemoryStream ms = new MemoryStream(asset.bytes);
BinaryReader binRead = new BinaryReader(ms);
binRead.BaseStream.Seek(52, SeekOrigin.Begin);
int itemCnt = binRead.ReadInt16();
int bytesLeft = binRead.ReadInt16();
binRead.BaseStream.Seek(4, SeekOrigin.Current);
//武器每一项195字节 因为内部名称原因,各个大小不是定长的,可能在195左右
//招式空-45字节 4字节3 4字节招式编号
while (itemCnt != 0)
{
int type = binRead.ReadInt32();
int Idx = binRead.ReadInt32();//包含属性的武器编号
int charLength = binRead.ReadInt32();//包含/0在内的字符串长度是
string iden = "";
if (type == 3 || type == 1)
iden = I18N.CJK.GB18030Encoding.GetEncoding(950).GetString(binRead.ReadBytes(charLength), 0, charLength - 1);
else
iden = I18N.CJK.GB18030Encoding.GetEncoding(936).GetString(binRead.ReadBytes(charLength), 0, charLength - 1);
Debug.Log("type:" + type + ":idx" + Idx + ":" + iden);
int modelLength = binRead.ReadInt32();
string model = "";
if (type == 3 || type == 1)
model = I18N.CJK.GB18030Encoding.GetEncoding(950).GetString(binRead.ReadBytes(modelLength), 0, modelLength - 1);
else
model = I18N.CJK.GB18030Encoding.GetEncoding(936).GetString(binRead.ReadBytes(modelLength), 0, modelLength - 1);
int lastLength = binRead.ReadInt32();
string last = "";
if (type == 3 || type == 1)
last = I18N.CJK.GB18030Encoding.GetEncoding(950).GetString(binRead.ReadBytes(lastLength), 0, lastLength - 1);
else
last = I18N.CJK.GB18030Encoding.GetEncoding(936).GetString(binRead.ReadBytes(lastLength), 0, lastLength - 1);
int firstBodyItemCnt = 0;
int secBodyItemCnt = 0;
Option op = new Option();
op.Type = type;
op.Idx = Idx;
op.Identify = iden;
op.model = model;
firstBodyItemCnt = binRead.ReadInt32();
op.first = new FirstOption[firstBodyItemCnt];
for (int x = 0; x < firstBodyItemCnt; x++)
{
op.first[x] = new FirstOption();
op.first[x].flag[0] = binRead.ReadInt32();
op.first[x].flag[1] = binRead.ReadInt32();
op.first[x].flag[2] = binRead.ReadInt32();
}
secBodyItemCnt = binRead.ReadInt32();
op.second = new SecondOption[secBodyItemCnt];
for (int x = 0; x < secBodyItemCnt; x++)
{
op.second[x] = new SecondOption();
for (int y = 0; y < 10; y++)
{
op.second[x].flag[y] = binRead.ReadInt32();
}
}
Info.Add(op);
itemCnt--;
}
Debug.Log("info loaded");
}
public class Option
{
public int Idx;
public string Identify;
public string model;
public int Type;
public FirstOption[] first;
public SecondOption[] second;
}
public class FirstOption
{
public int[] flag = new int[3];
}
public class SecondOption
{
public int[] flag = new int[10];
}
}
调用 MenuResLoader.Instance.Init();即可读取所有信息,当然前提是把原流星游戏安装目录下的 meteor.res 更改为 meteor.res.bytes 放到工程的 Resources 目录下
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于