update
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { _decorator, resources, BufferAsset, Component } from "cc";
|
||||
import {
|
||||
_decorator,
|
||||
resources,
|
||||
BufferAsset,
|
||||
Component,
|
||||
assetManager,
|
||||
AssetManager,
|
||||
} from "cc";
|
||||
import * as cfg from "../../schema/schema";
|
||||
import ByteBuf from "db://assets/Scripts/luban/ByteBuf";
|
||||
|
||||
@@ -22,9 +29,27 @@ export default class ConfigManager extends Component {
|
||||
let promises: Promise<unknown>[] = [];
|
||||
for (let curFileName of ConfigManager.jsonFileNames) {
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
resources.load("test/" + curFileName, BufferAsset, (err, data) => {
|
||||
resolve(data);
|
||||
});
|
||||
let bundle = assetManager.getBundle("DataTable");
|
||||
if (bundle) {
|
||||
bundle.load(curFileName, BufferAsset, (err, data) => {
|
||||
resolve(data);
|
||||
});
|
||||
} else {
|
||||
assetManager.loadBundle(
|
||||
"DataTable",
|
||||
(err: Error, _bundle: AssetManager.Bundle) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
reject && reject(err);
|
||||
return;
|
||||
} else {
|
||||
_bundle.load(curFileName, BufferAsset, (err, data) => {
|
||||
resolve(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
promise.then((data: BufferAsset) => {
|
||||
if (data) {
|
||||
@@ -41,7 +66,7 @@ export default class ConfigManager extends Component {
|
||||
Promise.all(promises).then((values) => {
|
||||
console.log("静态配置加载完成");
|
||||
ConfigManager.tables = new cfg.Tables(this.getFileData);
|
||||
for (let item of ConfigManager.tables.Tbitem.getDataList()) {
|
||||
for (let item of ConfigManager.tables.TbGirls.getDataList()) {
|
||||
console.log(item);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,6 +10,52 @@
|
||||
|
||||
import ByteBuf from '../luban/ByteBuf'
|
||||
|
||||
|
||||
export enum Category {
|
||||
/**
|
||||
* 熟女
|
||||
*/
|
||||
shunv = 0,
|
||||
/**
|
||||
* 18岁
|
||||
*/
|
||||
eighteen = 1,
|
||||
/**
|
||||
* 辣妈
|
||||
*/
|
||||
lama = 2,
|
||||
/**
|
||||
* 捆绑
|
||||
*/
|
||||
kunbang = 3,
|
||||
/**
|
||||
* 公众野战
|
||||
*/
|
||||
publicfight = 4,
|
||||
/**
|
||||
* 卡通
|
||||
*/
|
||||
cartoon = 5,
|
||||
}
|
||||
|
||||
|
||||
|
||||
export enum PriceType {
|
||||
/**
|
||||
* 免费
|
||||
*/
|
||||
free = 0,
|
||||
/**
|
||||
* 试用
|
||||
*/
|
||||
first_time_free = 1,
|
||||
/**
|
||||
* 收费
|
||||
*/
|
||||
pay = 2,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -91,6 +137,56 @@ export class Reward {
|
||||
|
||||
|
||||
|
||||
export class Girls {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this.id = _buf_.readInt()
|
||||
this.name = _buf_.readString()
|
||||
this.age = _buf_.readString()
|
||||
this.category = _buf_.readInt()
|
||||
{ let n = Math.min(_buf_.readSize(), _buf_.size); this.tag = []; for(let i = 0 ; i < n ; i++) { let _e0 ;_e0 = _buf_.readString(); this.tag.push(_e0);}}
|
||||
this.priceType = _buf_.readInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
readonly id: number
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
readonly name: string
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
readonly age: string
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
readonly category: Category
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
readonly tag: string[]
|
||||
/**
|
||||
* 付费类型
|
||||
*/
|
||||
readonly priceType: PriceType
|
||||
|
||||
resolve(tables:Tables) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class vector2 {
|
||||
|
||||
constructor(_buf_: ByteBuf) {
|
||||
@@ -193,6 +289,39 @@ export class TbReward {
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class TbGirls {
|
||||
private _dataMap: Map<number, Girls>
|
||||
private _dataList: Girls[]
|
||||
constructor(_buf_: ByteBuf) {
|
||||
this._dataMap = new Map<number, Girls>()
|
||||
this._dataList = []
|
||||
for(let n = _buf_.readInt(); n > 0; n--) {
|
||||
let _v: Girls
|
||||
_v = new Girls(_buf_)
|
||||
this._dataList.push(_v)
|
||||
this._dataMap.set(_v.id, _v)
|
||||
}
|
||||
}
|
||||
|
||||
getDataMap(): Map<number, Girls> { return this._dataMap; }
|
||||
getDataList(): Girls[] { return this._dataList; }
|
||||
|
||||
get(key: number): Girls | undefined {
|
||||
return this._dataMap.get(key);
|
||||
}
|
||||
|
||||
resolve(tables:Tables) {
|
||||
for(let data of this._dataList)
|
||||
{
|
||||
data.resolve(tables)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export namespace demo {
|
||||
export class Tbitem {
|
||||
private _dataMap: Map<number, demo.item>
|
||||
@@ -232,21 +361,26 @@ type ByteBufLoader = (file: string) => ByteBuf
|
||||
export class Tables {
|
||||
private _TbReward: demo.TbReward
|
||||
get TbReward(): demo.TbReward { return this._TbReward;}
|
||||
private _TbGirls: TbGirls
|
||||
get TbGirls(): TbGirls { return this._TbGirls;}
|
||||
private _Tbitem: demo.Tbitem
|
||||
get Tbitem(): demo.Tbitem { return this._Tbitem;}
|
||||
|
||||
static getTableNames(): string[] {
|
||||
let names: string[] = [];
|
||||
names.push('demo_tbreward');
|
||||
names.push('tbgirls');
|
||||
names.push('demo_tbitem');
|
||||
return names;
|
||||
}
|
||||
|
||||
constructor(loader: ByteBufLoader) {
|
||||
this._TbReward = new demo.TbReward(loader('demo_tbreward'))
|
||||
this._TbGirls = new TbGirls(loader('tbgirls'))
|
||||
this._Tbitem = new demo.Tbitem(loader('demo_tbitem'))
|
||||
|
||||
this._TbReward.resolve(this)
|
||||
this._TbGirls.resolve(this)
|
||||
this._Tbitem.resolve(this)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user