// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html import ResManager from "../../common/res/ResManager"; import UIBase from "../../common/ui/base/UIBase"; import { PanelType } from "../../common/ui/config/SysDefine"; import UIBaseEv from "../../common/ui/uiEv/UIBaseEv"; import { MSG_Event } from "../DefineMsg/LogicMsg"; import AccountManager from "../Model/data/AccountManager"; import { valueObj } from "../Model/data/baseObject"; import ProxyClientDataMgr, { offLineData } from "../Model/ProxyClientDataMgr"; import ProxyNetDataMgr from "../Model/ProxyNetDataMgr"; import UIFishBookLayer from "./UIFishBookLayer"; import UIFishingLayer from "./UIFishingLayer"; import UIOnlineLayer from "./UIOnlineLayer"; import UISignInLayer from "./UISignInLayer"; import UISingleVenueLayer from "./UISingleVenueLayer"; //import lobbyAreaLayer from "./LobbyAreaLayer"; //import PopManager from "./PopManager"; const {ccclass, property} = cc._decorator; export enum BTN_TYPE{ BOOK, VENUE, SPEED, FISHING, ADDGOLD, PASSPAGE, BACKPAGE, SIGNIN } @ccclass export default class UILobbyLayer extends UIBaseEv { @property(cc.Layout) areaLayer:cc.Layout = null; @property(cc.PageView) pageViewLayer:cc.PageView = null; @property(cc.Layout) pageViewContent:cc.Layout = null; @property(cc.Button) bookBtn:cc.Button = null; @property(cc.Button) venueBtn:cc.Button = null; @property(cc.Button) speedBtn:cc.Button = null; @property(cc.Button) fishingBtn:cc.Button = null; @property(cc.Button) addGoldBtn:cc.Button = null; @property(cc.Button) areaPassBtn:cc.Button = null; @property(cc.Button) areaBackBtn:cc.Button = null; @property(cc.Button) signInBtn:cc.Button = null; @property(cc.Button) settingBtn:cc.Button = null; @property(cc.Button) taskBtn:cc.Button = null; parentNode = null; bGetSpeed = false; panelType: PanelType = PanelType.Screen; page_X = []; goldLabel:cc.Label = null; // LIFE-CYCLE CALLBACKS: // onLoad () {} private getSpeedOn():void { cc.director.getScheduler().setTimeScale(5); } private getSpeedOff():void { cc.director.getScheduler().setTimeScale(1); } onClickEvent(event,customEventData):void { let node = event.target; let button = node.getComponent(cc.Button); switch (+customEventData) { case BTN_TYPE.BOOK: console.log("0000000"); UIFishBookLayer.openView(); //this.popupLayer.getComponent(PopManager).openPanel(3,{}); break; case BTN_TYPE.VENUE: console.log("1111111"); break; case BTN_TYPE.SPEED: console.log("22222"); break; case BTN_TYPE.FISHING: UIFishingLayer.openView(); //this.popupLayer.getComponent(PopManager).openPanel(2,{}); console.log("333333"); break; case BTN_TYPE.ADDGOLD: console.log("444444"); break; case BTN_TYPE.PASSPAGE: this.changeAddPage(true); console.log("passBtn"); break; case BTN_TYPE.BACKPAGE: this.changeAddPage(false); console.log("backBtn"); break; case BTN_TYPE.SIGNIN: UISignInLayer.openView(); break; default: break; } } async onLoad() { //初始化 for (let i = 0; i < this.pageViewContent.node.childrenCount; i++) { this.page_X[i] = this.pageViewContent.node.children[i]; let PanelPath = "UIPanels/UISingleVenueLayer"; let pre = await ResManager.inst.loadPrefab(PanelPath); if(!pre) { cc.warn(`${PanelPath} 资源加载失败, 请确认路径是否正确`); return ; } let node: cc.Node = cc.instantiate(pre); this.pageViewContent.node.children[i].addChild(node); this.page_X[i].ts = node.getComponent(UISingleVenueLayer); node.getComponent(UISingleVenueLayer).onShow(i); } } onEnable(){ this.speedBtn.node.on(cc.Node.EventType.TOUCH_START,this.getSpeedOn,this); this.speedBtn.node.on(cc.Node.EventType.TOUCH_END,this.getSpeedOff,this); } onDisable() { this.speedBtn.node.off(cc.Node.EventType.TOUCH_START,this.getSpeedOn,this); this.speedBtn.node.off(cc.Node.EventType.TOUCH_END,this.getSpeedOff,this); } changeAddPage(bAdd):void { let curIndex = this.pageViewLayer.getCurrentPageIndex(); let allPageNumber = this.pageViewContent.node.childrenCount; if(bAdd) { if((curIndex + 1) < allPageNumber) { this.pageViewLayer.scrollToPage(curIndex + 1 ,0.3); } } else { if((curIndex + 1) > 1) { this.pageViewLayer.scrollToPage(curIndex - 1,0.3); } } } initEvent() { this.registEvent(MSG_Event.ParkFeeCoin,()=>{ this.updateGold(); }); this.registEvent(MSG_Event.FishSaleCoin,()=>{ this.updateGold(); }); this.registEvent(MSG_Event.OperChangeCoin,()=>{ this.updateGold(); }); this.registEvent(MSG_Event.OffLineRevenue,(offlineDt:offLineData)=>{ UIOnlineLayer.openView(offlineDt); }) this.registEvent(MSG_Event.Net_DoSignInResp,(x)=>{ let signRed = this.signInBtn.node.getChildByName("redSpr"); let bShowSignRed = ProxyClientDataMgr.ins().isTodaySignInAble(); signRed.active = bShowSignRed; }) } updateGold() { let temp = ProxyClientDataMgr.ins().getValueObj(1001) //let tempObj= AccountManager.ins().getGameInfo().getMember(1001) as valueObj; this._Labels.LobbyGold.string = ""+temp.getCount(); } start () { this.updateGold(); ProxyClientDataMgr.ins().OffLineRevenue(); ProxyClientDataMgr.ins().doFishStatistics(true); this.initUI(); } initUI() { let signRed = this.signInBtn.node.getChildByName("redSpr"); let bShowSignRed = ProxyClientDataMgr.ins().isTodaySignInAble(); signRed.active = bShowSignRed; } init(Node) { } // update (dt) {} }