1
0

UIMain.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. import SpineMgr from "../core/mgrs/SpineMgr";
  2. import DataMgr from "../data/DataMgr";
  3. import { CHANGE_SECRETARY, GameMode, GET_USER_INFO, RESTART_GAME, keyForLoginInfo } 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. this.ui.n83.visible = false;
  156. //万宁台球
  157. //Moyu.setShareInfo("8Ball Fury", ["台球", "台球", "桌球"], '2300002254');
  158. if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
  159. const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo);
  160. let ua = d.username;
  161. this.ui.headNode.nameTxt.text = xGame.tools.reviseString(ua, 16);
  162. }
  163. this.c_btn_for_user();
  164. window['nativeCallJs'] = this.nativeCallJs.bind(this);
  165. }
  166. Logout() {
  167. if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
  168. //const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyForLoginInfo);
  169. LocalStorageManager.removeItem(keyForLoginInfo);
  170. this.freshUser();
  171. }
  172. }
  173. gotoLogin() {
  174. xGame.uiMgr.Show(UILogin);
  175. }
  176. gotoRegUser() {
  177. xGame.uiMgr.Show(UIReg);
  178. }
  179. showFuLi() {
  180. console.log('zh:福利2');
  181. xGame.uiMgr.Show(UIFuli1);
  182. xGame.uiMgr.Show(UIFuli2);
  183. console.log('zh:福利2222');
  184. }
  185. /**
  186. * 登录注册退出
  187. */
  188. c_btn_for_user() {
  189. this.ui.n_Logout.visible = false;
  190. this.ui.n_dengLu.visible = false;
  191. this.ui.n_zhuCe.visible = false;
  192. if (LocalStorageManager.hasJosnKey(keyForLoginInfo)) {
  193. this.ui.n_Logout.visible = true;
  194. } else {
  195. this.ui.n_dengLu.visible = true;
  196. }
  197. }
  198. changeSecretary(curUse) {
  199. let name = cfgTable.secretaryshopData[curUse + 1].spine;
  200. xGame.common.secretary && xGame.common.secretary.dispose();
  201. this.addSecretarySpine(name);
  202. }
  203. addSecretarySpine(name) {
  204. let spine = new SpineMgr(name, () => {
  205. this.playSecretaryIdle();
  206. });
  207. xGame.common.secretary = spine;
  208. }
  209. addClickSpine() {
  210. let clickSpine = new SpineMgr("dianji", () => {
  211. Laya.stage.on(Laya.Event.CLICK, this, (e: Laya.Event) => {
  212. //
  213. let parent = Laya.stage;
  214. let data = { x: e.stageX, y: e.stageY, scaleX: 0.8, scaleY: 0.8 };
  215. clickSpine.play(data, 0, false, parent, (spine) => {
  216. spine.destroy(true);
  217. });
  218. })
  219. //
  220. });
  221. }
  222. private addEvent(): void {
  223. this.addUIClick(this.ui.classicBtn, this.startGame, [GameMode.classic]);
  224. this.addUIClick(this.ui.bigMoveBtn, this.startGame, [GameMode.bigMove])
  225. this.addUIClick(this.ui.ganFaMoShiBtn, this.startGame, [GameMode.bigMove])
  226. //
  227. this.addUIClick(this.ui.globalBtn, this.startGlobal);
  228. // this.addUIClick(this.ui.weeklyBtn, this.startWeekly);
  229. this.addUIClick(this.ui.placeBallBtn, this.startPlaceBall);
  230. //
  231. this.addUIClick(this.ui.headNode, this.onGetUserInfo, [true]);
  232. this.addUIClick(this.ui, this.interuptSecretary);
  233. this.addUIClick(this.ui.rightBtn, this.ensureSecretary);
  234. this.addUIClick(this.ui.guideBtn, this.startGame, [GameMode.bigMove]);
  235. this.addUIClick(this.ui.secretaryBtn, this.openSecretaryView);
  236. this.addUIClick(this.ui.shopBtn, this.openShopView);
  237. //
  238. this.addUIClick(this.ui.signBtn, this.openSignView);
  239. this.addUIClick(this.ui.drawBtn, this.openDrawView);
  240. this.addUIClick(this.ui.rankBtn, this.openRanking);
  241. //退出登录
  242. this.addUIClick(this.ui.n_Logout, this.Logout);
  243. this.addUIClick(this.ui.n_dengLu, this.gotoLogin);
  244. this.addUIClick(this.ui.n_zhuCe, this.gotoRegUser);
  245. this.addUIClick(this.ui.n_fuli, this.showFuLi);
  246. }
  247. public show(showFailWords): void {
  248. super.show();
  249. //
  250. this.moneyNode.ui.c1.selectedIndex = 1;
  251. this.playSecretaryIdle();
  252. xGame.soundMgr.playMusic("caromhall01", 0);
  253. Laya.timer.clearAll(this);
  254. this.playSecretaryRandomSound();
  255. console.log('zh:uimain.ts show show FailWords=', showFailWords);
  256. if (showFailWords) {
  257. console.log('zh:uimain.ts ')
  258. //延迟播放进入主页面的失败音效
  259. setTimeout(() => {
  260. let str = Math.random() <= 0.5 ? "s_main02" : "s_main03";
  261. let words = -1;
  262. if (str == "s_main02") {
  263. words = 2;
  264. }
  265. else {
  266. words = 3;
  267. }
  268. xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt);
  269. xGame.soundMgr.playSound(str);
  270. }, 300);
  271. }
  272. // setTimeout(() => {
  273. // console.log('zh:播放7背景音乐 m ')
  274. // xGame.soundMgr.playSound('bjyy_m', 0);
  275. // }, 2000);
  276. //
  277. this.showGuide();
  278. this.ui.guideBtn.x = this.ui.liucheng2.myMask.x;
  279. this.ui.guideBtn.y = this.ui.liucheng2.myMask.y;
  280. //
  281. let guide = DataMgr.getSkillGuide();
  282. if (guide == 1) {
  283. let randTime = xGame.common.randomNum(300, 800);
  284. if (this.firstEnter) {
  285. console.log("zh: firstEnter");
  286. this.firstEnter = false;
  287. randTime += 900;
  288. } else {
  289. console.log("zh: no firstEnter");
  290. }
  291. Laya.timer.once(randTime, this, () => {
  292. xGame.common.autoPopUIView();
  293. })
  294. }
  295. }
  296. checkActive(show) {
  297. //console.log("是否处于最外层",show);
  298. //wx banner太大
  299. // if (!Moyu.isWx)
  300. // PlatMgr.showBanner(show);
  301. }
  302. showGuide() {
  303. let guide = DataMgr.getSkillGuide();
  304. this.ui.guideBtn.visible = guide == 0;
  305. this.ui.enterGuide.visible = false;
  306. this.ui.secretaryGuide.visible = guide == 0;
  307. if (guide == 0) {
  308. console.log("zh:显示引导");
  309. xGame.soundMgr.playSound("s_guide");
  310. xGame.common.showGirlTalkPop(16, this.ui.talkNode, this.ui.talkNode.womanTxt);
  311. } else {
  312. console.log("zh:不需要显示引导");
  313. }
  314. }
  315. ensureSecretary() {
  316. console.log('zh: ensureSecretary ensureSecretaryensureSecretaryensureSecretaryensureSecretaryensureSecretary')
  317. this.ui.secretaryGuide.visible = false;
  318. this.ui.enterGuide.visible = true;
  319. this.ui.wordsNode.t0.play();
  320. //todo
  321. if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameReady");
  322. }
  323. playSecretaryIdle() {
  324. let parent = this.ui.secretary.displayObject;
  325. parent.destroyChildren();
  326. let xx = this.ui.secretary.width / 2;
  327. let yy = this.ui.secretary.height;
  328. // xx = Laya.stage.width / 2;
  329. // yy = Laya.stage.height;
  330. let scale = xGame.common.getSecretaryScale();
  331. let data = { x: xx, y: yy, scaleX: scale, scaleY: scale };
  332. //console.log("zh:playSecretaryIdle", data);
  333. //xGame.common.secretary.play(data, 1, true, parent); 这是老的秘书
  334. xGame.common.secretary.play(data, 0, true, parent);
  335. }
  336. startGame(type: GameMode) {
  337. if (!this.isReadyForLoadNetSource()) {
  338. return;
  339. }
  340. // console.log('zh: 停止播放主頁面背景音乐');
  341. // xGame.soundMgr.stopMusic();
  342. //进入游戏页面
  343. xGame.common.gameMode = type;
  344. //
  345. Moyu.sendDataEvent("PlayGame", { type: type });
  346. console.log('zh:进入游戏gameMode =' + xGame.common.gameMode);
  347. switch (xGame.common.gameMode) {
  348. case GameMode.classic:
  349. console.log('zh:进入经典模式111111111');
  350. //zhdiy - challenge mode作为教学练习关,完成2关解锁classic,
  351. if (DataMgr.DIY_challengeMode_overLev_jieSuo_mark) {
  352. let db_over_lev = DataMgr.getChallengeMode_overLev();
  353. console.log('zh:classic db_over_lev=', db_over_lev);
  354. if (db_over_lev < DataMgr.DIY_challengeMode_overLev_jieSuo_Classic) {
  355. console.log('zh:判断是否可以玩该模式classic =NO');
  356. let tipStr = 'You must complete ' + DataMgr.DIY_challengeMode_overLev_jieSuo_Classic + ' levels in Challenge Mode to unlock Classic Mode.';
  357. xGame.uiMgr.Show(UIMsg, tipStr);
  358. return;
  359. } else {
  360. console.log('zh:可以玩该模式classic 66666666666666');
  361. this.beginGame();
  362. }
  363. } else {
  364. console.log('zh:不需要判断是否可以玩该classic');
  365. let challengeTimes = DataMgr.getChallengeTimes();
  366. if (challengeTimes == 0) {
  367. xGame.uiMgr.Show(UIInvitation);
  368. }
  369. else {
  370. this.beginGame();
  371. }
  372. break;
  373. }
  374. case GameMode.bigMove:
  375. console.error('zh:bigMove check');
  376. let guide = DataMgr.getSkillGuide();
  377. //zhdiy - challenge mode作为教学练习关,完成2关解锁classic,
  378. if (DataMgr.DIY_challengeMode_overLev_jieSuo_mark && guide == 1) {
  379. let db_over_lev = DataMgr.getChallengeMode_overLev();
  380. console.log('zh:bigMove db_over_lev=', db_over_lev);
  381. if (db_over_lev < DataMgr.DIY_challengeMode_overLev_jieSuo_rodMethod) {
  382. let tipStr = 'Complete ' + DataMgr.DIY_challengeMode_overLev_jieSuo_rodMethod + ' levels in Challenge Mode to unlock the Rod Method Mode';
  383. xGame.uiMgr.Show(UIMsg, tipStr);
  384. return;
  385. } else {
  386. console.log('zh:可以玩该模式 bigMove');
  387. this.beginGame();
  388. if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart0");
  389. }
  390. } else {
  391. this.beginGame();
  392. if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart0");
  393. }
  394. break;
  395. default:
  396. console.error('zh:未知错误!!!!');
  397. break;
  398. }
  399. }
  400. beginGame(isNice = false) {
  401. console.log('zh:beginGame ');
  402. //TODO:ZH 插屏AD
  403. //let time = xGame.common.randomNum(1000, 2000);
  404. //Moyu.showInsertAd(time, 60000);
  405. let guide = DataMgr.getSkillGuide();
  406. if (guide == 1) {//非新手引导,就显示,否则不显示
  407. console.log('zh:非新手引导,showInternAd ');
  408. JSBridgeUtils.instance.showInternAd('beginGame');
  409. } else {
  410. console.log('zh:新手引导,不显示AD ');
  411. }
  412. console.log('zh:beginGame 2 go');
  413. if (xGame.common.gameMode == GameMode.classic) {
  414. // xGame.uiMgr.Show(UIMsg, "Coming Soon")
  415. if (isNice) {
  416. //巅峰赛直接进入
  417. this.enterClassic();
  418. }
  419. else {
  420. xGame.uiMgr.Show(UIModeSelection, () => {
  421. console.log('zh:BBBBBBBBBBBBBBB');
  422. this.enterClassic();
  423. })
  424. }
  425. }
  426. else if (xGame.common.gameMode == GameMode.bigMove) {
  427. this.ui.enterGuide.visible = false;
  428. xGame.uiMgr.Show(UISkill);
  429. }
  430. }
  431. enterClassic() {
  432. xGame.uiMgr.Show(UIGame);
  433. xGame.uiMgr.Show(UIMatching, () => {
  434. if (!this.isHide) this.hide();
  435. xGame.common.gameUI.ui.alpha = 1;
  436. xGame.common.gameUI.startGame();
  437. xGame.uiMgr.Hide(UIGameEnd);
  438. });
  439. }
  440. startGlobal() {
  441. xGame.uiMgr.Show(UIMsg, "Coming Soon")
  442. //xGame.uiMgr.Show(UITry);
  443. // JSBridgeUtils.instance.showInternAd('');
  444. }
  445. startWeekly() {
  446. //xGame.uiMgr.Show(UIBox);
  447. xGame.uiMgr.Show(UIMsg, "Coming Soon")
  448. //测试AD
  449. // GlobalManager.instance.registerMethod('zhouSaiMonth', this.zhouSaiMonth);
  450. //JSBridgeUtils.instance.showRewardAd('zhouSaiMonth');
  451. }
  452. zhouSaiMonth() {
  453. console.log('zh: zhouSaiMonth 被调用')
  454. }
  455. //网络资源是否准备好了
  456. public isReadyForLoadNetSource(): boolean {
  457. let reqCount = xGame.cfgMgr.httpReqCount;
  458. let ok = xGame.cfgMgr.httpReqOkCount;
  459. if (reqCount > ok) {
  460. //console.log('zh:网络资源没有准备完成,请稍后再试');
  461. xGame.uiMgr.Show(UIMsg, "Network not ready. Try again later.")
  462. console.log('zh:✅❌ 5秒后重新尝试加载网络资源');
  463. Laya.timer.once(5000, this, () => {
  464. let retryCount = 0;
  465. const maxRetries = 3;
  466. const tryFetchConfig = () => {
  467. try {
  468. xGame.cfgMgr.getConfigFromServer();
  469. } catch (error) {
  470. if (retryCount < maxRetries) {
  471. retryCount++;
  472. console.log(`🔄 第${retryCount}次重试获取配置...`);
  473. Laya.timer.once(5000, this, tryFetchConfig);
  474. } else {
  475. console.error("❌ 达到最大重试次数,配置获取失败");
  476. }
  477. }
  478. };
  479. tryFetchConfig();
  480. });
  481. return false;
  482. }
  483. return true;
  484. }
  485. startPlaceBall() {
  486. if (!this.isReadyForLoadNetSource()) {
  487. return;
  488. }
  489. xGame.uiMgr.Show(UILevelDisplay);
  490. }
  491. public hide(): void {
  492. console.log('zh:uimain hide ...');
  493. // console.log('zh:停止播放bjyy_m');
  494. //xGame.soundMgr.stopSound("bjyy_m");
  495. // console.log('zh: hide 停止播放主頁面背景音乐');
  496. // xGame.soundMgr.stopMusic();
  497. super.hide();
  498. xGame.common.stopGirlPop(this.ui.talkNode)
  499. }
  500. //点击头像
  501. onGetUserInfo(force = false) {
  502. if (Moyu.isWx) {
  503. let info = Moyu.getSystemInfo();
  504. if (info)
  505. Moyu.createWXUserBtn(0, 0, info.width, info.height, 'res/wxuser.png', this.freshUser);
  506. }
  507. else {
  508. Moyu.initUser(this, this.freshUser, force)
  509. }
  510. // if (!Moyu.hasUserInfo) {
  511. // let user = Moyu.getUserInfo();
  512. // //user.nickName="我";
  513. // user.headIcon = 'res/ty_touxiang.png';
  514. // //console.log("未授权");
  515. // }
  516. this.freshUser();
  517. }
  518. freshUser() {
  519. let user = Moyu.getUserInfo();
  520. if (!user.isAuth) {
  521. user.headIcon = 'res/ty_touxiang.png';
  522. }
  523. else {
  524. DataMgr.upRankData();
  525. }
  526. this.ui.headNode.nameTxt.text = xGame.tools.reviseString(user.nickName, 16);
  527. xGame.common.createHead(this.ui.headNode.headRoot.headImg, user.headIcon);
  528. let keyStr = keyForLoginInfo;
  529. if (LocalStorageManager.hasJosnKey(keyStr)) {
  530. const d = LocalStorageManager.getItem<{ username: string, token: string }>(keyStr);
  531. let ua = d.username;
  532. this.ui.headNode.nameTxt.text = xGame.tools.reviseString(ua, 16);
  533. } else {
  534. }
  535. this.c_btn_for_user();
  536. }
  537. interuptSecretary() {
  538. Laya.timer.clearAll(this);
  539. this.playSecretaryRandomSound();
  540. }
  541. //主界面和技能选择界面3-7秒未操作随机播放秘书音效
  542. playSecretaryRandomSound() {
  543. if (this.isHide) return;
  544. let time = xGame.common.randomNum(45000, 60000);
  545. Laya.timer.once(time, this, () => {
  546. if (this.isHide) return;
  547. let index = xGame.common.randomNum(4, 7);
  548. xGame.soundMgr.playSound("s_main0" + index);
  549. let words = 1;
  550. switch (index) {
  551. case 4:
  552. words = 5;
  553. break;
  554. case 5:
  555. words = 3;
  556. break;
  557. case 6:
  558. words = 6;
  559. break;
  560. case 7:
  561. words = 7;
  562. break;
  563. default:
  564. break;
  565. }
  566. xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt);
  567. //
  568. this.playSecretaryRandomSound();
  569. })
  570. }
  571. openSecretaryView() {
  572. xGame.uiMgr.Show(UISecretary);
  573. Moyu.sendDataEvent("secretary");
  574. }
  575. openShopView() {
  576. xGame.uiMgr.Show(UIShop, 0);
  577. }
  578. openSignView() {
  579. xGame.uiMgr.Show(UISign);
  580. }
  581. openDrawView() {
  582. xGame.uiMgr.Show(UIDraw);
  583. }
  584. openRanking() {
  585. console.log('zh:phb openRanking')
  586. xGame.uiMgr.Show(UIRanking);
  587. Moyu.sendDataEvent("rankingList");
  588. }
  589. }
  590. UIMain.uiName = "UIMain";