LoadingUIController.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import FireEventObserver from '../framework/FireEventObserver';
  2. import PreloadManager from '../common/PreloadManager';
  3. import AudioControlManager from '../common/AudioControlManager';
  4. import Event from '../net/Event';
  5. import LogicUnitManager from '../framework/LogicUnitManager'
  6. import Common from '../common/Common';
  7. cc.Class({
  8. extends: FireEventObserver,
  9. properties: {
  10. progressBar: cc.ProgressBar,
  11. wxLogin:cc.Button,
  12. ykLogin:cc.Button,
  13. zhLogin:cc.Button,
  14. ljLogin:cc.Button,
  15. yk2Login:cc.Button,
  16. loginBtnNode:cc.Node,
  17. loadproNode:cc.Node,
  18. loginBannerNode:cc.Node,
  19. regAndreadNode:cc.Node,
  20. regNode:cc.Node,
  21. readNode:cc.Node,
  22. gotoRegBtn:cc.Node,
  23. },
  24. onLoad()
  25. {
  26. window['onGameBoot']();
  27. cc.macro.ENABLE_CULLING = false;
  28. this.loginBtnNode.active = false
  29. this.progressBarTarget = 0;
  30. this.scale = 1;
  31. this.initListener();
  32. this.preloadCount = 0;
  33. this.preloadTotal = 5;
  34. this.lum = LogicUnitManager;
  35. this.loginLogic = this.lum.getBehavior('LoginBehavior');
  36. // this.loginLogic.CreateLoginStart();
  37. this.bloaded = true
  38. },
  39. initListener()
  40. {
  41. this.onBehaviorEvent('LoginBehavior',Event.COM_MSG.PRELOAD_DONE,this.onLoaded.bind(this));
  42. this.onBehaviorEvent('LoginBehavior',Event.SOCKET_MSG.OPEN, this.onSocketOpen.bind(this));
  43. },
  44. onSocketOpen(sender,result)
  45. {
  46. this.bloaded = true
  47. },
  48. onLoaded(sender, result)
  49. {
  50. this.preloadCount++;
  51. this.progressBarTarget = this.preloadCount / this.preloadTotal;
  52. console.log("this.preloadCount:"+this.preloadCount+"this.progressBarTarget:"+this.progressBarTarget+"")
  53. if (this.progressBarTarget >= 1 && this.bloaded)
  54. {
  55. this.onResourcesLoaded();
  56. }
  57. },
  58. start()
  59. {
  60. this.preloadManager = new PreloadManager();
  61. this.audioControlManager = new AudioControlManager();
  62. //加载动画和预制体
  63. this.preloadManager.run();
  64. //加载音频
  65. this.audioControlManager.run();
  66. var self = this;
  67. cc.director.preloadScene("hall", function(){
  68. console.log("preload scene battle");
  69. self.onLoaded();
  70. })
  71. },
  72. onResourcesLoaded()
  73. {
  74. this.loginBtnNode.active = true
  75. this.loadproNode.active = false
  76. },
  77. update(dt)
  78. {
  79. if (this.progressBar.progress < this.progressBarTarget)
  80. {
  81. this.progressBar.progress += dt*this.scale
  82. }
  83. if (this.progressBarTarget >= 1 && this.bloaded && this.loginLogic.needShowAuth == false) {
  84. this.onResourcesLoaded();
  85. } else if (this.progressBarTarget >= 5 / 6 && this.bloaded && this.loginLogic.needShowAuth == false) {
  86. this.onResourcesLoaded();
  87. }
  88. },
  89. clickWXLogin(sender)
  90. {
  91. //weixin login
  92. // this.loginLogic.login()
  93. },
  94. clickYKLogin(sender){
  95. //youke login
  96. cc.director.loadScene('hall');
  97. },
  98. clickZHLogin(sender){
  99. //zhang hao login
  100. sender.target.active = false
  101. this.ykLogin.node.active = false
  102. this.loginBannerNode.active = true
  103. this.ljLogin.node.active = true
  104. this.yk2Login.node.active = true
  105. },
  106. clickRegBtn(sender){
  107. this.regAndreadNode.active = true
  108. this.regNode.active = true
  109. },
  110. clickReadYsBtn(sender){
  111. this.regNode.active = false
  112. this.readNode.active = true
  113. },
  114. clickCloseReg(sender){
  115. if (this.regNode.active) {
  116. this.regAndreadNode.active = false
  117. }else{
  118. this.regNode.active = true
  119. this.readNode.active = false
  120. }
  121. },
  122. });