import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc'; import { scene_tips_data, ui_att_item } from '../../../data/data'; import { gameManager } from '../gameManager'; import { SdkUtil } from '../../sdkUtil'; import { config } from '../../config'; import { statisticsManager } from '../../statisticsManager'; const { ccclass, property } = _decorator; @ccclass('tips_view') export class tips_view extends Component { @property(Node) btn_tips:Node = null; @property(Node) btn_answer:Node = null; @property(Node) btn_close:Node = null; @property(Node) icon:Node = null; @property(Node) text_view:Node = null; @property(SpriteFrame) sf_tips:SpriteFrame; @property(SpriteFrame) sf_tips_video:SpriteFrame; @property(SpriteFrame) sf_answer:SpriteFrame; @property(SpriteFrame) sf_answer_video:SpriteFrame; private mData:scene_tips_data = null; private IsShowFindRuleTips:boolean = false; private IsShowSecondLevel:boolean = false; private isLookTipsVideo:boolean = false; private isLookAnswerVideo:boolean = false; public initView(data:scene_tips_data){ this.mData = data; this.btn_tips.off(Node.EventType.TOUCH_END) this.btn_answer.off(Node.EventType.TOUCH_END) this.btn_close.off(Node.EventType.TOUCH_END) this.isLookTipsVideo = false; this.isLookAnswerVideo = false; this.btn_tips.on(Node.EventType.TOUCH_END,()=>{ if(this.isLookTipsVideo){ this.showTips() }else{ SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{ if(res.isEnded){ this.isLookTipsVideo = true; this.showTips() this.btn_tips.getComponent(Sprite).spriteFrame = this.sf_tips } // 统计-激励视频广告 let level_id = gameManager.Singleton.getLevelData().id let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI) statisticsManager.request_collect_rewardVideoData(collect_data) }) } gameManager.Singleton.sys_click_button_music() }) this.btn_answer.on(Node.EventType.TOUCH_END,()=>{ if( this.isLookAnswerVideo){ this.showAnswer() }else{ SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{ if(res.isEnded){ this.isLookAnswerVideo = true; this.showAnswer() this.btn_answer.getComponent(Sprite).spriteFrame = this.sf_answer } // 统计-激励视频广告 let level_id = gameManager.Singleton.getLevelData().id let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_DA_AN) statisticsManager.request_collect_rewardVideoData(collect_data) }) } gameManager.Singleton.sys_click_button_music() }) this.btn_close.on(Node.EventType.TOUCH_END,()=>{ if(this.IsShowFindRuleTips==true) { this.IsShowFindRuleTips = false this.close() } else { if(this.IsShowSecondLevel==true) { this.show() this.IsShowSecondLevel = false } else { this.close() } } gameManager.Singleton.sys_click_button_music() }) this.text_view.active = false; } show(){ this.text_view.active = false; this.btn_tips.active = true; if(this.isLookTipsVideo) { this.btn_answer.active = true; } else { this.btn_answer.active = false; } this.node.active = true; } close(){ this.node.active = false; } showTips(){ this.IsShowSecondLevel = true this.text_view.active = true; this.btn_answer.active = false; this.btn_tips.active = false; this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_tips.res) } showAnswer(){ this.IsShowSecondLevel = true this.text_view.active = true; this.btn_answer.active = false; this.btn_tips.active = false; this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_answer.res) } public showFindRuleTips(data:ui_att_item){ this.IsShowFindRuleTips = true; this.node.active = true; this.text_view.active = true; this.btn_answer.active = false; this.btn_tips.active = false; this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,data.res) } }