import { _decorator, Component, Node, Sprite } from 'cc'; import { scene_tips_data, ui_att_item } from '../../../data/data'; import { gameManager } from '../gameManager'; import { SdkUtil } from '../../sdkUtil'; import { config } from '../../config'; 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; private mData:scene_tips_data = null; private IsShowFindRuleTips: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() } }) } 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() } }) } gameManager.Singleton.sys_click_button_music() }) this.btn_close.on(Node.EventType.TOUCH_END,()=>{ if(!this.btn_answer.active&&!this.IsShowFindRuleTips){ this.show() }else{ this.IsShowFindRuleTips = false; this.close() } gameManager.Singleton.sys_click_button_music() }) this.text_view.active = false; } show(){ this.text_view.active = false; this.btn_answer.active = true; this.btn_tips.active = true; this.node.active = true; } close(){ this.node.active = false; } showTips(){ this.text_view.active = true; this.btn_answer.active = false; this.btn_tips.active = false; this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.mData.tips_tips.res) } showAnswer(){ this.text_view.active = true; this.btn_answer.active = false; this.btn_tips.active = false; this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(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(data.res) } }