tips_view.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { _decorator, Component, Node, Sprite } from 'cc';
  2. import { scene_tips_data, ui_att_item } from '../../../data/data';
  3. import { gameManager } from '../gameManager';
  4. import { SdkUtil } from '../../sdkUtil';
  5. import { config } from '../../config';
  6. import { statisticsManager } from '../../statisticsManager';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('tips_view')
  9. export class tips_view extends Component {
  10. @property(Node) btn_tips:Node = null;
  11. @property(Node) btn_answer:Node = null;
  12. @property(Node) btn_close:Node = null;
  13. @property(Node) icon:Node = null;
  14. @property(Node) text_view:Node = null;
  15. private mData:scene_tips_data = null;
  16. private IsShowFindRuleTips:boolean = false;
  17. private IsShowSecondLevel:boolean = false;
  18. private isLookTipsVideo:boolean = false;
  19. private isLookAnswerVideo:boolean = false;
  20. public initView(data:scene_tips_data){
  21. this.mData = data;
  22. this.btn_tips.off(Node.EventType.TOUCH_END)
  23. this.btn_answer.off(Node.EventType.TOUCH_END)
  24. this.btn_close.off(Node.EventType.TOUCH_END)
  25. this.isLookTipsVideo = false;
  26. this.isLookAnswerVideo = false;
  27. this.btn_tips.on(Node.EventType.TOUCH_END,()=>{
  28. if(this.isLookTipsVideo){
  29. this.showTips()
  30. }else{
  31. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  32. if(res.isEnded){
  33. this.isLookTipsVideo = true;
  34. this.showTips()
  35. }
  36. // 统计-激励视频广告
  37. let level_id = gameManager.Singleton.getLevelData().id
  38. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI)
  39. statisticsManager.request_collect_rewardVideoData(collect_data)
  40. })
  41. }
  42. gameManager.Singleton.sys_click_button_music()
  43. })
  44. this.btn_answer.on(Node.EventType.TOUCH_END,()=>{
  45. if( this.isLookAnswerVideo){
  46. this.showAnswer()
  47. }else{
  48. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  49. if(res.isEnded){
  50. this.isLookAnswerVideo = true;
  51. this.showAnswer()
  52. }
  53. // 统计-激励视频广告
  54. let level_id = gameManager.Singleton.getLevelData().id
  55. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_DA_AN)
  56. statisticsManager.request_collect_rewardVideoData(collect_data)
  57. })
  58. }
  59. gameManager.Singleton.sys_click_button_music()
  60. })
  61. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  62. if(this.IsShowFindRuleTips==true) {
  63. this.IsShowFindRuleTips = false
  64. this.close()
  65. } else {
  66. if(this.IsShowSecondLevel==true) {
  67. this.show()
  68. this.IsShowSecondLevel = false
  69. } else {
  70. this.close()
  71. }
  72. }
  73. gameManager.Singleton.sys_click_button_music()
  74. })
  75. this.text_view.active = false;
  76. }
  77. show(){
  78. this.text_view.active = false;
  79. this.btn_tips.active = true;
  80. if(this.isLookTipsVideo) {
  81. this.btn_answer.active = true;
  82. } else {
  83. this.btn_answer.active = false;
  84. }
  85. this.node.active = true;
  86. }
  87. close(){
  88. this.node.active = false;
  89. }
  90. showTips(){
  91. this.IsShowSecondLevel = true
  92. this.text_view.active = true;
  93. this.btn_answer.active = false;
  94. this.btn_tips.active = false;
  95. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_tips.res)
  96. }
  97. showAnswer(){
  98. this.IsShowSecondLevel = true
  99. this.text_view.active = true;
  100. this.btn_answer.active = false;
  101. this.btn_tips.active = false;
  102. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_answer.res)
  103. }
  104. public showFindRuleTips(data:ui_att_item){
  105. this.IsShowFindRuleTips = true;
  106. this.node.active = true;
  107. this.text_view.active = true;
  108. this.btn_answer.active = false;
  109. this.btn_tips.active = false;
  110. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,data.res)
  111. }
  112. }