1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { _decorator, Component, Label, Node } from 'cc';
- import { userDataManager } from '../../manager/userDataManager';
- import { Util } from '../../util';
- const { ccclass, property } = _decorator;
- @ccclass('home_bottom_countdown')
- export class home_bottom_countdown extends Component {
- @property(Node) lab_countdown_time:Node = null
- private seconds:number = 0
- startTime(active_cb) {
- this.seconds = userDataManager.getUserFreeAdsSeconds()
- if(this.seconds<=0) {
- this.unscheduleAllCallbacks()
- this.node.active = false
- if(active_cb){ active_cb(false) }
- return
- }
- this.node.active = true
- if(active_cb){ active_cb(true) }
- this.lab_countdown_time.getComponent(Label).string = Util.formatTimeForSecond(this.seconds)
- this.unscheduleAllCallbacks()
- this.schedule(()=>{
- this.seconds --
- if(this.seconds<=0) {
- let c_free_ads_data = userDataManager.getUserFreeAdsData()
- c_free_ads_data.is_free = false
- c_free_ads_data.look_video_count = 0
- userDataManager.saveUserFreeAdsData()
- this.unscheduleAllCallbacks()
- this.node.active = false
- if(active_cb){ active_cb(false) }
- return
- }
- this.lab_countdown_time.getComponent(Label).string = Util.formatTimeForSecond(this.seconds)
- },1)
- // this.seconds = userDataManager.getUserFreeAdsTime()
- // console.log('seconds=',this.seconds)
- // if(this.seconds==-1) {
- // this.unscheduleAllCallbacks()
- // this.node.active = false
- // if(active_cb){ active_cb(false) }
- // return
- // }
- // this.node.active = true
- // if(active_cb){ active_cb(true) }
- // this.lab_countdown_time.getComponent(Label).string = Util.formatTimeForSecond(this.seconds)
- // this.unscheduleAllCallbacks()
- // this.schedule(()=>{
- // this.seconds --
- // if(this.seconds<=0) {
- // userDataManager.is_free_ads = false
- // userDataManager.saveUserFreeAdsLookVideoCount(0)
- // this.unscheduleAllCallbacks()
- // this.node.active = false
- // if(active_cb){ active_cb(false) }
- // return
- // }
- // this.lab_countdown_time.getComponent(Label).string = Util.formatTimeForSecond(this.seconds)
- // },1)
- }
- }
|