import TaskManager, { MainTaskIdEnum } from "./TaskManager"; const { ccclass, property } = cc._decorator; @ccclass export default class TaskInfoView extends cc.Component { @property(cc.Node) boxNode: cc.Node = null; @property(cc.Label) tittleStr: cc.Label = null; @property(cc.Label) contentDesc: cc.Label = null; @property(cc.Label) subTitle: cc.Label = null; // @property(cc.Label) // taskPos: cc.Label = null; // LIFE-CYCLE CALLBACKS: // onLoad () {} isCanTouch = false start() { } init(time?) { this.node.getChildByName("maskNode").active = true this.refreshView() // cc.tween(this.boxNode) // .set({x:-700}) // .to(0.3,{x:50}) // .call(()=>{ // this.isCanTouch = true // // this.node.getChildByName('收起按钮').active = true // }) // .start() // this.scheduleOnce(()=>{ // this.onClose() // },3) cc.Tween.stopAllByTarget(this.node) cc.Tween.stopAllByTarget(this.boxNode) this.contentDesc["_forceUpdateRenderData"](true); let strwidth = this.contentDesc.node.width if (strwidth <= 300) { this.scheduleOnce(() => { let size = this.boxNode.getContentSize() this.boxNode.setContentSize(cc.size(400, size.height)) this.contentDesc.node.setAnchorPoint(cc.v2(0.5, 0.5)) this.contentDesc.node.setPosition(cc.v3(200 + 25, 0, 0)) this.boxNode.getChildByName("框体右侧").getComponent(cc.Widget).updateAlignment() }) } else { let size = this.boxNode.getContentSize() this.boxNode.setContentSize(cc.size(strwidth + 50, size.height)) this.contentDesc.getComponent(cc.Widget).updateAlignment() this.boxNode.getChildByName("框体右侧").getComponent(cc.Widget).updateAlignment() } cc.tween(this.boxNode) .set({ active: true }) .set({ position: cc.v3(-700, this.boxNode.y) }) .to(0.3, { x: 0 }) .call(() => { this.isCanTouch = true // this.node.getChildByName('收起按钮').active = true }) .start() let delaytime = time ?? 3 cc.tween(this.node) .sequence( cc.tween().delay(delaytime), cc.tween().call(() => { this.onClose() }) ) .start() // this.scheduleOnce(() => { // this.onClose() // }, 3) } refreshView() { console.log('TaskInfoView') let customTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let taskId = customTaskInfo.Id let config = TaskManager.getTaskConfigById(taskId) if (config) { // this.tittleStr.string = config.TaskTittle this.contentDesc.string = config.TaskDesc // this.subTitle.string = "任务"+config.subtitle // this.taskPos.string = config.TaskTiaoZhuan } else { // this.tittleStr.string = '' this.contentDesc.string = '当前无任务' // this.subTitle.string = '' // this.taskPos.string = '' } // //补丁,因部分字段未保存数据,给线上玩家补上 // if(taskId > MainTaskIdEnum.MainTask_532){ // let hetongData = User.getUserHeTong() // hetongData.buyYeLianChang = true // User.setUserHeTong(hetongData,false) // } // if(taskId > MainTaskIdEnum.MainTask_527){ // User.setIsChongFanHaoMen(true,false) // } } onClose() { if (!this.isCanTouch) { return } this.isCanTouch = false // this.node.getChildByName('收起按钮').active = false cc.tween(this.boxNode) .to(0.3, { x: -700 }) .call(() => { // this.node.active = false // this.node.removeFromParent() // this.node.destroy() this.isCanTouch = true this.node.getChildByName("maskNode").active = false }) .start() //this.node.active = false } onBtnTiaoZhuan() { let customTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let taskId = customTaskInfo.Id let config = TaskManager.getTaskConfigById(taskId) // if(config.TaskTiaoZhuanFunc != ''){ // if(GameEnterClick[config.TaskTiaoZhuanFunc]){ // GameEnterClick[config.TaskTiaoZhuanFunc]() // } // } } // update (dt) {} }