Ani 第3版

This commit is contained in:
Lenheart 2024-03-09 19:39:20 +08:00
parent ac2b1768e9
commit 350917fb12
3 changed files with 934 additions and 31 deletions

View File

@ -68,7 +68,7 @@ export class ImagePack extends Component {
}); });
} }
NpkHasImg: Map<string, Array<string>> = new Map<string, Array<string>>();
LoadNpk(): void { LoadNpk(): void {
this.BundleObject.loadDir("", BufferAsset, (err, contents: Array<BufferAsset>) => { this.BundleObject.loadDir("", BufferAsset, (err, contents: Array<BufferAsset>) => {
//记录NPK文件数量 //记录NPK文件数量
@ -76,6 +76,7 @@ export class ImagePack extends Component {
console.log(this.NpkCount); console.log(this.NpkCount);
contents.forEach(content => { contents.forEach(content => {
let ImgArr: Array<string> = [];
const Buf = new Uint8Array(content.buffer()); const Buf = new Uint8Array(content.buffer());
const Ro = new ReadStream(Buf); const Ro = new ReadStream(Buf);
//文件头 //文件头
@ -92,6 +93,7 @@ export class ImagePack extends Component {
} }
} }
for (let i = 0; i < ImageCount; i++) { for (let i = 0; i < ImageCount; i++) {
ImgArr.push(ImgList[i].Path);
let Buf: Img = { let Buf: Img = {
ImgOffset: ImgList[i].Offset, ImgOffset: ImgList[i].Offset,
ImgSize: ImgList[i].Length, ImgSize: ImgList[i].Length,
@ -103,18 +105,20 @@ export class ImagePack extends Component {
} }
this.Map_Img.set(ImgList[i].Path, Buf); this.Map_Img.set(ImgList[i].Path, Buf);
} }
this.NpkHasImg.set(content.name, ImgArr);
} }
//完成一个加载 //完成一个加载
this.LoadNpkCount = this.LoadNpkCount + 1; this.LoadNpkCount = this.LoadNpkCount + 1;
//加载完成
if (this.LoadNpkCount == this.NpkCount) {
this.initSuccess();
}
//把本地路径和NPK名称挂钩一下 //把本地路径和NPK名称挂钩一下
this.Npk_URL_Table.set(content.nativeUrl, content.name); this.Npk_URL_Table.set(content.nativeUrl, content.name);
//载入完成以后需要释放 //载入完成以后需要释放
assetManager.releaseAsset(content); assetManager.releaseAsset(content);
//加载完成
if (this.LoadNpkCount == this.NpkCount) {
this.initSuccess();
}
}); });
}); });
} }
@ -295,6 +299,27 @@ export class ImagePack extends Component {
return false; return false;
} }
LoadNpkImgCount = 0;
//读取Npk数据
ReadNpkFile(npkname: string, func: Function): number {
let ImgArr = this.NpkHasImg.get(npkname);
ImgArr.forEach(imgname => {
let ImgObj: Img = this.Map_Img.get(imgname);
if (ImgObj) {
//没有图片数据 需要加载
if (ImgObj.Png_List == null) {
//加载Img进内存
this.LoadImgToMem(ImgObj, func);
}
else {
func(ImgObj);
}
}
});
return ImgArr.length;
}
ReleaseNpkTable(p: Img): void { ReleaseNpkTable(p: Img): void {
// implementation // implementation
} }

View File

@ -22,7 +22,10 @@ export class LodingLogic extends Component {
//Pvf管理器初始化状态 //Pvf管理器初始化状态
PvfManage: boolean = false; PvfManage: boolean = false;
NpkImgCount = 0
NpkImgLoadCount = 0
NpkInitFlag = false;
start() { start() {
//初始化音频Map //初始化音频Map
GlobalAudio.getInstance().Init(() => { GlobalAudio.getInstance().Init(() => {
@ -31,12 +34,18 @@ export class LodingLogic extends Component {
//初始化Npk //初始化Npk
ImagePack.getInstance().init(() => { ImagePack.getInstance().init(() => {
this.NpkManage = true; this.NpkManage = true;
this.NpkImgCount = ImagePack.getInstance().ReadNpkFile("!幻想模拟战", (img) => {
this.NpkImgLoadCount++;
if (this.NpkImgLoadCount >= this.NpkImgCount) this.NpkInitFlag = true;
});
}); });
//初始化Pvf //初始化Pvf
GameScript.getInstance().Init(() => { GameScript.getInstance().Init(() => {
this.PvfManage = true; this.PvfManage = true;
}); });
} }
CheckInitState() { CheckInitState() {
@ -49,12 +58,12 @@ export class LodingLogic extends Component {
update(deltaTime: number) { update(deltaTime: number) {
if (this.CheckInitState() && !this.InitFlag && this.LogoFlag) { if (this.CheckInitState() && !this.InitFlag && this.LogoFlag && this.NpkInitFlag) {
this.scheduleOnce(function () { this.scheduleOnce(function () {
// director.loadScene("LoginGame"); // director.loadScene("LoginGame");
director.preloadScene("main",()=>{ director.preloadScene("main", () => {
director.loadScene("main"); director.loadScene("main");
}); });
}, 0); }, 0);
@ -63,7 +72,7 @@ export class LodingLogic extends Component {
} else { } else {
//每帧调用 //每帧调用
GameScript.getInstance().Update(); GameScript.getInstance().Update();
} }
} }
} }

File diff suppressed because it is too large Load Diff