ui_manifestations.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { _decorator, Component, Node } from 'cc';
  2. import { zhao_xi_jie_data, zhao_xi_jie_item_data } from '../../../data/data';
  3. import { config } from '../../config';
  4. import { tip_type_single } from './tip_type_single';
  5. import { tip_type_all } from './tip_type_all';
  6. import { shouji_item } from './shouji_item';
  7. import { ClientEvent } from '../../clientEvent';
  8. import { gameManager } from '../gameManager';
  9. import { SdkUtil } from '../../sdkUtil';
  10. import { statisticsManager } from '../../statisticsManager';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('ui_manifestations')
  13. export class ui_manifestations extends Component {
  14. @property(Node) tip_type_single:Node = null;
  15. @property(Node) tip_type_all:Node = null;
  16. @property(Node) btn_single_click_hide_tip:Node = null;
  17. private tipsMap:Map<string,boolean> = new Map;
  18. private mData:zhao_xi_jie_data = null;
  19. public initView(data:zhao_xi_jie_data){
  20. this.tipsMap.clear()
  21. this.mData = data;
  22. if(this.mData.tip_type===config.zhao_xi_jie_tip_type.select_tips){
  23. this.tip_type_single.active = true;
  24. this.btn_single_click_hide_tip.active = false;
  25. this.btn_single_click_hide_tip.on(Node.EventType.TOUCH_END,()=>{
  26. this.btn_single_click_hide_tip.active = false;
  27. this.tip_type_single.getComponent(tip_type_single).hideTipBtn()
  28. })
  29. this.tip_type_all.active = false;
  30. this.tip_type_single.getComponent(tip_type_single).initView(data,this.onItemClick.bind(this),this.onItemTips.bind(this))
  31. }else{
  32. this.tip_type_all.active = true;
  33. this.tip_type_single.active = false;
  34. this.tip_type_all.getComponent(tip_type_all).initView(data,this.onShowTips.bind(this))
  35. }
  36. ClientEvent.on(config.EventRun.SHOW_ZHAO_BU_TONG_FINISH_STATUS,this.on_zhao_bu_tong_finish.bind(this),this)
  37. }
  38. on_zhao_bu_tong_finish(widget:zhao_xi_jie_item_data){
  39. if(this.mData.tip_type===config.zhao_xi_jie_tip_type.select_tips){
  40. widget.is_find_answer = true
  41. this.tip_type_single.getComponent(tip_type_single).showFinishIcon(widget.widget_id)
  42. }else{
  43. this.tip_type_all.getComponent(tip_type_all).showFinishIcon(widget.widget_id)
  44. }
  45. }
  46. onItemClick(item:shouji_item){
  47. this.btn_single_click_hide_tip.active = true;
  48. this.updateBtnTipStatus(item.getData())
  49. }
  50. public onItemTips(data:zhao_xi_jie_item_data){
  51. if(this.tipsMap.get(data.tips_res)){
  52. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  53. }else{
  54. let ad_id = SdkUtil.getAdId(config.AD_TYPE.LOOK_TIPS)
  55. SdkUtil.showVideoAd(ad_id,(res)=>{
  56. if(res.isEnded){
  57. data.is_look_video_ads = true
  58. this.updateBtnTipStatus(data)
  59. this.tipsMap.set(data.tips_res,true)
  60. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  61. }
  62. // 统计-激励视频广告
  63. let level_id = gameManager.Singleton.getLevelData().id
  64. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI)
  65. statisticsManager.request_collect_rewardVideoData(collect_data)
  66. })
  67. }
  68. }
  69. private updateBtnTipStatus(data:zhao_xi_jie_item_data) {
  70. this.tip_type_single.getComponent(tip_type_single).updateBtnTipStatus(data)
  71. }
  72. public onShowTips(){
  73. gameManager.Singleton.showTips()
  74. }
  75. }