tips_view.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  37. if(res.isEnded){
  38. this.isLookTipsVideo = true;
  39. this.showTips()
  40. this.updateBtnTipStatus()
  41. }
  42. // 统计-激励视频广告
  43. let level_id = gameManager.Singleton.getLevelData().id
  44. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_TI_SHI)
  45. statisticsManager.request_collect_rewardVideoData(collect_data)
  46. })
  47. }
  48. gameManager.Singleton.sys_click_button_music()
  49. })
  50. this.btn_answer.on(Node.EventType.TOUCH_END,()=>{
  51. if( this.isLookAnswerVideo){
  52. this.showAnswer()
  53. }else{
  54. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  55. if(res.isEnded){
  56. this.isLookAnswerVideo = true;
  57. this.showAnswer()
  58. this.updateBtnAnswerStatus()
  59. }
  60. // 统计-激励视频广告
  61. let level_id = gameManager.Singleton.getLevelData().id
  62. let collect_data = statisticsManager.get_collect_data(level_id, res, config.STATISTICS_ACTION_TYPE.CHA_KAN_DA_AN)
  63. statisticsManager.request_collect_rewardVideoData(collect_data)
  64. })
  65. }
  66. gameManager.Singleton.sys_click_button_music()
  67. })
  68. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  69. if(this.IsShowFindRuleTips==true) {
  70. this.IsShowFindRuleTips = false
  71. this.close()
  72. } else {
  73. if(this.IsShowSecondLevel==true) {
  74. this.show()
  75. this.IsShowSecondLevel = false
  76. } else {
  77. this.close()
  78. }
  79. }
  80. gameManager.Singleton.sys_click_button_music()
  81. })
  82. this.text_view.active = false;
  83. this.updateBtnTipStatus()
  84. this.updateBtnAnswerStatus()
  85. }
  86. private updateBtnTipStatus() {
  87. if(this.isLookTipsVideo) {
  88. this.btn_tips.getComponent(Sprite).spriteFrame = this.sf_tips
  89. } else {
  90. this.btn_tips.getComponent(Sprite).spriteFrame = this.sf_tips_video
  91. }
  92. }
  93. private updateBtnAnswerStatus() {
  94. if(this.isLookTipsVideo) {
  95. this.btn_answer.getComponent(Sprite).spriteFrame = this.sf_answer
  96. } else {
  97. this.btn_answer.getComponent(Sprite).spriteFrame = this.sf_answer_video
  98. }
  99. }
  100. show(){
  101. this.text_view.active = false;
  102. this.btn_tips.active = true;
  103. if(this.isLookTipsVideo) {
  104. this.btn_answer.active = true;
  105. } else {
  106. this.btn_answer.active = false;
  107. }
  108. this.node.active = true;
  109. }
  110. close(){
  111. this.node.active = false;
  112. }
  113. showTips(){
  114. this.IsShowSecondLevel = true
  115. this.text_view.active = true;
  116. this.btn_answer.active = false;
  117. this.btn_tips.active = false;
  118. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_tips.res)
  119. }
  120. showAnswer(){
  121. this.IsShowSecondLevel = true
  122. this.text_view.active = true;
  123. this.btn_answer.active = false;
  124. this.btn_tips.active = false;
  125. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,this.mData.tips_answer.res)
  126. }
  127. public showFindRuleTips(data:ui_att_item){
  128. this.IsShowFindRuleTips = true;
  129. this.node.active = true;
  130. this.text_view.active = true;
  131. this.btn_answer.active = false;
  132. this.btn_tips.active = false;
  133. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.icon,data.res)
  134. }
  135. }