更新了所有方块和墙壁图片以及墙壁图片的引用,GameScene和homeScene 场景一些UI调动,更新高内存机型的预热机制
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { GAMEPLAY_ATLAS_PATHS } from "../Tool/GameplayAtlasFrames";
|
||||
|
||||
import { MiniGameSdk } from "../../Sdk/MiniGameSdk";
|
||||
import { GameTool } from "../Tool/GameTool";
|
||||
@@ -62,19 +63,25 @@ export class GameConfig {
|
||||
static MESSAGE_MODEL: any;
|
||||
static LOCAL_CACHE_PREFIX = "level_cache_";
|
||||
static MAX_LOCAL_LEVEL = 100;
|
||||
// 直接上传 Block 下的 PNG 和 version.json,不使用 Cocos Bundle 构建产物。
|
||||
// 上传 Block 下的 PNG、三张公共图集对应的 plist 和 version.json,不使用 Bundle 构建产物。
|
||||
static BLOCK_IMAGE_BASE_URL = "https://cdn.pay.nika4games.com/remote/Block/";
|
||||
// 首次启动且远程版本不可用时的默认值;后续以远程 version.json 为准。
|
||||
static BLOCK_IMAGE_VERSION = "1.0.0";
|
||||
static nextEndlessLevel = 0;
|
||||
static locatePositionOnHome = false; // Win 入职按钮返回首页后定位一次。
|
||||
private static loadedLevelNumber = 0;
|
||||
private static levelLoadRequest = 0;
|
||||
private static sceneLoadRequest = 0;
|
||||
private static homeWarmupRequest = 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];
|
||||
return this.collectLevelBlockDefinitions(blocks, level);
|
||||
}
|
||||
|
||||
private static collectLevelBlockDefinitions(blocks: any[], level: any): any[] {
|
||||
const result = blocks.slice();
|
||||
const gates = level && Array.isArray(level.spawnGates) ? level.spawnGates : [];
|
||||
for (const gate of gates) {
|
||||
@@ -86,6 +93,48 @@ export class GameConfig {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** HomeScene 空闲预热:低内存 iOS 只落盘,高内存 iOS 和安卓直接创建纹理。 */
|
||||
static warmupHomeBlockAssets(): Promise<boolean> {
|
||||
const requestId = ++this.homeWarmupRequest;
|
||||
const scene = cc.director.getScene();
|
||||
const otherLevel = Number(this.GM_INFO.otherLevel) || 0;
|
||||
const levelNumber = otherLevel > 0 ? otherLevel : Number(this.GM_INFO.level) + 1;
|
||||
const isCurrent = () => requestId === this.homeWarmupRequest
|
||||
&& cc.director.getScene() === scene
|
||||
&& !!scene && scene.name === "HomeScene";
|
||||
|
||||
if (!isCurrent() || levelNumber < 1 || levelNumber > GameTool.MAX_NORMAL_LEVEL) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
return this.loadLevelFromBundle(levelNumber).then(jsonData => {
|
||||
if (!isCurrent()) return false;
|
||||
const blockInfo = jsonData && jsonData.BLOCK_INFO && jsonData.BLOCK_INFO[0];
|
||||
const levelInfo = jsonData && jsonData.LEVEL_INFO && jsonData.LEVEL_INFO[0];
|
||||
if (!Array.isArray(blockInfo) || !levelInfo) {
|
||||
throw new Error(`关卡${levelNumber}配置无效`);
|
||||
}
|
||||
const blocks = this.collectLevelBlockDefinitions(blockInfo, levelInfo);
|
||||
if (GameTool.shouldPreloadGameplayPopupInstances()) {
|
||||
return BlockAssetManager.instance.prepareWindow(blocks, {
|
||||
currentLevel: levelNumber,
|
||||
stage: "首页内存预热",
|
||||
extraPaths: GAMEPLAY_ATLAS_PATHS,
|
||||
homeWarmup: true,
|
||||
}).then(ready => {
|
||||
if (ready && isCurrent()) {
|
||||
console.log(`[Block图片][首页内存预热] 当前关${levelNumber}完成`);
|
||||
}
|
||||
return ready && isCurrent();
|
||||
});
|
||||
}
|
||||
return BlockAssetManager.instance.cacheWindowFiles(blocks, GAMEPLAY_ATLAS_PATHS);
|
||||
}).catch(error => {
|
||||
if (isCurrent()) cc.warn(`[Block图片][首页预热] 当前关${levelNumber}失败`, error);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/** 只准备当前关图片,不预读或加载下一关图片。 */
|
||||
static prepareBlockWindow(onRemoteRequired?: () => void, stage = "进关"): Promise<boolean> {
|
||||
const blockInfo = this.BLOCK_INFO && this.BLOCK_INFO[0];
|
||||
@@ -94,7 +143,7 @@ export class GameConfig {
|
||||
const blocks = this.getCurrentLevelBlockDefinitions();
|
||||
const currentLevel = this.loadedLevelNumber;
|
||||
return BlockAssetManager.instance.prepareWindow(blocks,
|
||||
{ onRemoteRequired, currentLevel, stage }).then(ready =>
|
||||
{ onRemoteRequired, currentLevel, stage, extraPaths: GAMEPLAY_ATLAS_PATHS }).then(ready =>
|
||||
ready && this.BLOCK_INFO[0] === blockInfo && this.LEVEL_INFO[0] === levelInfo);
|
||||
}
|
||||
|
||||
@@ -160,7 +209,21 @@ export class GameConfig {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (isCurrent()) cc.director.loadScene("GameScene");
|
||||
if (!isCurrent()) return;
|
||||
const retainPopupBundles = !!scene && scene.name === "GameScene"
|
||||
&& GameTool.beginGameplayPopupGameSceneReloadRetention();
|
||||
try {
|
||||
cc.director.loadScene("GameScene", () => {
|
||||
if (retainPopupBundles) {
|
||||
GameTool.finishGameplayPopupGameSceneReloadRetention();
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
if (retainPopupBundles) {
|
||||
GameTool.finishGameplayPopupGameSceneReloadRetention();
|
||||
}
|
||||
this.showBlockLoadError(error, () => this.enterGameSceneWhenReady(time));
|
||||
}
|
||||
}, time);
|
||||
});
|
||||
}).catch(error => {
|
||||
@@ -480,7 +543,7 @@ export class GameConfig {
|
||||
vibrateOpen: true, //震动
|
||||
coinnum: 0, //每局的金币数
|
||||
paid_user: false, //是否是付费用户
|
||||
version: "1.0.45", //版本号
|
||||
version: "1.0.47", //版本号
|
||||
shushu_DistinctId: "", //数数访客ID
|
||||
shushu_AccountId: "", //数数账号ID
|
||||
uid: "", //用户和后端唯一id
|
||||
@@ -1128,4 +1191,3 @@ export class GameConfig {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user