ui_manifestations.ts 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.off(Node.EventType.TOUCH_END)
  26. this.btn_single_click_hide_tip.on(Node.EventType.TOUCH_END,()=>{
  27. this.btn_single_click_hide_tip.active = false;
  28. this.tip_type_single.getComponent(tip_type_single).hideTipBtn()
  29. })
  30. this.tip_type_all.active = false;
  31. this.tip_type_single.getComponent(tip_type_single).initView(data,this.onItemClick.bind(this),this.onItemTips.bind(this))
  32. }else{
  33. this.tip_type_all.active = true;
  34. this.tip_type_single.active = false;
  35. this.tip_type_all.getComponent(tip_type_all).initView(data,this.onShowTips.bind(this))
  36. }
  37. ClientEvent.on(config.EventRun.SHOW_ZHAO_BU_TONG_FINISH_STATUS,this.on_zhao_bu_tong_finish.bind(this),this)
  38. ClientEvent.on(config.EventRun.ON_ZHAO_BU_TONG_ALL_FINISH,this.on_zhao_bu_tong_all_finish.bind(this),this)
  39. }
  40. on_zhao_bu_tong_finish(widget:zhao_xi_jie_item_data){
  41. if(this.mData.tip_type===config.zhao_xi_jie_tip_type.select_tips){
  42. widget.is_find_answer = true
  43. this.tip_type_single.getComponent(tip_type_single).showFinishIcon(widget.widget_id)
  44. }else{
  45. this.tip_type_all.getComponent(tip_type_all).showFinishIcon(widget.widget_id)
  46. }
  47. }
  48. on_zhao_bu_tong_all_finish(data: zhao_xi_jie_data) {
  49. this.node.active = false
  50. }
  51. onItemClick(item:shouji_item){
  52. this.btn_single_click_hide_tip.active = true;
  53. this.updateBtnTipStatus(item.getData())
  54. }
  55. public onItemTips(data:zhao_xi_jie_item_data){
  56. if(this.tipsMap.get(data.tips_res)){
  57. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  58. }else{
  59. let ad_id = SdkUtil.getAdId(config.AD_TYPE.LOOK_TIPS)
  60. SdkUtil.showVideoAd(ad_id,(res)=>{
  61. if(res.isEnded){
  62. data.is_look_video_ads = true
  63. this.updateBtnTipStatus(data)
  64. this.tipsMap.set(data.tips_res,true)
  65. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  66. }
  67. // 统计-激励视频广告
  68. let level_id = gameManager.Singleton.getLevelData().id
  69. let collect_data = statisticsManager.get_collect_ads_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI)
  70. statisticsManager.request_collect_rewardVideoData(collect_data)
  71. })
  72. }
  73. }
  74. private updateBtnTipStatus(data:zhao_xi_jie_item_data) {
  75. this.tip_type_single.getComponent(tip_type_single).updateBtnTipStatus(data)
  76. }
  77. public onShowTips(){
  78. gameManager.Singleton.showTips()
  79. }
  80. }