import { _decorator, Component, Label, Node, Animation } from 'cc'; import { base_ui } from '../fw/base_ui'; import { userDataManager } from '../manager/userDataManager'; import { tools } from '../tools'; import { SdkUtil } from '../sdkUtil'; import { config } from '../config'; const { ccclass, property } = _decorator; @ccclass('unLock_view') export class unLock_view extends base_ui { @property(Node) btn_close:Node = null @property(Node) btn_look_video:Node = null @property(Node) lab_look_video:Node = null @property(Node) lab_des:Node = null private m_cur_count:number = 0 private m_max_count:number = 3 private m_lookVideo_finish_cb = null start() { this.onButtonListen(this.btn_close, ()=>{ this.stopBtnLookVideoAni() this.closeSelf() }) this.onButtonListen(this.btn_look_video, this.onLookVideo.bind(this)) this.playBtnLookVideoAni() } initView(lookVideo_finish_cb) { this.m_lookVideo_finish_cb = lookVideo_finish_cb this.m_cur_count = userDataManager.getUserFreeAdsData().look_video_count let sys_config = tools.sys_config this.m_max_count = sys_config.free_ads_number let time = 0 if(sys_config.free_game_time >0) { time = sys_config.free_game_time / 3600 } if(time<1) { time = parseFloat(time.toFixed(1)) } // console.log('time=',time) this.lab_look_video.getComponent(Label).string = '看视频' + this.m_cur_count + '/' + this.m_max_count this.lab_des.getComponent(Label).string = '观看' + this.m_max_count + '次视频,获取' + time + '小时无限挑战机会' } private onLookVideo() { if(this.m_cur_count>=this.m_max_count) { return } let ad_id = SdkUtil.getAdId(config.ADS_TYPE.GAME_INFINITE_DEGREE_VIDEO) SdkUtil.showVideoAd(ad_id,(res)=>{ if(res.isEnded){ this.m_cur_count++ this.lab_look_video.getComponent(Label).string = '看视频' + this.m_cur_count + '/' + this.m_max_count let free_ads_data = userDataManager.getUserFreeAdsData() if(this.m_cur_count