更新内存优化方案,更新获胜结算界面图和动画
This commit is contained in:
@@ -72,14 +72,30 @@ export class GameConfig {
|
||||
private static sceneLoadRequest = 0;
|
||||
private static cancelBlockLoading: () => void = null;
|
||||
|
||||
static getCurrentLevelBlockDefinitions(): any[] {
|
||||
const blocks = this.BLOCK_INFO && this.BLOCK_INFO[0] ? this.BLOCK_INFO[0] : [];
|
||||
const level: any = this.LEVEL_INFO && this.LEVEL_INFO[0];
|
||||
const result = blocks.slice();
|
||||
const gates = level && Array.isArray(level.spawnGates) ? level.spawnGates : [];
|
||||
for (const gate of gates) {
|
||||
const queue = gate && Array.isArray(gate.spawnQueue) ? gate.spawnQueue : [];
|
||||
for (const item of queue) {
|
||||
if (item && Array.isArray(item.members)) result.push(...item.members);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 只准备当前关图片,不预读或加载下一关图片。 */
|
||||
static prepareBlockWindow(onRemoteRequired?: () => void, stage = "进关"): Promise<boolean> {
|
||||
const blocks = this.BLOCK_INFO && this.BLOCK_INFO[0];
|
||||
if (!blocks || !this.loadedLevelNumber) return Promise.reject(new Error("关卡配置尚未就绪"));
|
||||
const blockInfo = this.BLOCK_INFO && this.BLOCK_INFO[0];
|
||||
const levelInfo = this.LEVEL_INFO && this.LEVEL_INFO[0];
|
||||
if (!blockInfo || !this.loadedLevelNumber) return Promise.reject(new Error("关卡配置尚未就绪"));
|
||||
const blocks = this.getCurrentLevelBlockDefinitions();
|
||||
const currentLevel = this.loadedLevelNumber;
|
||||
return BlockAssetManager.instance.prepareWindow(blocks,
|
||||
{ onRemoteRequired, currentLevel, stage }).then(ready =>
|
||||
ready && this.BLOCK_INFO[0] === blocks);
|
||||
ready && this.BLOCK_INFO[0] === blockInfo && this.LEVEL_INFO[0] === levelInfo);
|
||||
}
|
||||
|
||||
/** 创建时不显示;仅远程图片调用 open。失效请求不能打开或关闭后续请求的 Loading。 */
|
||||
@@ -109,14 +125,32 @@ export class GameConfig {
|
||||
};
|
||||
}
|
||||
|
||||
/** 所有正式进关入口都在当前关图片就绪后才切换 GameScene。 */
|
||||
/** 所有正式进关入口都在弹窗分包及当前关图片就绪后才切换 GameScene。 */
|
||||
static enterGameSceneWhenReady(time = 0): void {
|
||||
const id = ++this.sceneLoadRequest;
|
||||
const scene = cc.director.getScene();
|
||||
const blocks = this.BLOCK_INFO;
|
||||
const isCurrent = () => id === this.sceneLoadRequest && cc.director.getScene() === scene && this.BLOCK_INFO === blocks;
|
||||
const loading = this.createBlockLoading(isCurrent);
|
||||
this.prepareBlockWindow(loading.open).then(ready => {
|
||||
|
||||
if (!GameTool.areGameplayPopupSubpackagesDownloaded()) loading.open();
|
||||
GameTool.ensureGameplayPopupSubpackagesDownloaded().then(popupReady => {
|
||||
if (!isCurrent()) {
|
||||
loading.close();
|
||||
return false;
|
||||
}
|
||||
if (!popupReady) {
|
||||
loading.close();
|
||||
const missing = GameTool.getMissingGameplayPopupSubpackages();
|
||||
this.showBlockLoadError(
|
||||
new Error(`游戏弹窗分包下载失败: ${missing.join(", ")}`),
|
||||
() => this.enterGameSceneWhenReady(time),
|
||||
"游戏界面资源下载失败\n请检查网络,点击此处重试"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return this.prepareBlockWindow(loading.open);
|
||||
}).then(ready => {
|
||||
loading.close();
|
||||
if (!ready || !isCurrent()) return;
|
||||
cc.director.preloadScene("GameScene", error => {
|
||||
@@ -140,8 +174,9 @@ export class GameConfig {
|
||||
}
|
||||
|
||||
/** 不推进关卡、不无限卡在转场;此提示不依赖任何远程图片。 */
|
||||
static showBlockLoadError(error: any, retry: () => void): void {
|
||||
cc.error("方块资源加载失败:", error);
|
||||
static showBlockLoadError(error: any, retry: () => void,
|
||||
messageText = "方块图片加载失败\n请检查网络,点击此处重试"): void {
|
||||
cc.error(messageText, error);
|
||||
const canvas = cc.find("Canvas");
|
||||
if (!canvas || canvas.getChildByName("BlockLoadRetry")) return;
|
||||
const overlay = new cc.Node("BlockLoadRetry");
|
||||
@@ -156,7 +191,7 @@ export class GameConfig {
|
||||
const message = new cc.Node("message");
|
||||
message.parent = overlay;
|
||||
const label = message.addComponent(cc.Label);
|
||||
label.string = "方块图片加载失败\n请检查网络,点击此处重试";
|
||||
label.string = messageText;
|
||||
label.fontSize = 32;
|
||||
label.lineHeight = 48;
|
||||
label.horizontalAlign = cc.Label.HorizontalAlign.CENTER;
|
||||
@@ -445,8 +480,7 @@ export class GameConfig {
|
||||
vibrateOpen: true, //震动
|
||||
coinnum: 0, //每局的金币数
|
||||
paid_user: false, //是否是付费用户
|
||||
version: "1.0.41", //版本号
|
||||
version: "1.0.43", //版本号
|
||||
version: "1.0.44", //版本号
|
||||
shushu_DistinctId: "", //数数访客ID
|
||||
shushu_AccountId: "", //数数账号ID
|
||||
uid: "", //用户和后端唯一id
|
||||
|
||||
Reference in New Issue
Block a user