ui_manifestations.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.mData = data;
  21. if(this.mData.tip_type===config.zhao_xi_jie_tip_type.select_tips){
  22. this.tip_type_single.active = true;
  23. this.btn_single_click_hide_tip.active = false;
  24. this.btn_single_click_hide_tip.on(Node.EventType.TOUCH_END,()=>{
  25. this.btn_single_click_hide_tip.active = false;
  26. this.tip_type_single.getComponent(tip_type_single).hideTipBtn()
  27. })
  28. this.tip_type_all.active = false;
  29. this.tip_type_single.getComponent(tip_type_single).initView(data,this.onItemClick.bind(this),this.onItemTips.bind(this))
  30. }else{
  31. this.tip_type_all.active = true;
  32. this.tip_type_single.active = false;
  33. this.tip_type_all.getComponent(tip_type_all).initView(data,this.onShowTips.bind(this))
  34. }
  35. ClientEvent.on(config.EventRun.SHOW_ZHAO_BU_TONG_FINISH_STATUS,this.on_zhao_bu_tong_finish.bind(this),this)
  36. }
  37. on_zhao_bu_tong_finish(widget:zhao_xi_jie_item_data){
  38. if(this.mData.tip_type===config.zhao_xi_jie_tip_type.select_tips){
  39. this.tip_type_single.getComponent(tip_type_single).showFinishIcon(widget.widget_id)
  40. }else{
  41. this.tip_type_all.getComponent(tip_type_all).showFinishIcon(widget.widget_id)
  42. }
  43. }
  44. onItemClick(item:shouji_item){
  45. this.btn_single_click_hide_tip.active = true;
  46. let isFindAnswer = item.getIsShowTipIcon()
  47. this.tip_type_single.getComponent(tip_type_single).changeBtnTipSpriteFrame(isFindAnswer)
  48. }
  49. public onItemTips(data:zhao_xi_jie_item_data){
  50. if(this.tipsMap.get(data.tips_res)){
  51. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  52. }else{
  53. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  54. if(res.isEnded){
  55. this.tipsMap.set(data.tips_res,true)
  56. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  57. }
  58. // 统计-激励视频广告
  59. let level_id = gameManager.Singleton.getLevelData().id
  60. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI)
  61. statisticsManager.request_collect_rewardVideoData(collect_data)
  62. })
  63. }
  64. }
  65. public onShowTips(){
  66. gameManager.Singleton.showTips()
  67. }
  68. }