12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import GameController from "../GameController"
- import { gameMethod } from "./gameMethod"
- // type for attr.excel
- // type for audio.excel
- export type xlsAudioInfo = {id:string,name:string,vol:number}
- // type for chapter.excel
- export type xlsChapterInfo = {id:int,grid:int[],map:string,name:string}
- export type xlsChapterLayout = {id:int,infoId:int,grid:int,type:int,correlationId:int,unlock:int}
- // type for emitter.excel
- export type xlsEmitterInfo = {id:int,name:string,icon:string,type:int,upLimit:int,restoreInterval:int,restoreNum:int,prop:int[],demand:int[],chargingType:int,chargingCost:int[],expiryTime:int}
- // type for guide.excel
- export type xlsGuideInfo = {id:string,event:string,way:string,variable:number[],ytype:number,condition:number[],type:number,pram:any[],pram1:any[]}
- // type for help.excel
- // type for item.excel
- export type xlsItemKind = {kind:string,name:string}
- export type xlsItemMoney = {id:string,name:string,icon:string,pinzhi:number,desc:string,iconshowtype:number,from:number[],produce:string,type:string,detailType:string,param:{"items"?:number[][],"nums"?:number[],"kv"?:{[key:string]:number},"count"?:number},beibao:number,isUse:number,isShowRed:number,openType:string,price:number}
- // type for kaiqi.excel
- // type for languageClient.excel
- export type xlsLanguageClientText = {key:string,cn:string,us:string,kr:string,tw:string,jp:string}
- // type for languageSever.excel
- export type xlsLanguageSeverHouduan = {}
- // type for language.excel
- export type xlsLanguageLang = {key:string,cn:string,kr:string,tw:string,jp:string}
- // type for level.excel
- // type for math.excel
- export type xlsMathInfo = {key:string,pram:{"count"?:number,"count1"?:number,"str"?:string,"item"?:number[],"items"?:number[][],"kv"?:{[key:string]:number}}}
- // type for mergeProp.excel
- export type xlsMergePropInfo = {id:int,name:string,icon:string,type:int,quality:int}
- // type for name.excel
- // type for package.excel
- export type xlsPackageInfo = {id:string,group:string,plat:string,wayhttp:string,cfgUrl:string,params:any[],logo:string,loadingTips1:string,loadingTips2:string}
- // type for pingbici.excel
- // type for shop.excel
- export class XlsConfig {
- xlsLanguageClientText: xlsLanguageClientText[]
- xlsAudioInfo: xlsAudioInfo[]
- xlsChapterInfo: xlsChapterInfo[]
- xlsChapterLayout: xlsChapterLayout[]
- xlsPackageInfo: xlsPackageInfo[]
- xlsEmitterInfo: xlsEmitterInfo[]
- xlsMergePropInfo: xlsMergePropInfo[]
- xlsGuideInfo: xlsGuideInfo[]
- xlsMathInfo: xlsMathInfo[]
- xlsLanguageSeverHouduan: xlsLanguageSeverHouduan[]
- xlsItemKind: xlsItemKind[]
- xlsItemMoney: xlsItemMoney[]
- xlsLanguageLang: xlsLanguageLang[]
- constructor(bundleName:string, callback: Function, progressCallback?: Function) {
- cc.assetManager.loadBundle(bundleName, (err, bundle) => {
- if (err) {
- GameController.clear()
- cc.game.restart()
- if (progressCallback) {
- progressCallback(0, 0.99);
- }
- return
- }
- if (gameMethod.isEmpty(bundle) && cc.sys.platform == cc.sys.WECHAT_GAME) {
- //小游戏平台,缓存过期,自动清理缓存,重启游戏
- console.error("加载配置表的bundle失败,清理缓存重新加载")
- cc.assetManager.cacheManager.clearCache()
- GameController.clear()
- cc.game.restart()
- if (progressCallback) {
- progressCallback(0, 0.99);
- }
- return
- }
- bundle.loadDir("",(finish: number, total: number, item: any)=>{
- if (progressCallback) {
- progressCallback(finish, total);
- }
- }, (err2, assets: cc.JsonAsset[]) => {
- if (err2) {
- GameController.clear()
- cc.game.restart()
- if (progressCallback) {
- progressCallback(0, 0.99);
- }
- return
- }
- let current = 0;
- assets.forEach(element => {
- this["xls" + this.firstUpCase(element.name)] = element.json;
- current++;
- });
- callback(this)
- })
- })
- }
- // 首字母大写
- private firstUpCase(str: string) {
- return str[0].toUpperCase() + str.substring(1)
- }
- }
|