AddCountPanel.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import { _decorator, Button, Component, Label, Node, sys } from 'cc';
  2. import { Difficulty, SuperFind } from '../../script/Manager/LocalDataMgr';
  3. import EventMgr from '../../script/Manager/EventMgr';
  4. import { mainscene } from '../../script/mainscene';
  5. import PlatformService from '../../script/Platform/PlatformService';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('AddCountPanel')
  8. export class AddCountPanel extends Component {
  9. @property(Node)
  10. btnClose:Node = null
  11. @property(Label)
  12. labCount:Label = null
  13. @property(Button)
  14. btnAdd5:Button = null
  15. @property(Button)
  16. btnAdd30:Button = null
  17. watchAdvCount:number = 0
  18. start() {
  19. this.btnClose.on(Node.EventType.TOUCH_END,this.close,this)
  20. this.btnAdd5.node.on(Node.EventType.TOUCH_END,this.AddCount5,this)
  21. this.btnAdd30.node.on(Node.EventType.TOUCH_END,this.AddCount30,this)
  22. }
  23. close()
  24. {
  25. this.node.active = false
  26. }
  27. AddCount5()
  28. {
  29. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
  30. mainscene.instance.ge.track(
  31. "ad_show", //追踪事件的名称
  32. {
  33. version: "123",
  34. ad_position: "小熊数量+5",
  35. level_id: SuperFind.superFindData.currentBgKey
  36. } //需要上传的事件属性
  37. );
  38. }
  39. PlatformService.getInstance().platformApi.loadAndShowVideoAd(() => {
  40. // PlatformService.getInstance().platformApi.reportAnalytics("tips", {
  41. // level: this.data.title
  42. // })
  43. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
  44. mainscene.instance.ge.track(
  45. "ad_showend", //追踪事件的名称
  46. {
  47. version: "123",
  48. ad_position: "小熊数量+5",
  49. level_id: SuperFind.superFindData.currentBgKey
  50. } //需要上传的事件属性
  51. );
  52. let count = 5
  53. Difficulty.difficutyData.difficutyCount += count
  54. Difficulty.createOrDeleteOtherScale();
  55. Difficulty.saveDifficutyData();
  56. SuperFind.setTitle()
  57. EventMgr.ins.dispatchEvent("refreshLevelInfo")
  58. this.node.active = false
  59. EventMgr.ins.dispatchEvent("regenerate")
  60. this.btnAdd5.node.active = false
  61. }
  62. })
  63. }
  64. AddCount30()
  65. {
  66. // AudioManager.instance.playBundleAudio("button")
  67. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
  68. mainscene.instance.ge.track(
  69. "ad_show", //追踪事件的名称
  70. {
  71. version: "123",
  72. ad_position: "小熊数量加至30",
  73. level_id: SuperFind.superFindData.currentBgKey
  74. } //需要上传的事件属性
  75. );
  76. }
  77. PlatformService.getInstance().platformApi.loadAndShowVideoAd(() => {
  78. // PlatformService.getInstance().platformApi.reportAnalytics("tips", {
  79. // level: this.data.title
  80. // })
  81. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
  82. mainscene.instance.ge.track(
  83. "ad_showend", //追踪事件的名称
  84. {
  85. version: "123",
  86. ad_position: "小熊数量加至30",
  87. level_id: SuperFind.superFindData.currentBgKey
  88. } //需要上传的事件属性
  89. );
  90. this.watchAdvCount++
  91. if (this.watchAdvCount >= 2) {
  92. let count = 30
  93. Difficulty.difficutyData.difficutyCount += count
  94. if (Difficulty.difficutyData.difficutyCount > 30) {
  95. Difficulty.difficutyData.difficutyCount = 30
  96. }
  97. Difficulty.createOrDeleteOtherScale();
  98. Difficulty.saveDifficutyData();
  99. SuperFind.setTitle()
  100. EventMgr.ins.dispatchEvent("refreshLevelInfo")
  101. this.node.active = false
  102. EventMgr.ins.dispatchEvent("regenerate")
  103. this.btnAdd30.node.active = false
  104. }
  105. this.labCount.string = `${this.watchAdvCount}/${2}`
  106. }
  107. })
  108. }
  109. }