tips_view.ts 4.9 KB

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