UIMain.ts 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. import SpineMgr from "../core/mgrs/SpineMgr";
  2. import DataMgr from "../data/DataMgr";
  3. import { CHANGE_SECRETARY, GameMode, GET_USER_INFO, RESTART_GAME, keyForLoginInfo, TIP_MSG_key } from "../data/Define";
  4. import UIBase from "../fgui/core/UIBase";
  5. import ui_UIMain from "../fgui/res/game/ui_UIMain";
  6. import PlatMgr from "../game/PlatMgr";
  7. import { xGame } from "../xGame";
  8. import MoneyNode from "./item/MoneyNode";
  9. import SettingNode from "./item/SettingNode";
  10. import UIAddProp from "./UIAddProp";
  11. import UIDraw from "./UIDraw";
  12. import { UIGame } from "./UIGame";
  13. import UIGameEnd from "./UIGameEnd";
  14. import UIInvitation from "./UIInvitation";
  15. import UILevelDisplay from "./UILevelDisplay";
  16. import UIMatching from "./UIMatching";
  17. import UIRanking from "./UIRanking";
  18. import UISecretary from "./UISecretary";
  19. import UIShop from "./UIShop";
  20. import UISign from "./UISign";
  21. import UISkill from "./UISkill";
  22. import UIMsg from "./UIMsg";
  23. import UIModeSelection from "./UIModeSelection";
  24. import GlobalManager from "../utils/GlobalManager";
  25. import JSBridgeUtils from "../utils/JSBridgeUtils";
  26. import SkillDisplay from "./item/SkillDisplay";
  27. import UIReg from "./UIReg";
  28. import UILogin from "./UILogin";
  29. import UIFuli1 from "./UIFuli1";
  30. import UIFuli2 from "./UIFuli2";
  31. import UITry from "./UITry";
  32. import UIPower from "./UIPower";
  33. import UIGetAward from "./UIGetAward";
  34. import UIRepentProp from "./UIRepentProp";
  35. import UIBox from "./UIBox";
  36. import UIAddCoin from "./UIAddCoin";
  37. import { NoInternetDialog } from "./NoInternetDialog";
  38. //import NetCheckTool from "../utils/NetCheckTool";
  39. import { LocalStorageManager } from "../utils/LocalStorageManager";
  40. export default class UIMain extends UIBase {
  41. public ui: ui_UIMain;
  42. public settingNode: SettingNode;
  43. public moneyNode: MoneyNode;
  44. public firstEnter = true;
  45. nativeCallJs(msg: string) {
  46. let t = msg;
  47. console.log("zh: nativeCallJs 奖励开始发放:", t);
  48. //GlobalManager.instance.callMethod(msg)
  49. switch (t) {
  50. case 'qjff_chouJiang':
  51. let dui = <UIDraw>xGame.uiMgr.getUI(UIDraw);
  52. dui.qjff_chouJiang();
  53. break;
  54. case 'qjff_AD_for_uisign':
  55. let dui2 = <UISign>xGame.uiMgr.getUI(UISign);
  56. dui2.qjff_AD_for_uisign();
  57. break;
  58. case 'qjff_AD_for_uitry':
  59. let dui3 = <UITry>xGame.uiMgr.getUI(UITry);
  60. dui3.qjff_AD_for_uitry();
  61. break;
  62. case 'qjff_AD_for_uipower':
  63. let dui4 = <UIPower>xGame.uiMgr.getUI(UIPower);
  64. dui4.qjff_AD_for_uipower();
  65. break;
  66. case 'qjff_AD_for_uigetAward':
  67. let dui5 = <UIGetAward>xGame.uiMgr.getUI(UIGetAward);
  68. dui5.qjff_AD_for_uigetAward();
  69. break;
  70. case 'qjff_AD_for_uiGameEnd':
  71. let temp_level = Laya.LocalStorage.getItem('temp_qjff_AD_for_uiGameEnd_level');
  72. let dui6 = <UIGameEnd>xGame.uiMgr.getUI(UIGameEnd);
  73. dui6.qjff_AD_for_uiGameEnd(parseInt(temp_level))
  74. break;
  75. case 'qjff_AD_for_uiAddProp_videoGetDiamond':
  76. let dui7 = <UIAddProp>xGame.uiMgr.getUI(UIAddProp);
  77. dui7.qjff_AD_for_uiAddProp_videoGetDiamond();
  78. break;
  79. case 'qjff_AD_for_uiAddProp_videoGetCoin':
  80. let dui8 = <UIAddProp>xGame.uiMgr.getUI(UIAddProp);
  81. dui8.qjff_AD_for_uiAddProp_videoGetCoin();
  82. break;
  83. case 'qjff_AD_for_UIrepentProp_videoRegret':
  84. let dui9 = <UIRepentProp>xGame.uiMgr.getUI(UIRepentProp);
  85. dui9.qjff_AD_for_UIrepentProp_videoRegret();
  86. break;
  87. case 'qjff_AD_for_UIrepentProp_videoAddHelpLine':
  88. let dui10 = <UIRepentProp>xGame.uiMgr.getUI(UIRepentProp);
  89. dui10.qjff_AD_for_UIrepentProp_videoAddHelpLine();
  90. break;
  91. case 'qjff_AD_for_UIBOX_onOpenBox':
  92. let dui11 = <UIBox>xGame.uiMgr.getUI(UIBox);
  93. dui11.qjff_AD_for_UIBOX_onOpenBox();
  94. break;
  95. case 'qjff_AD_for_UIAddCoin':
  96. let dui12 = <UIAddCoin>xGame.uiMgr.getUI(UIAddCoin);
  97. dui12.qjff_AD_for_UIAddCoin();
  98. break;
  99. // case 'qjff_AD_for_skilldisplay_clickAddLevel':
  100. // // SkillDisplay s=new SkillDisplay();//改为插屏了
  101. // // s.qjff_AD_for_skilldisplay_clickAddLevel();
  102. // break;
  103. case '111a':
  104. let dui14 = <UISign>xGame.uiMgr.getUI(UISign);
  105. dui14.qjff_AD_for_uisign();
  106. break;
  107. case '222a':
  108. let dui15 = <UISign>xGame.uiMgr.getUI(UISign);
  109. dui15.qjff_AD_for_uisign();
  110. break;
  111. case '333a':
  112. let dui16 = <UISign>xGame.uiMgr.getUI(UISign);
  113. dui16.qjff_AD_for_uisign();
  114. break;
  115. default:
  116. console.log('zh:未知的方法名字' + t)
  117. break;
  118. }
  119. // if(t === 'qjff_shengJi_for_SkillDisplay'){
  120. // const dui = new
  121. // dui.qjff_shengJi();
  122. // }
  123. }
  124. public constructor() {
  125. super();
  126. }
  127. protected onConstructor(): void {
  128. console.log('zh: UIMain onConstructor');
  129. this.ui = ui_UIMain.createInstance();
  130. this.contentPane = this.ui;
  131. this.isEject = false;
  132. // this.ui.weeklyBtn.visible = false;
  133. this.addEvent();
  134. this.addClickSpine();
  135. //设置界面
  136. this.settingNode = new SettingNode(this.ui.settingNode);
  137. this.moneyNode = new MoneyNode(this.ui.moneyNode);
  138. //
  139. xGame.eventMgr.on(RESTART_GAME, this, this.beginGame);
  140. xGame.eventMgr.on(GET_USER_INFO, this, this.onGetUserInfo);
  141. xGame.eventMgr.on(CHANGE_SECRETARY, this, this.changeSecretary);
  142. let curUse = DataMgr.getCurSecretary();
  143. this.changeSecretary(curUse);
  144. //
  145. //this.ui.rankBtn.visible = false;
  146. this.ui.talkNode.visible = false;
  147. let guide = DataMgr.getSkillGuide();
  148. if (xGame.common.isNewDay && guide == 1) {
  149. xGame.common.isNewDay = false;
  150. xGame.soundMgr.playSound("s_main01");
  151. xGame.common.showGirlTalkPop(1, this.ui.talkNode, this.ui.talkNode.womanTxt);
  152. console.log("zh:播放小秘书每天语音");
  153. }
  154. this.onGetUserInfo();
  155. DataMgr.getUserZiChanInfo();
  156. this.ui.n83.visible = false;
  157. //万宁台球
  158. //Moyu.setShareInfo("8Ball Fury", ["台球", "台球", "桌球"], '2300002254');
  159. if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
  160. const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo);
  161. let ua = d.username;
  162. this.ui.headNode.nameTxt.text = xGame.tools.reviseString(ua, 16);
  163. }
  164. this.c_btn_for_user();
  165. window['nativeCallJs'] = this.nativeCallJs.bind(this);
  166. // console.log('zh: 显示福利')
  167. // Laya.timer.once(100, this, () => {
  168. // console.log('zh: 1秒后 showFuLiSp1')
  169. // this.showFuLiSp1();
  170. // })
  171. this.loadUserSpOrderForAd();
  172. }
  173. Logout() {
  174. if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
  175. //const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo);
  176. LocalStorageManager.removeItem(keyForLoginInfo);
  177. this.freshUser();
  178. }
  179. //必须要调用APP退出登录
  180. JSBridgeUtils.instance.loginOutForApp();
  181. }
  182. gotoLogin() {
  183. xGame.uiMgr.Show(UILogin);
  184. }
  185. gotoRegUser() {
  186. xGame.uiMgr.Show(UIReg);
  187. }
  188. showFuLiSp1() {
  189. console.log('zh:福利1');
  190. this.checkForShowFuLi17(1);
  191. }
  192. showFuLiSp7() {
  193. console.log('zh:福利7');
  194. this.checkForShowFuLi17(7);
  195. }
  196. /**
  197. * 加载用户广告权利
  198. */
  199. loadUserSpOrderForAd() {
  200. let userInfo = LocalStorageManager.getItem(keyForLoginInfo);
  201. if (userInfo == null) {
  202. return;
  203. }
  204. let reqData = xGame.httpMgr.getReqData();
  205. xGame.httpMgr.sendPost2025('order/getOrderListForNoChongFuBuy', reqData, (res) => {
  206. try {
  207. console.log('zh:loadUserSpOrderForAd res = ' + JSON.stringify(res))
  208. let code = res.code;
  209. let msg = res.msg;
  210. if (code == 401) {
  211. Laya.LocalStorage.setItem(keyForLoginInfo, null);
  212. xGame.uiMgr.Show(UIMsg, TIP_MSG_key.pleaseLoginIn)
  213. return;
  214. }
  215. if (code == 200) {
  216. let data = res.data;
  217. let buy_spid1: boolean = false;
  218. let buy_spid7: boolean = false;
  219. for (let index = 0; index < data.length; index++) {
  220. let element = data[index];
  221. console.log('zh:list element.spid = ' + element.spid);
  222. if (element.spid == 1) {
  223. buy_spid1 = true;
  224. }
  225. if (element.spid == 7) {
  226. buy_spid7 = true;
  227. }
  228. }
  229. DataMgr.updateLocalUserDataForSpid17(1, buy_spid1);
  230. DataMgr.updateLocalUserDataForSpid17(7, buy_spid7);
  231. } else {
  232. xGame.uiMgr.Show(UIMsg, msg);
  233. }
  234. } catch (error) {
  235. console.log('error=' + error);
  236. alert(error);
  237. } finally {
  238. }
  239. });
  240. }
  241. /**
  242. *
  243. * @param spid 商品ID ,于数据库里的一致
  244. * @returns
  245. */
  246. checkForShowFuLi17(spid: number) {
  247. let userInfo = LocalStorageManager.getItem(keyForLoginInfo);
  248. if (userInfo == null) {
  249. console.log('zh:没有登录就不显示福利弹框了');
  250. // xGame.uiMgr.Show(UIMsg, TIP_MSG_key.pleaseLoginIn);
  251. return;
  252. }
  253. console.log('zh:是否需要展示福利 ' + spid + ' 的弹窗');
  254. let reqData = xGame.httpMgr.getReqData();
  255. let pd: any = JSON.parse(reqData);
  256. pd.productId = spid;
  257. reqData = JSON.stringify(pd);
  258. xGame.httpMgr.sendPost2025('order/checkBuyFuLi', reqData, (res) => {
  259. try {
  260. console.log('zh:checkForShowFuLi17 res = ' + JSON.stringify(res))
  261. let code = res.code;
  262. let msg = res.msg;
  263. if (code == 401) {
  264. Laya.LocalStorage.setItem(keyForLoginInfo, null);
  265. xGame.uiMgr.Show(UIMsg, TIP_MSG_key.pleaseLoginIn)
  266. return;
  267. }
  268. if (code == 200) {//{"msg":"Please do not repeat the purchase.","code":200,"data":0}
  269. let isBuyOk = res.data;//true 表示已经购买
  270. DataMgr.updateLocalUserDataForSpid17(spid, isBuyOk);
  271. if (isBuyOk === false) {
  272. if (spid === 1) {
  273. xGame.uiMgr.Show(UIFuli1);
  274. } if (spid === 7) {
  275. xGame.uiMgr.Show(UIFuli2);
  276. }
  277. } else {
  278. console.log('zh:已经购买了SPID=' + spid + ',不需要再提示用户了')
  279. }
  280. } else {
  281. xGame.uiMgr.Show(UIMsg, msg);
  282. }
  283. } catch (error) {
  284. console.log('error=' + error);
  285. alert(error);
  286. } finally {
  287. }
  288. });
  289. }
  290. /**
  291. * 登录注册退出
  292. */
  293. c_btn_for_user() {
  294. this.ui.n_Logout.visible = false;
  295. this.ui.n_dengLu.visible = false;
  296. this.ui.n_zhuCe.visible = false;
  297. if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
  298. this.ui.n_Logout.visible = true;
  299. } else {
  300. this.ui.n_dengLu.visible = true;
  301. }
  302. }
  303. changeSecretary(curUse) {
  304. let name = cfgTable.secretaryshopData[curUse + 1].spine;
  305. xGame.common.secretary && xGame.common.secretary.dispose();
  306. this.addSecretarySpine(name);
  307. }
  308. addSecretarySpine(name) {
  309. let spine = new SpineMgr(name, () => {
  310. this.playSecretaryIdle();
  311. });
  312. xGame.common.secretary = spine;
  313. }
  314. addClickSpine() {
  315. let clickSpine = new SpineMgr("dianji", () => {
  316. Laya.stage.on(Laya.Event.CLICK, this, (e: Laya.Event) => {
  317. //
  318. let parent = Laya.stage;
  319. let data = { x: e.stageX, y: e.stageY, scaleX: 0.8, scaleY: 0.8 };
  320. clickSpine.play(data, 0, false, parent, (spine) => {
  321. spine.destroy(true);
  322. });
  323. })
  324. //
  325. });
  326. }
  327. private addEvent(): void {
  328. this.addUIClick(this.ui.classicBtn, this.startGame, [GameMode.classic]);
  329. this.addUIClick(this.ui.bigMoveBtn, this.startGame, [GameMode.bigMove])
  330. this.addUIClick(this.ui.ganFaMoShiBtn, this.startGame, [GameMode.bigMove])
  331. //
  332. this.addUIClick(this.ui.globalBtn, this.startGlobal);
  333. // this.addUIClick(this.ui.weeklyBtn, this.startWeekly);
  334. this.addUIClick(this.ui.placeBallBtn, this.startPlaceBall);
  335. //
  336. this.addUIClick(this.ui.headNode, this.onGetUserInfo, [true]);
  337. this.addUIClick(this.ui, this.interuptSecretary);
  338. this.addUIClick(this.ui.rightBtn, this.ensureSecretary);
  339. this.addUIClick(this.ui.guideBtn, this.startGame, [GameMode.bigMove]);
  340. this.addUIClick(this.ui.secretaryBtn, this.openSecretaryView);
  341. this.addUIClick(this.ui.shopBtn, this.openShopView);
  342. //
  343. this.addUIClick(this.ui.signBtn, this.openSignView);
  344. this.addUIClick(this.ui.drawBtn, this.openDrawView);
  345. this.addUIClick(this.ui.rankBtn, this.openRanking);
  346. //退出登录
  347. this.addUIClick(this.ui.n_Logout, this.Logout);
  348. this.addUIClick(this.ui.n_dengLu, this.gotoLogin);
  349. this.addUIClick(this.ui.n_zhuCe, this.gotoRegUser);
  350. this.addUIClick(this.ui.n_fuli, this.showFuLiSp7);
  351. //调试专用
  352. this.addUIClick(this.ui.n_moni_pay_ok, this.start_debug_for_moni_payOk);
  353. }
  354. public show(showFailWords): void {
  355. super.show();
  356. this.loadUserSpOrderForAd();
  357. //
  358. this.moneyNode.ui.c1.selectedIndex = 1;
  359. this.playSecretaryIdle();
  360. xGame.soundMgr.playMusic("caromhall01", 0);
  361. Laya.timer.clearAll(this);
  362. this.playSecretaryRandomSound();
  363. console.log('zh:uimain.ts show show FailWords=', showFailWords);
  364. if (showFailWords) {
  365. console.log('zh:uimain.ts ')
  366. //延迟播放进入主页面的失败音效
  367. setTimeout(() => {
  368. let str = Math.random() <= 0.5 ? "s_main02" : "s_main03";
  369. let words = -1;
  370. if (str == "s_main02") {
  371. words = 2;
  372. }
  373. else {
  374. words = 3;
  375. }
  376. xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt);
  377. xGame.soundMgr.playSound(str);
  378. }, 300);
  379. }
  380. // setTimeout(() => {
  381. // console.log('zh:播放7背景音乐 m ')
  382. // xGame.soundMgr.playSound('bjyy_m', 0);
  383. // }, 2000);
  384. //
  385. this.showGuide();
  386. this.ui.guideBtn.x = this.ui.liucheng2.myMask.x;
  387. this.ui.guideBtn.y = this.ui.liucheng2.myMask.y;
  388. //
  389. let guide = DataMgr.getSkillGuide();
  390. if (guide == 1) {
  391. let randTime = xGame.common.randomNum(300, 800);
  392. if (this.firstEnter) {
  393. console.log("zh: firstEnter");
  394. this.firstEnter = false;
  395. randTime += 900;
  396. } else {
  397. console.log("zh: no firstEnter");
  398. }
  399. Laya.timer.once(randTime, this, () => {
  400. // xGame.common.autoPopUIView();
  401. })
  402. }
  403. }
  404. checkActive(show) {
  405. //console.log("是否处于最外层",show);
  406. //wx banner太大
  407. // if (!Moyu.isWx)
  408. // PlatMgr.showBanner(show);
  409. }
  410. showGuide() {
  411. let guide = DataMgr.getSkillGuide();
  412. this.ui.guideBtn.visible = guide == 0;
  413. this.ui.enterGuide.visible = false;
  414. this.ui.secretaryGuide.visible = guide == 0;
  415. if (guide == 0) {
  416. console.log("zh:显示引导");
  417. xGame.soundMgr.playSound("s_guide");
  418. xGame.common.showGirlTalkPop(16, this.ui.talkNode, this.ui.talkNode.womanTxt);
  419. } else {
  420. console.log("zh:不需要显示引导");
  421. }
  422. }
  423. ensureSecretary() {
  424. console.log('zh: ensureSecretary ensureSecretaryensureSecretaryensureSecretaryensureSecretaryensureSecretary')
  425. this.ui.secretaryGuide.visible = false;
  426. this.ui.enterGuide.visible = true;
  427. this.ui.wordsNode.t0.play();
  428. //todo
  429. if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameReady");
  430. }
  431. playSecretaryIdle() {
  432. let parent = this.ui.secretary.displayObject;
  433. parent.destroyChildren();
  434. let xx = this.ui.secretary.width / 2;
  435. let yy = this.ui.secretary.height;
  436. // xx = Laya.stage.width / 2;
  437. // yy = Laya.stage.height;
  438. let scale = xGame.common.getSecretaryScale();
  439. let data = { x: xx, y: yy, scaleX: scale, scaleY: scale };
  440. //console.log("zh:playSecretaryIdle", data);
  441. //xGame.common.secretary.play(data, 1, true, parent); 这是老的秘书
  442. xGame.common.secretary.play(data, 0, true, parent);
  443. }
  444. startGame(type: GameMode) {
  445. if (!this.isReadyForLoadNetSource()) {
  446. return;
  447. }
  448. // console.log('zh: 停止播放主頁面背景音乐');
  449. // xGame.soundMgr.stopMusic();
  450. //进入游戏页面
  451. xGame.common.gameMode = type;
  452. //
  453. Moyu.sendDataEvent("PlayGame", { type: type });
  454. console.log('zh:进入游戏gameMode =' + xGame.common.gameMode);
  455. switch (xGame.common.gameMode) {
  456. case GameMode.classic:
  457. console.log('zh:进入经典模式111111111');
  458. //zhdiy - challenge mode作为教学练习关,完成2关解锁classic,
  459. if (DataMgr.DIY_challengeMode_overLev_jieSuo_mark) {
  460. let db_over_lev = DataMgr.getChallengeMode_overLev();
  461. console.log('zh:classic db_over_lev=', db_over_lev);
  462. if (db_over_lev < DataMgr.DIY_challengeMode_overLev_jieSuo_Classic) {
  463. console.log('zh:判断是否可以玩该模式classic =NO');
  464. let tipStr = 'You must complete ' + DataMgr.DIY_challengeMode_overLev_jieSuo_Classic + ' levels in Challenge Mode to unlock Classic Mode.';
  465. xGame.uiMgr.Show(UIMsg, tipStr);
  466. return;
  467. } else {
  468. console.log('zh:可以玩该模式classic 66666666666666');
  469. this.beginGame();
  470. }
  471. } else {
  472. console.log('zh:不需要判断是否可以玩该classic');
  473. let challengeTimes = DataMgr.getChallengeTimes();
  474. if (challengeTimes == 0) {
  475. xGame.uiMgr.Show(UIInvitation);
  476. }
  477. else {
  478. this.beginGame();
  479. }
  480. break;
  481. }
  482. case GameMode.bigMove:
  483. console.error('zh:bigMove check');
  484. let guide = DataMgr.getSkillGuide();
  485. //zhdiy - challenge mode作为教学练习关,完成2关解锁classic,
  486. if (DataMgr.DIY_challengeMode_overLev_jieSuo_mark && guide == 1) {
  487. let db_over_lev = DataMgr.getChallengeMode_overLev();
  488. console.log('zh:bigMove db_over_lev=', db_over_lev);
  489. if (db_over_lev < DataMgr.DIY_challengeMode_overLev_jieSuo_rodMethod) {
  490. let tipStr = 'Complete ' + DataMgr.DIY_challengeMode_overLev_jieSuo_rodMethod + ' levels in Challenge Mode to unlock the Rod Method Mode';
  491. xGame.uiMgr.Show(UIMsg, tipStr);
  492. return;
  493. } else {
  494. console.log('zh:可以玩该模式 bigMove');
  495. this.beginGame();
  496. if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart0");
  497. }
  498. } else {
  499. this.beginGame();
  500. if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart0");
  501. }
  502. break;
  503. default:
  504. console.error('zh:未知错误!!!!');
  505. break;
  506. }
  507. }
  508. beginGame(isNice = false) {
  509. console.log('zh:beginGame ');
  510. //TODO:ZH 插屏AD
  511. //let time = xGame.common.randomNum(1000, 2000);
  512. //Moyu.showInsertAd(time, 60000);
  513. let guide = DataMgr.getSkillGuide();
  514. if (guide == 1) {//非新手引导,就显示,否则不显示
  515. console.log('zh:非新手引导,showInternAd ');
  516. JSBridgeUtils.instance.showInternAd('beginGame');
  517. } else {
  518. console.log('zh:新手引导,不显示AD ');
  519. }
  520. console.log('zh:beginGame 2 go');
  521. if (xGame.common.gameMode == GameMode.classic) {
  522. // xGame.uiMgr.Show(UIMsg, "Coming Soon")
  523. if (isNice) {
  524. //巅峰赛直接进入
  525. this.enterClassic();
  526. }
  527. else {
  528. xGame.uiMgr.Show(UIModeSelection, () => {
  529. console.log('zh:BBBBBBBBBBBBBBB');
  530. this.enterClassic();
  531. })
  532. }
  533. }
  534. else if (xGame.common.gameMode == GameMode.bigMove) {
  535. this.ui.enterGuide.visible = false;
  536. xGame.uiMgr.Show(UISkill);
  537. }
  538. }
  539. enterClassic() {
  540. xGame.uiMgr.Show(UIGame);
  541. xGame.uiMgr.Show(UIMatching, () => {
  542. if (!this.isHide) this.hide();
  543. xGame.common.gameUI.ui.alpha = 1;
  544. xGame.common.gameUI.startGame();
  545. xGame.uiMgr.Hide(UIGameEnd);
  546. });
  547. }
  548. /**
  549. * 模拟支付OK
  550. * @returns
  551. */
  552. start_debug_for_moni_payOk() {
  553. console.log('zh:start_debug_for_moni_payOk')
  554. let userInfo = LocalStorageManager.getItem(keyForLoginInfo);
  555. if (userInfo != null) {
  556. let token = userInfo.token;
  557. let ggSpid = 'com.vadltq.strike.ball.cue.gem50';
  558. JSBridgeUtils.instance.testPay1ForMoNiPayOver(token, ggSpid, 1);
  559. alert('模拟支付OK')
  560. return;
  561. } else {
  562. xGame.uiMgr.Show(UIMsg, TIP_MSG_key.pleaseLoginIn);
  563. }
  564. }
  565. startGlobal() {
  566. xGame.uiMgr.Show(UIMsg, "Coming Soon.")
  567. //xGame.uiMgr.Show(UITry);
  568. // JSBridgeUtils.instance.showInternAd('');
  569. }
  570. startWeekly() {
  571. //xGame.uiMgr.Show(UIBox);
  572. xGame.uiMgr.Show(UIMsg, "Coming Soon")
  573. //测试AD
  574. // GlobalManager.instance.registerMethod('zhouSaiMonth', this.zhouSaiMonth);
  575. //JSBridgeUtils.instance.showRewardAd('zhouSaiMonth');
  576. }
  577. zhouSaiMonth() {
  578. console.log('zh: zhouSaiMonth 被调用')
  579. }
  580. //网络资源是否准备好了
  581. public isReadyForLoadNetSource(): boolean {
  582. let reqCount = xGame.cfgMgr.httpReqCount;
  583. let ok = xGame.cfgMgr.httpReqOkCount;
  584. if (reqCount > ok) {
  585. //console.log('zh:网络资源没有准备完成,请稍后再试');
  586. xGame.uiMgr.Show(UIMsg, "Network not ready. Try again later.")
  587. console.log('zh:✅❌ 5秒后重新尝试加载网络资源');
  588. Laya.timer.once(5000, this, () => {
  589. let retryCount = 0;
  590. const maxRetries = 3;
  591. const tryFetchConfig = () => {
  592. try {
  593. xGame.cfgMgr.getConfigFromServer();
  594. } catch (error) {
  595. if (retryCount < maxRetries) {
  596. retryCount++;
  597. console.log(`🔄 第${retryCount}次重试获取配置...`);
  598. Laya.timer.once(5000, this, tryFetchConfig);
  599. } else {
  600. console.error("❌ 达到最大重试次数,配置获取失败");
  601. }
  602. }
  603. };
  604. tryFetchConfig();
  605. });
  606. return false;
  607. }
  608. return true;
  609. }
  610. startPlaceBall() {
  611. if (!this.isReadyForLoadNetSource()) {
  612. return;
  613. }
  614. xGame.uiMgr.Show(UILevelDisplay);
  615. }
  616. public hide(): void {
  617. console.log('zh:uimain hide ...');
  618. // console.log('zh:停止播放bjyy_m');
  619. //xGame.soundMgr.stopSound("bjyy_m");
  620. // console.log('zh: hide 停止播放主頁面背景音乐');
  621. // xGame.soundMgr.stopMusic();
  622. super.hide();
  623. xGame.common.stopGirlPop(this.ui.talkNode)
  624. }
  625. //点击头像
  626. onGetUserInfo(force = false) {
  627. if (Moyu.isWx) {
  628. let info = Moyu.getSystemInfo();
  629. if (info)
  630. Moyu.createWXUserBtn(0, 0, info.width, info.height, 'res/wxuser.png', this.freshUser);
  631. }
  632. else {
  633. Moyu.initUser(this, this.freshUser, force)
  634. }
  635. // if (!Moyu.hasUserInfo) {
  636. // let user = Moyu.getUserInfo();
  637. // //user.nickName="我";
  638. // user.headIcon = 'res/ty_touxiang.png';
  639. // //console.log("未授权");
  640. // }
  641. this.freshUser();
  642. }
  643. freshUser() {
  644. let user = Moyu.getUserInfo();
  645. if (!user.isAuth) {
  646. user.headIcon = 'res/ty_touxiang.png';
  647. }
  648. else {
  649. DataMgr.upRankData();
  650. }
  651. this.ui.headNode.nameTxt.text = xGame.tools.reviseString(user.nickName, 16);
  652. xGame.common.createHead(this.ui.headNode.headRoot.headImg, user.headIcon);
  653. let keyStr = keyForLoginInfo;
  654. if (LocalStorageManager.hasJosnKey(keyStr)) {
  655. const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyStr);
  656. let ua = d.username;
  657. this.ui.headNode.nameTxt.text = xGame.tools.reviseString(ua, 16);
  658. } else {
  659. }
  660. this.c_btn_for_user();
  661. }
  662. interuptSecretary() {
  663. Laya.timer.clearAll(this);
  664. this.playSecretaryRandomSound();
  665. }
  666. //主界面和技能选择界面3-7秒未操作随机播放秘书音效
  667. playSecretaryRandomSound() {
  668. if (this.isHide) return;
  669. let time = xGame.common.randomNum(45000, 60000);
  670. Laya.timer.once(time, this, () => {
  671. if (this.isHide) return;
  672. let index = xGame.common.randomNum(4, 7);
  673. xGame.soundMgr.playSound("s_main0" + index);
  674. let words = 1;
  675. switch (index) {
  676. case 4:
  677. words = 5;
  678. break;
  679. case 5:
  680. words = 3;
  681. break;
  682. case 6:
  683. words = 6;
  684. break;
  685. case 7:
  686. words = 7;
  687. break;
  688. default:
  689. break;
  690. }
  691. xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt);
  692. //
  693. this.playSecretaryRandomSound();
  694. })
  695. }
  696. openSecretaryView() {
  697. xGame.uiMgr.Show(UISecretary);
  698. Moyu.sendDataEvent("secretary");
  699. }
  700. openShopView() {
  701. xGame.uiMgr.Show(UIShop, 0);
  702. }
  703. openSignView() {
  704. xGame.uiMgr.Show(UISign);
  705. }
  706. openDrawView() {
  707. xGame.uiMgr.Show(UIDraw);
  708. }
  709. openRanking() {
  710. console.log('zh:phb openRanking')
  711. xGame.uiMgr.Show(UIRanking);
  712. Moyu.sendDataEvent("rankingList");
  713. }
  714. }
  715. UIMain.uiName = "UIMain";