var baseScene = require('BaseScene'); import EventMgr from "../base/EventMgr"; import ResMgr from "../base/ResMgr"; import UIMgr from "../base/UIMgr"; import SoundMgr from "../base/SoundMgr"; import Tool from "../base/Tool"; import UserInfoMgr from "../base/user/UserInfoMgr"; cc.Class({ extends: baseScene, properties: { atlasVIP: cc.SpriteAtlas, //vip图集 labCoin: cc.Label, labBli: cc.Label, labName: cc.Label, labID: cc.Label, labHBNum: cc.Label, labYGNum: cc.Label, labJixian: cc.Label, spHead: cc.Sprite, spVipDi: cc.Sprite, spVip: cc.Sprite, yunNode: cc.Node, haidaoNode: cc.Node, centerNode: cc.Node, roomNode: cc.Node, shopNode: cc.Node, mailNode: cc.Node, exchangeNode: cc.Node, btnsNode: cc.Node, jiaziNode: cc.Node, jixianSuoNode: cc.Node, paomaNode: cc.Node, dropDownNode: cc.Node, //下拉内容 geduanNode: cc.Node, //遮挡(防止瞎点) }, // LIFE-CYCLE CALLBACKS: onLoad () { this._super(); this.initData(); this.initListeners(); this.setPopLayerData(); // var frameSize = cc.view.getFrameSize(); // if (frameSize.width / frameSize.height < 1.65) { // cc.view.setDesignResolutionSize(720,1280, cc.ResolutionPolicy.FIXED_WIDTH); // } }, start () { this.onShow(); this.popLayer(); this.setPlayerInfo(); this.setPoolValue(); cc.director.preloadScene("gameScene"); }, // update (dt) {}, initData(){ this.popLayers = []; //存储需要自动打开的界面 this.llkConfig = ConfigModel.getGlobalConfigByKey("llk"); }, initListeners(){ // this.registerListener('121', this.setPlayerInfo); this.registerListener('121', this.setPlayerInfo); EventMgr.on(EventType.OtherJC_REFRESH, this.setPoolValue, this); //刷新奖池 }, setPopLayerData(){ this.popLayers = []; // this.popLayers.push('xxxxx'); }, popLayer(){ if(this.popLayers.length <= 0){ this.showGeduan(false); return; } let tempPop = this.popLayers.shift(); let self = this; this.showGeduan(true); if(tempPop){ UIMgr.openUI(`prefabs/${tempPop}`, (pf)=>{ pf.getComponent(tempPop).setCloseBack(()=>{ self.scheduleOnce(()=>{ self.popLayer(); }); }); }); } }, onShow(){ if(this.llkConfig.Onoff == 1 && GameModel.player.VIPExp >= this.llkConfig.Viplimt){ this.jixianSuoNode.active = true; }else{ this.jixianSuoNode.active = false; } }, setPlayerInfo(){ this.labCoin.string = utils.getGoldString(GameModel.getItemCountByModel(GAME_RES_MAP.Gold)); this.labBli.string = GameModel.getItemCountByModel(GAME_RES_MAP.Red); console.log('sasdas: ', GameModel.player); this.labName.string = GameModel.player.Name; this.labID.string = `ID:${GameModel.player.ID}`; let vipLv = utils.getVipLevel(); this.spVipDi.spriteFrame = this.atlasVIP.getSpriteFrame(`VIPdi${vipLv+1}`); this.spVip.spriteFrame = this.atlasVIP.getSpriteFrame(`VIP${vipLv+1}`); ResMgr.loadRemoteTexture(this.spHead, GameModel.player.Head); /* this.labHBNum.string = 222222; this.labYGNum.string = 333333; ResMgr.loadTexture('texture/head/h1', (sp)=>{ this.spHead.spriteFrame = sp; this.spHead.node.width = 90; this.spHead.node.height = 90; }); */ }, setPoolValue(){ let value1 = Tool.formatNumber(GameModel.pool3, 7); let value2 = Tool.formatNumber(GameModel.pool1, 7); let value3 = Tool.formatNumber(GameModel.Pool7, 7); this.labHBNum.string = value1; this.labYGNum.string = value2; this.labJixian.string = value3; }, showGeduan(bShow = false){ this.geduanNode.active = bShow; }, showHides(bShow){ for(let i=1; i< this.centerNode.childrenCount; i++){ this.centerNode.children[i].active = false; } if(this.centerNode.children[0].active) //房间界面只能自己关闭 bShow = false; this.yunNode.active = bShow; this.haidaoNode.active = bShow; this.btnsNode.active = bShow; this.jiaziNode.active = bShow; this.paomaNode.getComponent('PaomaLayer').setShowOrHide(bShow); }, //---------------------点击事件--------------------------- onClickHongbao(){ SoundMgr.playClick(); // EventMgr.emit('paopao', 'Hello World'); this.showHides(false); this.roomNode.getComponent('RoomLayer').showRoom(this, 1); }, //赏金争夺 onClickBonusRank(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/BonusRankLayer'); }, onClickYuangu(){ SoundMgr.playClick(); this.showHides(false); this.roomNode.getComponent('RoomLayer').showRoom(this, 2); }, onClickJixian(){ SoundMgr.playClick(); this.showHides(false); this.roomNode.getComponent('RoomLayer').showRoom(this, 3); }, onClickCoin(){ // 测试 // UIMgr.openUI('prefabs/TipsLayer', (pf)=>{ // pf.getComponent('TipsLayer').setCon('飒飒飒飒'); // }); // UIMgr.openUI('prefabs/GetRewardLayer', (pf)=>{ // pf.getComponent('GetRewardLayer').initData(); // }); this.onClickShop(); }, onClickBli(){ SoundMgr.playClick(); this.showHides(false); this.exchangeNode.getComponent('ExchangeLayer').showExchange(this); }, onClickHead(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/PlayerInfoLayer'); }, onClickMenu(){ SoundMgr.playClick(); this.dropDownNode.active = !this.dropDownNode.active; let tPosY = [80, -10, -100]; if(this.dropDownNode.active){ Tool.effectMoveY(this.dropDownNode, tPosY); } }, onClickFirst(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/FirstChargeLayer'); }, onClickSign(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/SignLayer'); }, onClickService(){ SoundMgr.playClick(); }, onClickSet(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/SetLayer'); }, onClickChaozhi(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/FortuneGiftLayer'); }, onClickMonthCard(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/MonthCardLayer'); }, onClickZhaocai(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/ZhaoCaiLayer'); }, onClickVIP(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/VIPLayer'); }, onClickShare(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/ShareTaskLayer'); }, onClickRedgrowth(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/RedGrowthLayer'); }, onClickInvestment(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/SevenInvestLayer'); }, onClickExchangeTask(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/ExchangeTaskLayer'); }, onClickMail(){ SoundMgr.playClick(); this.showHides(false); this.mailNode.getComponent('MailLayer').showMail(this); }, onClickActivity(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/ActivityLayer'); }, onClickShop(){ SoundMgr.playClick(); this.showHides(false); this.shopNode.getComponent('ShopLayer').showShop(this); }, onClickTask(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/TaskLayer', (pf)=>{ pf.getComponent('TaskLayer').initData(); }); }, onClickDailySale(){ SoundMgr.playClick(); UIMgr.openUI('prefabs/TeHuiLayer', (pf)=>{ // pf.getComponent('TeHuiLayer').initData(); }); }, });