controller.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. console.log('zh:controller.js initAdForPage END')
  50. },
  51. lateStart() {
  52. if (this.social.node.active) {
  53. this.social.closeBannerAdv()
  54. }
  55. this.illustrative.getComponent('illustrative').init(this)
  56. this.startPage.bannerNode.scale = 1
  57. this.pageManager.onOpenPage(0)
  58. },
  59. onGameStartButton() {
  60. // TODO: 增加一个动画
  61. if (this.social.node.active) {
  62. this.social.openBannerAdv()
  63. }
  64. this.startPage.showAnimation().then(() => {
  65. this.gameStart()
  66. })
  67. },
  68. gameStart() {
  69. this.pageManager.onOpenPage(1)
  70. this.game.gameStart()
  71. },
  72. closeRank() {
  73. this.totalRank.active = false
  74. this.navNode.active = true
  75. if (this.social.node.active) {
  76. this.social.closeRank()
  77. }
  78. },
  79. openRank() {
  80. this.totalRank.active = true
  81. this.navNode.active = false
  82. if (this.social.node.active) {
  83. this.social.showRank()
  84. }
  85. },
  86. openGroupRank() {
  87. this.groupRank.active = true
  88. if (this.social.node.active) {
  89. this.social.showGroupRank()
  90. this.pageManager.addPage(6)
  91. }
  92. },
  93. closeGroupRank() {
  94. this.groupRank.active = false
  95. this.navNode.active = true
  96. if (this.social.node.active) {
  97. this.social.closeGroupRank()
  98. this.pageManager.removePage(6)
  99. }
  100. },
  101. openPictorial() {
  102. //ZH测试专用显示AD
  103. if (2 > 3) {
  104. setTimeout(() => {
  105. if (cc.sys.os === cc.sys.OS_ANDROID) {
  106. if (ATRewardedVideoSDK.hasAdReady(AAJS2.getPlacementID())) {
  107. console.log('zh:AD ready for controller.js')
  108. ATRewardedVideoSDK.showAd(AAJS2.getPlacementID());
  109. } else {
  110. console.log('zh:AD not ready for controller.js')
  111. }
  112. }
  113. }, 300)
  114. }
  115. this.illustrative.active = true
  116. },
  117. closePictorial() {
  118. this.illustrative.active = false
  119. },
  120. openHelpPage() {
  121. this.helpPage.active = true
  122. },
  123. closeHelpPage() {
  124. this.helpPage.active = false
  125. }
  126. });