123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- let GameConstant = require('GameConstant');
- let _BYManagerInstance = null;
- class BYSceneManager {
- loadGameBaseData(wKindID, bundle) {
- //捕鱼单独处理
- this._bundle = bundle;
- this._percent = 0;
- if (cc.director.getScene().name == "byScene") { //BYSCENE
- Global.print("捕鱼正在游戏中,不需要重新创建游戏内核~~~~~~~~~~~~~~");
- cc.vv.inBYGame = true;
- cc.director.getScene().getChildByName("Canvas").getChildByName("BYGameScene").getComponent("BYGameScene").initGame();
- return;
- }
- let arrRes = [];
- let bByGame = false;
- let bBYGame = false;
- if (GameConstant.KIND_ID_BY == wKindID) {
- arrRes = [
- { res: "resourcesPrefab/Public" },
- { res: "resourcesPrefab/Net", funCall: require("BYNetManager") },
- { res: "resourcesPrefab/Bullet", funCall: require("BYBulletManager") },
- { res: "resourcesPrefab/Battery", funCall: require("BYBatteryManager") },
- { res: "resourcesPrefab/ByBg", funCall: require("BYBgManager") },
- { res: "resourcesPrefab/Fish", funCall: require("BYFishManager") },
- { res: "resourcesPrefab/Action", funCall: require("BYActionManager") },
- ]
- bBYGame = true;
- bByGame = true;
- } else if (GameConstant.KIND_ID_BRBYZB == wKindID) {
- //捕鱼争霸
- arrRes = [
- { res: "GamePrefabs/filter-brzb/Public" },
- { res: "GamePrefabs/filter-brzb/Net", funCall: require("BYZBNetManager") },
- { res: "GamePrefabs/filter-brzb/Bullet", funCall: require("BYZBBulletManager") },
- { res: "GamePrefabs/filter-brzb/Battery", funCall: require("BYZBBatteryManager") },
- { res: "GamePrefabs/filter-brzb/Role", funCall: require("BYZBRoleManager") },
- { res: "GamePrefabs/filter-brzb/Action", funCall: require("BYZBActionManager") },
- ]
- bBYGame = true;
- }
- if (bBYGame) {
- cc.vv.gameLoadStart = true;
- cc.find("GoFishNode").getComponent("GoFishLoading").showGoFishScene();
- if (bByGame) {
- bundle.preloadScene("byScene");
- this.loadCount = 0;
- this._percent = 0;
- for (let i = 1; i < arrRes.length; i++) {
- this.loadBYResDir(arrRes[i].res, arrRes[i].funCall, arrRes.length - 1, "byScene", i);
- }
- } else {
- bundle.preloadScene("byChampions");
- for (let i = 1; i < arrRes.length; i++) {
- this.loadBYResDir(arrRes[i].res, arrRes[i].funCall, i == arrRes.length - 1, "byChampions", i);
- }
- }
- return;
- }
- }
- loadBYResDir(strPath, funCall, isFinish, scene, idx) {
- this._bundle.loadDir(strPath, (completedCount, totalCount, item) => {
- if (totalCount > 0) {
- let percent = completedCount / totalCount * 0.1 + idx / isFinish;
- this._percent = percent < this._percent ? this._percent : percent;//防止加载进度条倒退
- cc.find("GoFishNode").getComponent("GoFishLoading").updateProgress(this._percent);
- }
- }, (err, assets) => {
- if (funCall && funCall.init) {
- this.loadCount++;
- assets.sort((a, b) => {
- let nameA = a.name;
- let nameB = b.name;
- if (nameA < nameB) {
- return -1;
- }
- if (nameA > nameB) {
- return 1;
- }
- return 0;
- });
- funCall.init(assets);
- if (this.loadCount >= isFinish) {
- cc.director.loadScene(scene);
- }
- }
- });
- }
- };
- BYSceneManager.Instance = function () {
- if (!_BYManagerInstance) {
- _BYManagerInstance = new BYSceneManager();
- }
- return _BYManagerInstance;
- }
- module.exports = BYSceneManager;
-
|