123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- import SpineMgr from "../core/mgrs/SpineMgr";
- import DataMgr from "../data/DataMgr";
- import { CHANGE_SECRETARY, GameMode, GET_USER_INFO, RESTART_GAME } 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 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";
- 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');
- window['nativeCallJs'] = this.nativeCallJs.bind(this);
- }
- 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.ganFaMoShiBtn, 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) {
- // 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);
- console.log('zh:返回');
- 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 被调用')
- }
- startPlaceBall() {
- xGame.uiMgr.Show(UILevelDisplay);
- //xGame.uiMgr.Show(UIMsg, "敬请期待~")
- }
- 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);
- }
- 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);
- }
- 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";
|