This commit is contained in:
PC-20230316NUNE\Administrator
2023-12-07 21:34:26 +08:00
parent 931f580082
commit fae958aac6
5 changed files with 375 additions and 297 deletions

View File

@@ -30,10 +30,10 @@ import { Component } from "cc";
// let APIPath = `http://localhost:8080`
// let WsPath = `ws://localhost:8080/websocket`
let APIPath = `http://192.168.1.23:8080`
let WsPath = `ws://192.168.1.23:8080/websocket`
// let APIPath = `http://192.168.0.113:8080`
// let WsPath = `ws://192.168.0.113:8080/websocket`
// let APIPath = `http://192.168.1.23:8080`
// let WsPath = `ws://192.168.1.23:8080/websocket`
let APIPath = `http://192.168.0.128:8080`
let WsPath = `ws://192.168.0.128:8080/websocket`
// let APIPath = `https://api.pet.jisol.cn`
// let WsPath = `wss://api.pet.jisol.cn/websocket`
@@ -148,7 +148,7 @@ export class JLoaderBattle extends JLoaderSystem{
//资源
resources:{[id:number]:Asset} = {};
foreverResources:number[] = []; //永久资源Id
battleResources:number[] = []; //战斗资源Id
async onInit(): Promise<any> {
@@ -161,28 +161,28 @@ export class JLoaderBattle extends JLoaderSystem{
app.loading.setCurrent(JLoaderBattle.loadingInit);
//默认加载全部资源
await this.loadForeverResources(...TD.TbBattleResource.getDataList());
await this.loadBattleResources(...TD.TbBattleResource.getDataList());
app.loading.ok(JLoaderBattle.loadingInit);
}
//加载永久资源
async loadForeverResources(...ress:TB.TbBattleResource[]){
//加载战斗资源
async loadBattleResources(...ress:TB.TbBattleResource[]){
for (const res of ress) {
await this.loadForeverResource(res);
await this.loadBattleResource(res);
}
}
//加载永久资源
loadForeverResource(res:TB.TbBattleResource){
//加载战斗资源
loadBattleResource(res:TB.TbBattleResource){
return (new Promise<void>(r => {
let Type:new ()=>Asset = [sp.SkeletonData,SpriteFrame][res.type];
this.bundle.load(res.path,Type,(error,data) => {
if(this.foreverResources.indexOf(res.id) < 0){
if(this.battleResources.indexOf(res.id) < 0){
//添加永久资源
this.resources[res.id] = data;
data.addRef();
@@ -213,14 +213,14 @@ export class JLoaderBattle extends JLoaderSystem{
}))
}
//销毁久资源
clearForeverResources(...ress:TB.TbBattleResource[]){
this.foreverResources.forEach(id => {
//销毁久资源
clearBattleResources(...ress:TB.TbBattleResource[]){
this.battleResources.forEach(id => {
if(this.resources[id]){
this.resources[id].decRef();
}
});
this.foreverResources = [];
this.battleResources = [];
this.onUpdateResources();
}