123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- 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";
- export default class UIMain extends UIBase {
- public ui: ui_UIMain;
- //
- public settingNode: SettingNode;
- public moneyNode: MoneyNode;
- public firstEnter = true;
- public constructor() {
- super();
- }
- protected onConstructor(): void {
- this.ui = ui_UIMain.createInstance();
- this.contentPane = this.ui;
- this.isEject = 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("播放小秘书每天语音");
- }
- this.onGetUserInfo();
- this.ui.n83.visible = false;
- //万宁台球
- Moyu.setShareInfo("8Ball Fury", ["台球", "万宁", "桌球"], '2300002254');
- }
- 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");
- //
- Laya.timer.clearAll(this);
- this.playSecretaryRandomSound();
- if (showFailWords) {
- //延迟播放进入主页面的失败音效
- 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);
- }
- //
- 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) {
- this.firstEnter = false;
- randTime += 900;
- }
- 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) {
- xGame.soundMgr.playSound("s_guide");
- xGame.common.showGirlTalkPop(16, this.ui.talkNode, this.ui.talkNode.womanTxt);
- }
- }
- ensureSecretary() {
- 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;
- let scale = xGame.common.getSecretaryScale();
- let data = { x: xx, y: yy, scaleX: scale, scaleY: scale };
- xGame.common.secretary.play(data, 1, true, parent);
- }
- startGame(type: GameMode) {
- //进入游戏页面
- xGame.common.gameMode = type;
- //
- Moyu.sendDataEvent("PlayGame", { type: type });
- switch (xGame.common.gameMode) {
- case GameMode.classic:
- let challengeTimes = DataMgr.getChallengeTimes();
- if (challengeTimes == 0) {
- xGame.uiMgr.Show(UIInvitation);
- }
- else {
- this.beginGame();
- }
- break;
- case GameMode.bigMove:
- this.beginGame();
- if (DataMgr.getNewUser()) Moyu.sendDataEvent("gameStart0");
- break;
- default:
- break;
- }
- }
- beginGame(isNice = false) {
- //
- //let time = xGame.common.randomNum(1000, 2000);
- //Moyu.showInsertAd(time, 60000);
- //
- if (xGame.common.gameMode == GameMode.classic) {
- //
- if (isNice) {
- //巅峰赛直接进入
- this.enterClassic();
- }
- else {
- xGame.uiMgr.Show(UIModeSelection, () => {
- 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, "敬请期待~")
- //xGame.uiMgr.Show(UITry);
- }
- startWeekly() {
- //xGame.uiMgr.Show(UIBox);
- xGame.uiMgr.Show(UIMsg, "敬请期待~")
- }
- startPlaceBall() {
- xGame.uiMgr.Show(UILevelDisplay);
- //xGame.uiMgr.Show(UIMsg, "敬请期待~")
- }
- public hide(): void {
- 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() {
- xGame.uiMgr.Show(UIRanking);
- Moyu.sendDataEvent("rankingList");
- }
- }
- UIMain.uiName = "UIMain";
|