123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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.IsShowSecondLevel = false;
- this.isLookTipsVideo = false;
- this.isLookAnswerVideo = false;
-
- this.btn_tips.on(Node.EventType.TOUCH_END,()=>{
- if(this.isLookTipsVideo){
- this.showTips()
- }else{
- let ad_id = SdkUtil.getAdId(config.AD_TYPE.LOOK_TIPS)
- SdkUtil.showVideoAd(ad_id,(res)=>{
- if(res.isEnded){
- this.isLookTipsVideo = true;
- this.showTips()
- this.updateBtnTipStatus()
- }
- // 统计-激励视频广告
- let level_id = gameManager.Singleton.getLevelData().id
- let collect_data = statisticsManager.get_collect_ads_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{
- let ad_id = SdkUtil.getAdId(config.AD_TYPE.ANSWER)
- SdkUtil.showVideoAd(ad_id,(res)=>{
- if(res.isEnded){
- this.isLookAnswerVideo = true;
- this.showAnswer()
- this.updateBtnAnswerStatus()
- }
- // 统计-激励视频广告
- let level_id = gameManager.Singleton.getLevelData().id
- let collect_data = statisticsManager.get_collect_ads_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;
- this.updateBtnTipStatus()
- this.updateBtnAnswerStatus()
- }
- private updateBtnTipStatus() {
- if(this.isLookTipsVideo) {
- this.btn_tips.getComponent(Sprite).spriteFrame = this.sf_tips
- } else {
- this.btn_tips.getComponent(Sprite).spriteFrame = this.sf_tips_video
- }
- }
-
- private updateBtnAnswerStatus() {
- if(this.isLookTipsVideo) {
- this.btn_answer.getComponent(Sprite).spriteFrame = this.sf_answer
- } else {
- this.btn_answer.getComponent(Sprite).spriteFrame = this.sf_answer_video
- }
- }
- 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)
- }
- }
|