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 {
this.BundleObject.loadDir("", BufferAsset, (err, contents: Array<BufferAsset>) => {
//记录NPK文件数量
@ -76,6 +76,7 @@ export class ImagePack extends Component {
console.log(this.NpkCount);
contents.forEach(content => {
let ImgArr: Array<string> = [];
const Buf = new Uint8Array(content.buffer());
const Ro = new ReadStream(Buf);
//文件头
@ -92,6 +93,7 @@ export class ImagePack extends Component {
}
}
for (let i = 0; i < ImageCount; i++) {
ImgArr.push(ImgList[i].Path);
let Buf: Img = {
ImgOffset: ImgList[i].Offset,
ImgSize: ImgList[i].Length,
@ -103,18 +105,20 @@ export class ImagePack extends Component {
}
this.Map_Img.set(ImgList[i].Path, Buf);
}
this.NpkHasImg.set(content.name, ImgArr);
}
//完成一个加载
this.LoadNpkCount = this.LoadNpkCount + 1;
//加载完成
if (this.LoadNpkCount == this.NpkCount) {
this.initSuccess();
}
//把本地路径和NPK名称挂钩一下
this.Npk_URL_Table.set(content.nativeUrl, content.name);
//载入完成以后需要释放
assetManager.releaseAsset(content);
//加载完成
if (this.LoadNpkCount == this.NpkCount) {
this.initSuccess();
}
});
});
}
@ -295,6 +299,27 @@ export class ImagePack extends Component {
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 {
// implementation
}

View File

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

File diff suppressed because it is too large Load Diff