// 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 { valueObj } from "../Model/data/baseObject"; import { IDDef } from "../Model/data/excelDefine"; import ProxyClientDataMgr, { fishCathOnline } from "../Model/ProxyClientDataMgr"; import fishingUpgradeModule from "../module/fishingUpgradeModule"; import UIFishBookLayer from "./UIFishBookLayer"; import UIFishEarningsLayer from "./UIFishEarningsLayer"; import UIShowFashingLayer from "./UIShowFashingLayer"; const {ccclass, property} = cc._decorator; @ccclass export default class UIFishingLayer extends UIBaseEv{ panelType: PanelType = PanelType.PopUp; canDestory = true; @property(cc.Button) taskBtn:cc.Button = null; @property(cc.Button) signInBtn:cc.Button = null; @property(cc.Button) settingBtn:cc.Button = null; @property(cc.Button) addGoldBtn:cc.Button = null; @property(cc.Button) bookBtn:cc.Button = null; @property(cc.Button) cancleBtn:cc.Button = null; @property(cc.Layout) areaLayer:cc.Layout = null; @property(cc.Label) goldLabel:cc.Label = null; @property(cc.Layout) shipLayer:cc.Layout = null; @property(cc.ScrollView) scrollView:cc.ScrollView = null; @property(cc.Button) flexBtn:cc.Button = null; flexStage = false; flexDownPos = cc.v2(0,-300); flexUpPos = cc.v2(0,280); flexDownHeight = 280; flexUpHeight = 860; spwanCount = 0; spacing = 10; _content = null; _lastContentPos = null; _maxCount = 6; _items = []; singlePrefab= null; tArrFashingFacility:valueObj[] = []; onClickEvent(event,customEventData){ let node = event.target; let button = node.getComponent(cc.Button); switch (+customEventData) { case 0: this.clickFlex(); //CMD_Config.ins.popManager().closeAction(this.node); //this.node.active = false; break; case 1: //CMD_Config.ins.popManager().closeAction(this.node); UIFishingLayer.closeView(); ProxyClientDataMgr.ins().doFishStatistics(true); //this.node.active = false; break; case 2: //CMD_Config.ins.popManager().closeAction(this.node); UIFishBookLayer.openView(); //this.node.active = false; break; default: break; } } clickFlex() { if(this.flexStage) { this.scrollView.node.height = this.flexDownHeight; this.scrollView.node.getChildByName('view').height = this.flexDownHeight - this.flexBtn.node.height; this.scrollView.node.setPosition(this.flexDownPos) this.flexStage = false; } else{ this.scrollView.node.height = this.flexUpHeight; this.scrollView.node.getChildByName('view').height = this.flexUpHeight - this.flexBtn.node.height; this.scrollView.node.setPosition(this.flexUpPos) this.flexStage = true; } } flexStageCallFunc(){ if(!this.flexStage) { this.scrollView.node.height = this.flexUpHeight; this.scrollView.node.getChildByName('view').height = this.flexUpHeight - this.flexBtn.node.height; this.scrollView.node.setPosition(this.flexUpPos) this.flexStage = true; } } initShipLayer(){ } async initScrollView(){ let PanelPath = "Prefabs/fishingUpgradeModule"; // let pre = await ResManager.inst.loadPrefab(PanelPath); // if(!pre) { // cc.warn(`${PanelPath} 资源加载失败, 请确认路径是否正确`); // return ; // } if(this._items.length === 0) { for (let i = 0; i < this._maxCount; i++) { let item:cc.Node = await this.addChildPerfab(PanelPath,this._content); item.setPosition(0,- item.height * i - this.spacing*(i + 1)); this._items.push(item); item.active = false; } } this._content.height = this._maxCount*(this._items[0].height + this.spacing) + this.spacing + this.flexBtn.node.height; this.updataScrollViewUI(); } updataScrollViewUI() { for (let i = 0; i < this._maxCount; i++) { this._items[i].getComponent(fishingUpgradeModule).onShow(this.tArrFashingFacility[i]); } } onEnable(){ this.scrollView.node.on(cc.Node.EventType.TOUCH_START,this.flexStageCallFunc,this); } onDisable(){ this.scrollView.node.off(cc.Node.EventType.TOUCH_START,this.flexStageCallFunc,this); } onShow() { this.initEvent(); this.updateGold(); let fashingObj = ProxyClientDataMgr.ins().getComposeObj(IDDef.FISHING) let tempObj = fashingObj.getMemberMap(); for (let i of tempObj.values()) { this.tArrFashingFacility.push(i as valueObj); } let tArrFishStatistics:Array = ProxyClientDataMgr.ins().doFishStatistics(false); if(tArrFishStatistics.length>0) { UIFishEarningsLayer.openView(tArrFishStatistics); } //this.updateBtnUi(); } // LIFE-CYCLE CALLBACKS: // onLoad () {} initEvent() { this.registEvent(MSG_Event.ParkFeeCoin,()=>{ this.updateGold(); }); this.registEvent(MSG_Event.FishSaleCoin,(catchedData:fishCathOnline)=>{ UIShowFashingLayer.openView(catchedData) this.updateGold(); }); this.registEvent(MSG_Event.OperChangeCoin,()=>{ this.updateGold(); }); } updateGold() { let temp = ProxyClientDataMgr.ins().getValueObj(1001) this.goldLabel.string = ""+temp.getCount(); } start () { this._content = this.scrollView.content; this.initScrollView(); this.initShipLayer(); } // update (dt) {} }