tips_view.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import { _decorator, Component, Node, Sprite, SpriteFrame } 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. @property(SpriteFrame) sf_tips:SpriteFrame;
  16. @property(SpriteFrame) sf_tips_video:SpriteFrame;
  17. @property(SpriteFrame) sf_answer:SpriteFrame;
  18. @property(SpriteFrame) sf_answer_video:SpriteFrame;
  19. private mData:scene_tips_data = null;
  20. private IsShowFindRuleTips:boolean = false;
  21. private IsShowSecondLevel:boolean = false;
  22. private isLookTipsVideo:boolean = false;
  23. private isLookAnswerVideo:boolean = false;
  24. public initView(data:scene_tips_data){
  25. this.mData = data;
  26. this.btn_tips.off(Node.EventType.TOUCH_END)
  27. this.btn_answer.off(Node.EventType.TOUCH_END)
  28. this.btn_close.off(Node.EventType.TOUCH_END)
  29. this.IsShowSecondLevel = false;
  30. this.isLookTipsVideo = false;
  31. this.isLookAnswerVideo = false;
  32. this.btn_tips.on(Node.EventType.TOUCH_END,()=>{
  33. if(this.isLookTipsVideo){
  34. this.showTips()
  35. }else{
  36. let ad_id = SdkUtil.getAdId(config.AD_TYPE.LOOK_TIPS)
  37. SdkUtil.showVideoAd(ad_id,(res)=>{
  38. if(res.isEnded){
  39. this.isLookTipsVideo = true;
  40. this.showTips()
  41. this.updateBtnTipStatus()
  42. }
  43. // 统计-激励视频广告
  44. let level_id = gameManager.Singleton.getLevelData().id
  45. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI)
  46. statisticsManager.request_collect_rewardVideoData(collect_data)
  47. })
  48. }
  49. gameManager.Singleton.sys_click_button_music()
  50. })
  51. this.btn_answer.on(Node.EventType.TOUCH_END,()=>{
  52. if( this.isLookAnswerVideo){
  53. this.showAnswer()
  54. }else{
  55. let ad_id = SdkUtil.getAdId(config.AD_TYPE.ANSWER)
  56. SdkUtil.showVideoAd(ad_id,(res)=>{
  57. if(res.isEnded){
  58. this.isLookAnswerVideo = true;
  59. this.showAnswer()
  60. this.updateBtnAnswerStatus()
  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_DA_AN)
  65. statisticsManager.request_collect_rewardVideoData(collect_data)
  66. })
  67. }
  68. gameManager.Singleton.sys_click_button_music()
  69. })
  70. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  71. if(this.IsShowFindRuleTips==true) {
  72. this.IsShowFindRuleTips = false
  73. this.close()
  74. } else {
  75. if(this.IsShowSecondLevel==true) {
  76. this.show()
  77. this.IsShowSecondLevel = false
  78. } else {
  79. this.close()
  80. }
  81. }
  82. gameManager.Singleton.sys_click_button_music()
  83. })
  84. this.text_view.active = false;
  85. this.updateBtnTipStatus()
  86. this.updateBtnAnswerStatus()
  87. }
  88. private updateBtnTipStatus() {
  89. if(this.isLookTipsVideo) {
  90. this.btn_tips.getComponent(Sprite).spriteFrame = this.sf_tips
  91. } else {
  92. this.btn_tips.getComponent(Sprite).spriteFrame = this.sf_tips_video
  93. }
  94. }
  95. private updateBtnAnswerStatus() {
  96. if(this.isLookTipsVideo) {
  97. this.btn_answer.getComponent(Sprite).spriteFrame = this.sf_answer
  98. } else {
  99. this.btn_answer.getComponent(Sprite).spriteFrame = this.sf_answer_video
  100. }
  101. }
  102. show(){
  103. this.text_view.active = false;
  104. this.btn_tips.active = true;
  105. if(this.isLookTipsVideo) {
  106. this.btn_answer.active = true;
  107. } else {
  108. this.btn_answer.active = false;
  109. }
  110. this.node.active = true;
  111. }
  112. close(){
  113. this.node.active = false;
  114. }
  115. showTips(){
  116. this.IsShowSecondLevel = true
  117. this.text_view.active = true;
  118. this.btn_answer.active = false;
  119. this.btn_tips.active = false;
  120. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_tips.res)
  121. }
  122. showAnswer(){
  123. this.IsShowSecondLevel = true
  124. this.text_view.active = true;
  125. this.btn_answer.active = false;
  126. this.btn_tips.active = false;
  127. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_answer.res)
  128. }
  129. public showFindRuleTips(data:ui_att_item){
  130. this.IsShowFindRuleTips = true;
  131. this.node.active = true;
  132. this.text_view.active = true;
  133. this.btn_answer.active = false;
  134. this.btn_tips.active = false;
  135. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,data.res)
  136. }
  137. }