ui_manifestations.ts 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  55. if(res.isEnded){
  56. data.is_look_video_ads = true
  57. this.updateBtnTipStatus(data)
  58. this.tipsMap.set(data.tips_res,true)
  59. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  60. }
  61. // 统计-激励视频广告
  62. let level_id = gameManager.Singleton.getLevelData().id
  63. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI)
  64. statisticsManager.request_collect_rewardVideoData(collect_data)
  65. })
  66. }
  67. }
  68. private updateBtnTipStatus(data:zhao_xi_jie_item_data) {
  69. this.tip_type_single.getComponent(tip_type_single).updateBtnTipStatus(data)
  70. }
  71. public onShowTips(){
  72. gameManager.Singleton.showTips()
  73. }
  74. }