controller.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //电子邮件puhalskijsemen@gmail.com
  2. //源码网站 开vpn全局模式打开 http://web3incubators.com/
  3. //电报https://t.me/gamecode999
  4. //网页客服 http://web3incubators.com/kefu.html
  5. /**
  6. * @author heyuchang
  7. * @file 主控制器
  8. */
  9. import ATSDK from "./AnyThinkAds/ATJSSDK";
  10. import ATRewardedVideoSDK from "./AnyThinkAds/ATRewardedVideoJSSDK";
  11. import AAJS2 from "./ATAndroidJS2";
  12. import AESUtil from "./AESUtil"
  13. cc.Class({
  14. extends: cc.Component,
  15. properties: {
  16. musicManager: require('musicManager'), //音乐控制组件
  17. game: require('game'), //主游戏控制器
  18. pageManager: require('pageManager'), //页面控制器
  19. social: require('social'), //排行榜、广告控制器
  20. config: cc.JsonAsset,
  21. gameData: cc.JsonAsset,
  22. scoreMgr: require('score'), //分数 特效控制
  23. totalRank: cc.Node,
  24. groupRank: cc.Node,
  25. startPage: require('startPage'),
  26. navNode: cc.Node,
  27. illustrative: cc.Node,
  28. helpPage: cc.Node,
  29. },
  30. start() {
  31. console.log('zh:controller 00000000000000')
  32. this.totalRank.active = false
  33. this.illustrative.active = false
  34. this.game.init(this)
  35. if (this.social.node.active) {
  36. this.social.init(this)
  37. }
  38. this.musicManager.init()
  39. this.lateStart()
  40. this.initAdForPage()
  41. },
  42. initAdForPage() {
  43. console.log('zh:controller.js initAdForPage start')
  44. let deviceId = AAJS2.getDeviceUserId();
  45. console.log("zh:checkstatus:", ATRewardedVideoSDK.checkAdStatus(AAJS2.getPlacementID()));
  46. var setting = {};
  47. setting[ATRewardedVideoSDK.userIdKey] = deviceId;
  48. ATRewardedVideoSDK.loadRewardedVideo(AAJS2.getPlacementID(), setting);
  49. },
  50. lateStart() {
  51. if (this.social.node.active) {
  52. this.social.closeBannerAdv()
  53. }
  54. this.illustrative.getComponent('illustrative').init(this)
  55. this.startPage.bannerNode.scale = 1
  56. this.pageManager.onOpenPage(0)
  57. },
  58. onGameStartButton() {
  59. // TODO: 增加一个动画
  60. if (this.social.node.active) {
  61. this.social.openBannerAdv()
  62. }
  63. this.startPage.showAnimation().then(() => {
  64. this.gameStart()
  65. })
  66. },
  67. gameStart() {
  68. this.pageManager.onOpenPage(1)
  69. this.game.gameStart()
  70. },
  71. closeRank() {
  72. this.totalRank.active = false
  73. this.navNode.active = true
  74. if (this.social.node.active) {
  75. this.social.closeRank()
  76. }
  77. },
  78. openRank() {
  79. this.totalRank.active = true
  80. this.navNode.active = false
  81. if (this.social.node.active) {
  82. this.social.showRank()
  83. }
  84. },
  85. openGroupRank() {
  86. this.groupRank.active = true
  87. if (this.social.node.active) {
  88. this.social.showGroupRank()
  89. this.pageManager.addPage(6)
  90. }
  91. },
  92. closeGroupRank() {
  93. this.groupRank.active = false
  94. this.navNode.active = true
  95. if (this.social.node.active) {
  96. this.social.closeGroupRank()
  97. this.pageManager.removePage(6)
  98. }
  99. },
  100. openPictorial() {
  101. //ZH测试显示AD
  102. if (2 > 3) {
  103. setTimeout(() => {
  104. if (cc.sys.os === cc.sys.OS_ANDROID) {
  105. if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementID())) {
  106. console.log('zh:AD ready for controller.js')
  107. ATRewardedVideoSDK.showAd(AAJS2.getPlacementID());
  108. } else {
  109. console.log('zh:AD not ready for controller.js')
  110. }
  111. }
  112. }, 300)
  113. }
  114. this.illustrative.active = true
  115. },
  116. closePictorial() {
  117. this.illustrative.active = false
  118. },
  119. openHelpPage() {
  120. this.helpPage.active = true
  121. },
  122. closeHelpPage() {
  123. this.helpPage.active = false
  124. }
  125. });