|
@@ -0,0 +1,647 @@
|
|
|
+import SpineMgr from "../core/mgrs/SpineMgr";
|
|
|
+import DataMgr from "../data/DataMgr";
|
|
|
+import { CHANGE_SECRETARY, GameMode, GET_USER_INFO, RESTART_GAME, keyForLoginInfo } from "../data/Define";
|
|
|
+import UIBase from "../fgui/core/UIBase";
|
|
|
+import ui_UIMain from "../fgui/res/game/ui_UIMain";
|
|
|
+import PlatMgr from "../game/PlatMgr";
|
|
|
+import { xGame } from "../xGame";
|
|
|
+import MoneyNode from "./item/MoneyNode";
|
|
|
+import SettingNode from "./item/SettingNode";
|
|
|
+import UIAddProp from "./UIAddProp";
|
|
|
+import UIDraw from "./UIDraw";
|
|
|
+import { UIGame } from "./UIGame";
|
|
|
+import UIGameEnd from "./UIGameEnd";
|
|
|
+import UIInvitation from "./UIInvitation";
|
|
|
+import UILevelDisplay from "./UILevelDisplay";
|
|
|
+import UIMatching from "./UIMatching";
|
|
|
+import UIRanking from "./UIRanking";
|
|
|
+import UISecretary from "./UISecretary";
|
|
|
+import UIShop from "./UIShop";
|
|
|
+import UISign from "./UISign";
|
|
|
+import UISkill from "./UISkill";
|
|
|
+import UIMsg from "./UIMsg";
|
|
|
+import UIModeSelection from "./UIModeSelection";
|
|
|
+import GlobalManager from "../utils/GlobalManager";
|
|
|
+import JSBridgeUtils from "../utils/JSBridgeUtils";
|
|
|
+import SkillDisplay from "./item/SkillDisplay";
|
|
|
+import UIReg from "./UIReg";
|
|
|
+import UILogin from "./UILogin";
|
|
|
+import UIFuli1 from "./UIFuli1";
|
|
|
+import UIFuli2 from "./UIFuli2";
|
|
|
+import UITry from "./UITry";
|
|
|
+import UIPower from "./UIPower";
|
|
|
+import UIGetAward from "./UIGetAward";
|
|
|
+import UIRepentProp from "./UIRepentProp";
|
|
|
+import UIBox from "./UIBox";
|
|
|
+import UIAddCoin from "./UIAddCoin";
|
|
|
+import { NoInternetDialog } from "./NoInternetDialog";
|
|
|
+//import NetCheckTool from "../utils/NetCheckTool";
|
|
|
+import { LocalStorageManager } from "../utils/LocalStorageManager";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+export default class UIMain extends UIBase {
|
|
|
+ public ui: ui_UIMain;
|
|
|
+ public settingNode: SettingNode;
|
|
|
+ public moneyNode: MoneyNode;
|
|
|
+ public firstEnter = true;
|
|
|
+
|
|
|
+ nativeCallJs(msg: string) {
|
|
|
+ let t = msg;
|
|
|
+ console.log("zh: nativeCallJs 奖励开始发放:", t);
|
|
|
+ //GlobalManager.instance.callMethod(msg)
|
|
|
+
|
|
|
+ switch (t) {
|
|
|
+ case 'qjff_chouJiang':
|
|
|
+ let dui = <UIDraw>xGame.uiMgr.getUI(UIDraw);
|
|
|
+ dui.qjff_chouJiang();
|
|
|
+ break;
|
|
|
+ case 'qjff_AD_for_uisign':
|
|
|
+ let dui2 = <UISign>xGame.uiMgr.getUI(UISign);
|
|
|
+ dui2.qjff_AD_for_uisign();
|
|
|
+ break;
|
|
|
+ case 'qjff_AD_for_uitry':
|
|
|
+ let dui3 = <UITry>xGame.uiMgr.getUI(UITry);
|
|
|
+ dui3.qjff_AD_for_uitry();
|
|
|
+ break;
|
|
|
+ case 'qjff_AD_for_uipower':
|
|
|
+ let dui4 = <UIPower>xGame.uiMgr.getUI(UIPower);
|
|
|
+ dui4.qjff_AD_for_uipower();
|
|
|
+ break;
|
|
|
+ case 'qjff_AD_for_uigetAward':
|
|
|
+ let dui5 = <UIGetAward>xGame.uiMgr.getUI(UIGetAward);
|
|
|
+ dui5.qjff_AD_for_uigetAward();
|
|
|
+ break;
|
|
|
+ case 'qjff_AD_for_uiGameEnd':
|
|
|
+ let temp_level = Laya.LocalStorage.getItem('temp_qjff_AD_for_uiGameEnd_level');
|
|
|
+ let dui6 = <UIGameEnd>xGame.uiMgr.getUI(UIGameEnd);
|
|
|
+ dui6.qjff_AD_for_uiGameEnd(parseInt(temp_level))
|
|
|
+ break;
|
|
|
+ case 'qjff_AD_for_uiAddProp_videoGetDiamond':
|
|
|
+
|
|
|
+ let dui7 = <UIAddProp>xGame.uiMgr.getUI(UIAddProp);
|
|
|
+ dui7.qjff_AD_for_uiAddProp_videoGetDiamond();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'qjff_AD_for_uiAddProp_videoGetCoin':
|
|
|
+ let dui8 = <UIAddProp>xGame.uiMgr.getUI(UIAddProp);
|
|
|
+ dui8.qjff_AD_for_uiAddProp_videoGetCoin();
|
|
|
+ break;
|
|
|
+ case 'qjff_AD_for_UIrepentProp_videoRegret':
|
|
|
+ let dui9 = <UIRepentProp>xGame.uiMgr.getUI(UIRepentProp);
|
|
|
+ dui9.qjff_AD_for_UIrepentProp_videoRegret();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'qjff_AD_for_UIrepentProp_videoAddHelpLine':
|
|
|
+ let dui10 = <UIRepentProp>xGame.uiMgr.getUI(UIRepentProp);
|
|
|
+ dui10.qjff_AD_for_UIrepentProp_videoAddHelpLine();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'qjff_AD_for_UIBOX_onOpenBox':
|
|
|
+ let dui11 = <UIBox>xGame.uiMgr.getUI(UIBox);
|
|
|
+ dui11.qjff_AD_for_UIBOX_onOpenBox();
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'qjff_AD_for_UIAddCoin':
|
|
|
+ let dui12 = <UIAddCoin>xGame.uiMgr.getUI(UIAddCoin);
|
|
|
+ dui12.qjff_AD_for_UIAddCoin();
|
|
|
+ break;
|
|
|
+ // case 'qjff_AD_for_skilldisplay_clickAddLevel':
|
|
|
+ // // SkillDisplay s=new SkillDisplay();//改为插屏了
|
|
|
+ // // s.qjff_AD_for_skilldisplay_clickAddLevel();
|
|
|
+ // break;
|
|
|
+ case '111a':
|
|
|
+ let dui14 = <UISign>xGame.uiMgr.getUI(UISign);
|
|
|
+ dui14.qjff_AD_for_uisign();
|
|
|
+ break;
|
|
|
+ case '222a':
|
|
|
+ let dui15 = <UISign>xGame.uiMgr.getUI(UISign);
|
|
|
+ dui15.qjff_AD_for_uisign();
|
|
|
+ break;
|
|
|
+ case '333a':
|
|
|
+ let dui16 = <UISign>xGame.uiMgr.getUI(UISign);
|
|
|
+ dui16.qjff_AD_for_uisign();
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ console.log('zh:未知的方法名字' + t)
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // if(t === 'qjff_shengJi_for_SkillDisplay'){
|
|
|
+ // const dui = new
|
|
|
+ // dui.qjff_shengJi();
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public constructor() {
|
|
|
+ super();
|
|
|
+ }
|
|
|
+ protected onConstructor(): void {
|
|
|
+ console.log('zh: UIMain onConstructor');
|
|
|
+ this.ui = ui_UIMain.createInstance();
|
|
|
+ this.contentPane = this.ui;
|
|
|
+ this.isEject = false;
|
|
|
+ // this.ui.weeklyBtn.visible = false;
|
|
|
+ this.addEvent();
|
|
|
+ this.addClickSpine();
|
|
|
+ //设置界面
|
|
|
+ this.settingNode = new SettingNode(this.ui.settingNode);
|
|
|
+ this.moneyNode = new MoneyNode(this.ui.moneyNode);
|
|
|
+ //
|
|
|
+ xGame.eventMgr.on(RESTART_GAME, this, this.beginGame);
|
|
|
+ xGame.eventMgr.on(GET_USER_INFO, this, this.onGetUserInfo);
|
|
|
+ xGame.eventMgr.on(CHANGE_SECRETARY, this, this.changeSecretary);
|
|
|
+
|
|
|
+
|
|
|
+ let curUse = DataMgr.getCurSecretary();
|
|
|
+ this.changeSecretary(curUse);
|
|
|
+
|
|
|
+ //
|
|
|
+ //this.ui.rankBtn.visible = false;
|
|
|
+ this.ui.talkNode.visible = false;
|
|
|
+ let guide = DataMgr.getSkillGuide();
|
|
|
+ if (xGame.common.isNewDay && guide == 1) {
|
|
|
+ xGame.common.isNewDay = false;
|
|
|
+ xGame.soundMgr.playSound("s_main01");
|
|
|
+ xGame.common.showGirlTalkPop(1, this.ui.talkNode, this.ui.talkNode.womanTxt);
|
|
|
+ console.log("zh:播放小秘书每天语音");
|
|
|
+ }
|
|
|
+ this.onGetUserInfo();
|
|
|
+ this.ui.n83.visible = false;
|
|
|
+ //万宁台球
|
|
|
+ //Moyu.setShareInfo("8Ball Fury", ["台球", "台球", "桌球"], '2300002254');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
|
|
|
+ const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo);
|
|
|
+ let ua = d.username;
|
|
|
+ this.ui.headNode.nameTxt.text = xGame.tools.reviseString(ua, 16);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ window['nativeCallJs'] = this.nativeCallJs.bind(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ Logout() {
|
|
|
+ if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
|
|
|
+ //const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo);
|
|
|
+ LocalStorageManager.removeItem(keyForLoginInfo);
|
|
|
+ this.freshUser();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gotoLogin() {
|
|
|
+ xGame.uiMgr.Show(UILogin);
|
|
|
+ }
|
|
|
+ gotoRegUser() {
|
|
|
+ xGame.uiMgr.Show(UIReg);
|
|
|
+ }
|
|
|
+ showFuLi() {
|
|
|
+ console.log('zh:福利2');
|
|
|
+ xGame.uiMgr.Show(UIFuli1);
|
|
|
+ xGame.uiMgr.Show(UIFuli2);
|
|
|
+ console.log('zh:福利2222');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ changeSecretary(curUse) {
|
|
|
+ let name = cfgTable.secretaryshopData[curUse + 1].spine;
|
|
|
+ xGame.common.secretary && xGame.common.secretary.dispose();
|
|
|
+ this.addSecretarySpine(name);
|
|
|
+ }
|
|
|
+ addSecretarySpine(name) {
|
|
|
+ let spine = new SpineMgr(name, () => {
|
|
|
+ this.playSecretaryIdle();
|
|
|
+ });
|
|
|
+ xGame.common.secretary = spine;
|
|
|
+ }
|
|
|
+ addClickSpine() {
|
|
|
+ let clickSpine = new SpineMgr("dianji", () => {
|
|
|
+ Laya.stage.on(Laya.Event.CLICK, this, (e: Laya.Event) => {
|
|
|
+ //
|
|
|
+ let parent = Laya.stage;
|
|
|
+ let data = { x: e.stageX, y: e.stageY, scaleX: 0.8, scaleY: 0.8 };
|
|
|
+ clickSpine.play(data, 0, false, parent, (spine) => {
|
|
|
+ spine.destroy(true);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ //
|
|
|
+ });
|
|
|
+ }
|
|
|
+ private addEvent(): void {
|
|
|
+ this.addUIClick(this.ui.classicBtn, this.startGame, [GameMode.classic]);
|
|
|
+ this.addUIClick(this.ui.bigMoveBtn, this.startGame, [GameMode.bigMove])
|
|
|
+
|
|
|
+ this.addUIClick(this.ui.globalBtn, this.startGlobal);
|
|
|
+ // this.addUIClick(this.ui.weeklyBtn, this.startWeekly);
|
|
|
+ this.addUIClick(this.ui.placeBallBtn, this.startPlaceBall);
|
|
|
+ //
|
|
|
+ this.addUIClick(this.ui.headNode, this.onGetUserInfo, [true]);
|
|
|
+ this.addUIClick(this.ui, this.interuptSecretary);
|
|
|
+ this.addUIClick(this.ui.rightBtn, this.ensureSecretary);
|
|
|
+ this.addUIClick(this.ui.guideBtn, this.startGame, [GameMode.bigMove]);
|
|
|
+ this.addUIClick(this.ui.secretaryBtn, this.openSecretaryView);
|
|
|
+ this.addUIClick(this.ui.shopBtn, this.openShopView);
|
|
|
+
|
|
|
+ //
|
|
|
+ this.addUIClick(this.ui.signBtn, this.openSignView);
|
|
|
+ this.addUIClick(this.ui.drawBtn, this.openDrawView);
|
|
|
+ this.addUIClick(this.ui.rankBtn, this.openRanking);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ public show(showFailWords): void {
|
|
|
+ super.show();
|
|
|
+ //
|
|
|
+ this.moneyNode.ui.c1.selectedIndex = 1;
|
|
|
+ this.playSecretaryIdle();
|
|
|
+
|
|
|
+ xGame.soundMgr.playMusic("caromhall01", 0);
|
|
|
+
|
|
|
+
|
|
|
+ Laya.timer.clearAll(this);
|
|
|
+ this.playSecretaryRandomSound();
|
|
|
+ console.log('zh:uimain.ts show show FailWords=', showFailWords);
|
|
|
+ if (showFailWords) {
|
|
|
+ console.log('zh:uimain.ts ')
|
|
|
+ //延迟播放进入主页面的失败音效
|
|
|
+ setTimeout(() => {
|
|
|
+ let str = Math.random() <= 0.5 ? "s_main02" : "s_main03";
|
|
|
+ let words = -1;
|
|
|
+ if (str == "s_main02") {
|
|
|
+ words = 2;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ words = 3;
|
|
|
+ }
|
|
|
+ xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt);
|
|
|
+ xGame.soundMgr.playSound(str);
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // setTimeout(() => {
|
|
|
+ // console.log('zh:播放7背景音乐 m ')
|
|
|
+ // xGame.soundMgr.playSound('bjyy_m', 0);
|
|
|
+ // }, 2000);
|
|
|
+
|
|
|
+
|
|
|
+ //
|
|
|
+ this.showGuide();
|
|
|
+ this.ui.guideBtn.x = this.ui.liucheng2.myMask.x;
|
|
|
+ this.ui.guideBtn.y = this.ui.liucheng2.myMask.y;
|
|
|
+ //
|
|
|
+ let guide = DataMgr.getSkillGuide();
|
|
|
+ if (guide == 1) {
|
|
|
+ let randTime = xGame.common.randomNum(300, 800);
|
|
|
+ if (this.firstEnter) {
|
|
|
+ console.log("zh: firstEnter");
|
|
|
+ this.firstEnter = false;
|
|
|
+ randTime += 900;
|
|
|
+ } else {
|
|
|
+ console.log("zh: no firstEnter");
|
|
|
+ }
|
|
|
+ Laya.timer.once(randTime, this, () => {
|
|
|
+ xGame.common.autoPopUIView();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ checkActive(show) {
|
|
|
+ //console.log("是否处于最外层",show);
|
|
|
+ //wx banner太大
|
|
|
+ // if (!Moyu.isWx)
|
|
|
+ // PlatMgr.showBanner(show);
|
|
|
+ }
|
|
|
+ showGuide() {
|
|
|
+ let guide = DataMgr.getSkillGuide();
|
|
|
+ this.ui.guideBtn.visible = guide == 0;
|
|
|
+ this.ui.enterGuide.visible = false;
|
|
|
+ this.ui.secretaryGuide.visible = guide == 0;
|
|
|
+ if (guide == 0) {
|
|
|
+ console.log("zh:显示引导");
|
|
|
+ xGame.soundMgr.playSound("s_guide");
|
|
|
+ xGame.common.showGirlTalkPop(16, this.ui.talkNode, this.ui.talkNode.womanTxt);
|
|
|
+ } else {
|
|
|
+ console.log("zh:不需要显示引导");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ensureSecretary() {
|
|
|
+ console.log('zh: ensureSecretary ensureSecretaryensureSecretaryensureSecretaryensureSecretaryensureSecretary')
|
|
|
+ this.ui.secretaryGuide.visible = false;
|
|
|
+ this.ui.enterGuide.visible = true;
|
|
|
+ this.ui.wordsNode.t0.play();
|
|
|
+ //todo
|
|
|
+ if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameReady");
|
|
|
+ }
|
|
|
+ playSecretaryIdle() {
|
|
|
+ let parent = this.ui.secretary.displayObject;
|
|
|
+ parent.destroyChildren();
|
|
|
+ let xx = this.ui.secretary.width / 2;
|
|
|
+ let yy = this.ui.secretary.height;
|
|
|
+
|
|
|
+ // xx = Laya.stage.width / 2;
|
|
|
+ // yy = Laya.stage.height;
|
|
|
+ let scale = xGame.common.getSecretaryScale();
|
|
|
+ let data = { x: xx, y: yy, scaleX: scale, scaleY: scale };
|
|
|
+ //console.log("zh:playSecretaryIdle", data);
|
|
|
+ //xGame.common.secretary.play(data, 1, true, parent); 这是老的秘书
|
|
|
+
|
|
|
+ xGame.common.secretary.play(data, 0, true, parent);
|
|
|
+ }
|
|
|
+ startGame(type: GameMode) {
|
|
|
+ if (!this.isReadyForLoadNetSource()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // console.log('zh: 停止播放主頁面背景音乐');
|
|
|
+ // xGame.soundMgr.stopMusic();
|
|
|
+
|
|
|
+
|
|
|
+ //进入游戏页面
|
|
|
+ xGame.common.gameMode = type;
|
|
|
+ //
|
|
|
+ Moyu.sendDataEvent("PlayGame", { type: type });
|
|
|
+ console.log('zh:进入游戏gameMode =' + xGame.common.gameMode);
|
|
|
+ switch (xGame.common.gameMode) {
|
|
|
+ case GameMode.classic:
|
|
|
+ console.log('zh:进入经典模式111111111');
|
|
|
+ //zhdiy - challenge mode作为教学练习关,完成2关解锁classic,
|
|
|
+ if (DataMgr.DIY_challengeMode_overLev_jieSuo_mark) {
|
|
|
+ let db_over_lev = DataMgr.getChallengeMode_overLev();
|
|
|
+ console.log('zh:classic db_over_lev=', db_over_lev);
|
|
|
+ if (db_over_lev < DataMgr.DIY_challengeMode_overLev_jieSuo_Classic) {
|
|
|
+ console.log('zh:判断是否可以玩该模式classic =NO');
|
|
|
+ let tipStr = 'You must complete ' + DataMgr.DIY_challengeMode_overLev_jieSuo_Classic + ' levels in Challenge Mode to unlock Classic Mode.';
|
|
|
+ xGame.uiMgr.Show(UIMsg, tipStr);
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ console.log('zh:可以玩该模式classic 66666666666666');
|
|
|
+ this.beginGame();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('zh:不需要判断是否可以玩该classic');
|
|
|
+ let challengeTimes = DataMgr.getChallengeTimes();
|
|
|
+ if (challengeTimes == 0) {
|
|
|
+ xGame.uiMgr.Show(UIInvitation);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.beginGame();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case GameMode.bigMove:
|
|
|
+ console.error('zh:bigMove check');
|
|
|
+ let guide = DataMgr.getSkillGuide();
|
|
|
+ //zhdiy - challenge mode作为教学练习关,完成2关解锁classic,
|
|
|
+ if (DataMgr.DIY_challengeMode_overLev_jieSuo_mark && guide == 1) {
|
|
|
+ let db_over_lev = DataMgr.getChallengeMode_overLev();
|
|
|
+ console.log('zh:bigMove db_over_lev=', db_over_lev);
|
|
|
+ if (db_over_lev < DataMgr.DIY_challengeMode_overLev_jieSuo_rodMethod) {
|
|
|
+ let tipStr = 'Complete ' + DataMgr.DIY_challengeMode_overLev_jieSuo_rodMethod + ' levels in Challenge Mode to unlock the Rod Method Mode';
|
|
|
+ xGame.uiMgr.Show(UIMsg, tipStr);
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ console.log('zh:可以玩该模式 bigMove');
|
|
|
+ this.beginGame();
|
|
|
+ if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart0");
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.beginGame();
|
|
|
+ if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart0");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ console.error('zh:未知错误!!!!');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ beginGame(isNice = false) {
|
|
|
+
|
|
|
+ console.log('zh:beginGame ');
|
|
|
+ //TODO:ZH 插屏AD
|
|
|
+ //let time = xGame.common.randomNum(1000, 2000);
|
|
|
+ //Moyu.showInsertAd(time, 60000);
|
|
|
+
|
|
|
+ let guide = DataMgr.getSkillGuide();
|
|
|
+ if (guide == 1) {//非新手引导,就显示,否则不显示
|
|
|
+ console.log('zh:非新手引导,showInternAd ');
|
|
|
+ JSBridgeUtils.instance.showInternAd('beginGame');
|
|
|
+ } else {
|
|
|
+ console.log('zh:新手引导,不显示AD ');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ console.log('zh:beginGame 2 go');
|
|
|
+ if (xGame.common.gameMode == GameMode.classic) {
|
|
|
+ // xGame.uiMgr.Show(UIMsg, "Coming Soon")
|
|
|
+ if (isNice) {
|
|
|
+ //巅峰赛直接进入
|
|
|
+ this.enterClassic();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ xGame.uiMgr.Show(UIModeSelection, () => {
|
|
|
+ console.log('zh:BBBBBBBBBBBBBBB');
|
|
|
+ this.enterClassic();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (xGame.common.gameMode == GameMode.bigMove) {
|
|
|
+ this.ui.enterGuide.visible = false;
|
|
|
+ xGame.uiMgr.Show(UISkill);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ enterClassic() {
|
|
|
+
|
|
|
+ xGame.uiMgr.Show(UIGame);
|
|
|
+ xGame.uiMgr.Show(UIMatching, () => {
|
|
|
+ if (!this.isHide) this.hide();
|
|
|
+ xGame.common.gameUI.ui.alpha = 1;
|
|
|
+ xGame.common.gameUI.startGame();
|
|
|
+ xGame.uiMgr.Hide(UIGameEnd);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ startGlobal() {
|
|
|
+ xGame.uiMgr.Show(UIMsg, "Coming Soon")
|
|
|
+
|
|
|
+ //xGame.uiMgr.Show(UITry);
|
|
|
+ // JSBridgeUtils.instance.showInternAd('');
|
|
|
+ }
|
|
|
+ startWeekly() {
|
|
|
+ //xGame.uiMgr.Show(UIBox);
|
|
|
+ xGame.uiMgr.Show(UIMsg, "Coming Soon")
|
|
|
+
|
|
|
+ //测试AD
|
|
|
+ // GlobalManager.instance.registerMethod('zhouSaiMonth', this.zhouSaiMonth);
|
|
|
+ //JSBridgeUtils.instance.showRewardAd('zhouSaiMonth');
|
|
|
+ }
|
|
|
+
|
|
|
+ zhouSaiMonth() {
|
|
|
+ console.log('zh: zhouSaiMonth 被调用')
|
|
|
+ }
|
|
|
+ //网络资源是否准备好了
|
|
|
+ public isReadyForLoadNetSource(): boolean {
|
|
|
+ let reqCount = xGame.cfgMgr.httpReqCount;
|
|
|
+ let ok = xGame.cfgMgr.httpReqOkCount;
|
|
|
+ if (reqCount > ok) {
|
|
|
+ //console.log('zh:网络资源没有准备完成,请稍后再试');
|
|
|
+ xGame.uiMgr.Show(UIMsg, "Network not ready. Try again later.")
|
|
|
+ console.log('zh:✅❌ 5秒后重新尝试加载网络资源');
|
|
|
+ Laya.timer.once(5000, this, () => {
|
|
|
+ let retryCount = 0;
|
|
|
+ const maxRetries = 3;
|
|
|
+
|
|
|
+ const tryFetchConfig = () => {
|
|
|
+ try {
|
|
|
+ xGame.cfgMgr.getConfigFromServer();
|
|
|
+ } catch (error) {
|
|
|
+ if (retryCount < maxRetries) {
|
|
|
+ retryCount++;
|
|
|
+ console.log(`🔄 第${retryCount}次重试获取配置...`);
|
|
|
+ Laya.timer.once(5000, this, tryFetchConfig);
|
|
|
+ } else {
|
|
|
+ console.error("❌ 达到最大重试次数,配置获取失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ tryFetchConfig();
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ startPlaceBall() {
|
|
|
+ if (!this.isReadyForLoadNetSource()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ xGame.uiMgr.Show(UILevelDisplay);
|
|
|
+ }
|
|
|
+ public hide(): void {
|
|
|
+ console.log('zh:uimain hide ...');
|
|
|
+ // console.log('zh:停止播放bjyy_m');
|
|
|
+ //xGame.soundMgr.stopSound("bjyy_m");
|
|
|
+
|
|
|
+
|
|
|
+ // console.log('zh: hide 停止播放主頁面背景音乐');
|
|
|
+ // xGame.soundMgr.stopMusic();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ super.hide();
|
|
|
+ xGame.common.stopGirlPop(this.ui.talkNode)
|
|
|
+ }
|
|
|
+ //点击头像
|
|
|
+ onGetUserInfo(force = false) {
|
|
|
+ if (Moyu.isWx) {
|
|
|
+ let info = Moyu.getSystemInfo();
|
|
|
+ if (info)
|
|
|
+ Moyu.createWXUserBtn(0, 0, info.width, info.height, 'res/wxuser.png', this.freshUser);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Moyu.initUser(this, this.freshUser, force)
|
|
|
+ }
|
|
|
+ // if (!Moyu.hasUserInfo) {
|
|
|
+ // let user = Moyu.getUserInfo();
|
|
|
+ // //user.nickName="我";
|
|
|
+ // user.headIcon = 'res/ty_touxiang.png';
|
|
|
+ // //console.log("未授权");
|
|
|
+ // }
|
|
|
+ this.freshUser();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ freshUser() {
|
|
|
+ let user = Moyu.getUserInfo();
|
|
|
+ if (!user.isAuth) {
|
|
|
+ user.headIcon = 'res/ty_touxiang.png';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DataMgr.upRankData();
|
|
|
+ }
|
|
|
+ this.ui.headNode.nameTxt.text = xGame.tools.reviseString(user.nickName, 16);
|
|
|
+ xGame.common.createHead(this.ui.headNode.headRoot.headImg, user.headIcon);
|
|
|
+ let keyStr = keyForLoginInfo;
|
|
|
+ if (LocalStorageManager.hasJosnKey(keyStr)) {
|
|
|
+ const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyStr);
|
|
|
+ let ua = d.username;
|
|
|
+ this.ui.headNode.nameTxt.text = xGame.tools.reviseString(ua, 16);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ interuptSecretary() {
|
|
|
+ Laya.timer.clearAll(this);
|
|
|
+ this.playSecretaryRandomSound();
|
|
|
+ }
|
|
|
+ //主界面和技能选择界面3-7秒未操作随机播放秘书音效
|
|
|
+ playSecretaryRandomSound() {
|
|
|
+ if (this.isHide) return;
|
|
|
+ let time = xGame.common.randomNum(45000, 60000);
|
|
|
+ Laya.timer.once(time, this, () => {
|
|
|
+ if (this.isHide) return;
|
|
|
+ let index = xGame.common.randomNum(4, 7);
|
|
|
+ xGame.soundMgr.playSound("s_main0" + index);
|
|
|
+ let words = 1;
|
|
|
+ switch (index) {
|
|
|
+ case 4:
|
|
|
+ words = 5;
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ words = 3;
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ words = 6;
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ words = 7;
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt);
|
|
|
+ //
|
|
|
+ this.playSecretaryRandomSound();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ openSecretaryView() {
|
|
|
+ xGame.uiMgr.Show(UISecretary);
|
|
|
+ Moyu.sendDataEvent("secretary");
|
|
|
+ }
|
|
|
+ openShopView() {
|
|
|
+ xGame.uiMgr.Show(UIShop, 0);
|
|
|
+ }
|
|
|
+ openSignView() {
|
|
|
+ xGame.uiMgr.Show(UISign);
|
|
|
+ }
|
|
|
+ openDrawView() {
|
|
|
+ xGame.uiMgr.Show(UIDraw);
|
|
|
+ }
|
|
|
+ openRanking() {
|
|
|
+ console.log('zh:phb openRanking')
|
|
|
+ xGame.uiMgr.Show(UIRanking);
|
|
|
+ Moyu.sendDataEvent("rankingList");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+UIMain.uiName = "UIMain";
|