/** * 游戏初始化 */ import DataMgr from "./data/DataMgr"; import { fguiRes } from "./data/Define"; import PlatMgr from "./game/PlatMgr"; import UILoading from "./UI/UILoading"; import UIMain from "./UI/UIMain"; import { xGame } from "./xGame"; /** * 自定义shader初始化 */ export function InitShader() { } //初始化 export function appInit() { //loading走完后 xGame.context.init(getLoadingResList(), initCallback); } function getLoadingResList() { return [ { url: "fgui/loading_atlas0.png", type: Laya.Loader.IMAGE }, { url: "fgui/loading.obj", type: Laya.Loader.BUFFER } ] } export function getGameResList() { return [ { url: "asset/fgui/game.obj", type: Laya.Loader.BUFFER }, { url: "asset/fgui/game_atlas0.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas0_1.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas0_2.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas0_3.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas10.png", type: Laya.Loader.IMAGE }, // // { url: "asset/fgui/game_atlas_kupwv4tc.png", type: Laya.Loader.IMAGE }, // { url: "asset/fgui/game_atlas_n43d3v3.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas_n43d3v4.png", type: Laya.Loader.IMAGE }, // { url: "asset/fgui/game_atlas_p4tr427.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas_p4tr42b.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas_p4tr42c.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas_p4tr42e.png", type: Laya.Loader.IMAGE }, // { url: "asset/fgui/game_atlas_p7rrv4r8.png", type: Laya.Loader.IMAGE }, // { url: "asset/fgui/game_atlas_p7rrv4rq.png", type: Laya.Loader.IMAGE }, // { url: "asset/fgui/game_atlas_rz5r457.jpg", type: Laya.Loader.IMAGE }, // { url: "asset/fgui/game_atlas_s8sz44t.png", type: Laya.Loader.IMAGE }, { url: "asset/fgui/game_atlas_s8sz44v.png", type: Laya.Loader.IMAGE }, // { url: "asset/fgui/game_atlas_wehi3uc.jpg", type: Laya.Loader.IMAGE }, // //加载json { url: "res/json/npc.json", type: Laya.Loader.JSON }, { url: "res/json/classicCfg.json", type: Laya.Loader.JSON }, { url: "res/json/levelCfg.json", type: Laya.Loader.JSON }, { url: "res/json/placeBallCfg.json", type: Laya.Loader.JSON }, { url: "res/font/arial.ttf", type: Laya.Loader.FONT }, ] } function initCallback() { window["DataMgr"] = DataMgr; DataMgr.Init(); Moyu.init(getPlat(), this, () => { DataMgr.isNewDay(); PlatMgr.initConfig(); // xGame.common.curRankID = Moyu.isWx ? xGame.common.rankID.wxStar : xGame.common.rankID.normalStar; }, true); console.log('zh:开始sm init1 start'); xGame.soundMgr.init(); console.log('zh:开始sm init1 end'); //初始化fgui xGame.uiMgr.init(); xGame.uiMgr.clearTempData(); xGame.uiMgr.bindFUI(fguiRes.loading); //加载loading界面 xGame.uiMgr.Show(UILoading) } export function loadSubRes(callback) { var tab = ["asset", "res", "spine"]; let subDone = 0; for (var i = 0; i < tab.length; i++) { let sub = tab[i]; Moyu.loadSubRes(sub, (pro) => { callback && callback(pro, false); }).then(() => { subDone++; //console.log(sub + " done") if (subDone >= tab.length) callback && callback(1, true); }); } } export function enterGame() { //常驻公共资源 //初始化json xGame.cfgMgr.init(); //本地设置 xGame.soundMgr.onSetting(DataMgr.userData.sound); Moyu.onSetting(DataMgr.userData.sound, DataMgr.userData.vibration); //UIMain xGame.uiMgr.Hide(UILoading); //移除 fgui.UIPackage.removePackage(fguiRes.loading); //加载初始场景 xGame.uiMgr.bindFUI(fguiRes.game); // xGame.uiMgr.Show(UIMain); // if (DataMgr.getNewUser()) Moyu.sendDataEvent("logOn", { newPlayerTime: new Date() }); } function getPlat() { let cfg: MoyuCfg = new MoyuCfg(); cfg.plat = MoyuPlat.web; //cfg.myId = 120; 20250627日Q cfg.myId = 180; cfg.myKey = '8848a885774230a4'; cfg.version = 0; if (window.hasOwnProperty("gamebox")) { cfg.plat = MoyuPlat.f399; cfg.version = 0; } else if (window.hasOwnProperty("ks")) { cfg.plat = MoyuPlat.ks; cfg.version = 0; cfg.ads.ksVideoId = '2300002254_01'; cfg.ads.ksInsertId = '2300002254_02'; } else if (Laya.Browser.onTTMiniGame) { cfg.plat = MoyuPlat.tt; cfg.version = 0; cfg.ads.ttVideoId = '55lg4hiq6cl1i98a01'; cfg.ads.ttInsertId = '163l1f09abb0fm5l05'; cfg.ads.ttBannerId = "349ld7libg2l5h9a3l"; } else if (Laya.Browser.onMiniGame) { cfg.plat = MoyuPlat.wx; cfg.ads.wxBannerId = 'adunit-fb4acc9e4c4d8c7c'; cfg.ads.wxInsertId = 'adunit-1c0437c20853677c'; cfg.ads.wxVideoId = 'adunit-51758e3d8d649e01'; } else if (Laya.Browser.onQQMiniGame) { cfg.plat = MoyuPlat.qq; } else if (Laya.Browser.onQGMiniGame) { cfg.plat = MoyuPlat.op; cfg.ads.opVideoId = '455502'; cfg.ads.opBannerId = '455507'; //cfg.ads.opNativeId=''; } else if (Laya.Browser.onVVMiniGame) { cfg.plat = MoyuPlat.vv; cfg.version = 0; cfg.ads.vvVideoId = '405d0513a3964187bfb37aca09da5f45'; cfg.ads.vvInsertId = '72b18a69075c410986ff16e43fb2b0f0'; cfg.ads.vvBannerId = 'fe2d2b92dbc144e086df5150b7d3d3d1'; //cfg.ads.vvNativeId='8c92c739451a4f28b5eb587a0fe9a02d'; } else if (Laya.Browser.onHWMiniGame) { cfg.plat = MoyuPlat.hw; } else if (window["mz"]) { cfg.plat = MoyuPlat.mz; } else { let cfg = window['conchConfig']; if (cfg) { var os = cfg.getOS(); if (os == "Conch-ios") { cfg.plat = MoyuPlat.ios; } else if (os == "Conch-android") //多android平台需要手动配置 { // cfg.plat=MoyuPlat.t33; // cfg.plat=MoyuPlat.mmy; // cfg.plat=MoyuPlat.xmApk; } } } return cfg; }