tips_view.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. const { ccclass, property } = _decorator;
  7. @ccclass('tips_view')
  8. export class tips_view extends Component {
  9. @property(Node) btn_tips:Node = null;
  10. @property(Node) btn_answer:Node = null;
  11. @property(Node) btn_close:Node = null;
  12. @property(Node) icon:Node = null;
  13. @property(Node) text_view:Node = null;
  14. private mData:scene_tips_data = null;
  15. private IsShowFindRuleTips:boolean = false;
  16. private isLookTipsVideo:boolean = false;
  17. private isLookAnswerVideo:boolean = false;
  18. public initView(data:scene_tips_data){
  19. this.mData = data;
  20. this.btn_tips.off(Node.EventType.TOUCH_END)
  21. this.btn_answer.off(Node.EventType.TOUCH_END)
  22. this.btn_close.off(Node.EventType.TOUCH_END)
  23. this.isLookTipsVideo = false;
  24. this.isLookAnswerVideo = false;
  25. this.btn_tips.on(Node.EventType.TOUCH_END,()=>{
  26. if(this.isLookTipsVideo){
  27. this.showTips()
  28. }else{
  29. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  30. if(res.isEnded){
  31. this.isLookTipsVideo = true;
  32. this.showTips()
  33. }
  34. })
  35. }
  36. gameManager.Singleton.sys_click_button_music()
  37. })
  38. this.btn_answer.on(Node.EventType.TOUCH_END,()=>{
  39. if( this.isLookAnswerVideo){
  40. this.showAnswer()
  41. }else{
  42. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  43. if(res.isEnded){
  44. this.isLookAnswerVideo = true;
  45. this.showAnswer()
  46. }
  47. })
  48. }
  49. gameManager.Singleton.sys_click_button_music()
  50. })
  51. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  52. if(!this.btn_answer.active&&!this.IsShowFindRuleTips){
  53. this.show()
  54. }else{
  55. this.IsShowFindRuleTips = false;
  56. this.close()
  57. }
  58. gameManager.Singleton.sys_click_button_music()
  59. })
  60. this.text_view.active = false;
  61. }
  62. show(){
  63. this.text_view.active = false;
  64. this.btn_answer.active = true;
  65. this.btn_tips.active = true;
  66. this.node.active = true;
  67. }
  68. close(){
  69. this.node.active = false;
  70. }
  71. showTips(){
  72. this.text_view.active = true;
  73. this.btn_answer.active = false;
  74. this.btn_tips.active = false;
  75. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.mData.tips_tips.res)
  76. }
  77. showAnswer(){
  78. this.text_view.active = true;
  79. this.btn_answer.active = false;
  80. this.btn_tips.active = false;
  81. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(this.mData.tips_answer.res)
  82. }
  83. public showFindRuleTips(data:ui_att_item){
  84. this.IsShowFindRuleTips = true;
  85. this.node.active = true;
  86. this.text_view.active = true;
  87. this.btn_answer.active = false;
  88. this.btn_tips.active = false;
  89. this.icon.getComponent(Sprite).spriteFrame = gameManager.getCacheSpriteFrameByName(data.res)
  90. }
  91. }