LoadingUIController.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. },
  38. initListener()
  39. {
  40. this.onBehaviorEvent('LoginBehavior',Event.COM_MSG.PRELOAD_DONE,this.onLoaded.bind(this));
  41. this.onBehaviorEvent('LoginBehavior',Event.SOCKET_MSG.OPEN, this.onSocketOpen.bind(this));
  42. },
  43. onSocketOpen(sender,result)
  44. {
  45. this.bloaded = true
  46. },
  47. onLoaded(sender, result)
  48. {
  49. this.preloadCount++;
  50. this.progressBarTarget = this.preloadCount / this.preloadTotal;
  51. console.log("this.preloadCount:"+this.preloadCount+"this.progressBarTarget:"+this.progressBarTarget+"")
  52. if (this.progressBarTarget >= 1 && this.bloaded)
  53. {
  54. this.onResourcesLoaded();
  55. }
  56. },
  57. start()
  58. {
  59. this.preloadManager = new PreloadManager();
  60. this.audioControlManager = new AudioControlManager();
  61. //加载动画和预制体
  62. this.preloadManager.run();
  63. //加载音频
  64. this.audioControlManager.run();
  65. var self = this;
  66. cc.director.preloadScene("hall", function(){
  67. console.log("preload scene battle");
  68. self.onLoaded();
  69. })
  70. },
  71. onResourcesLoaded()
  72. {
  73. this.loginBtnNode.active = true
  74. this.loadproNode.active = false
  75. },
  76. update(dt)
  77. {
  78. if (this.progressBar.progress < this.progressBarTarget)
  79. {
  80. this.progressBar.progress += dt*this.scale
  81. }
  82. if (this.progressBarTarget >= 1 && this.bloaded && this.loginLogic.needShowAuth == false) {
  83. this.onResourcesLoaded();
  84. } else if (this.progressBarTarget >= 5 / 6 && this.bloaded && this.loginLogic.needShowAuth == false) {
  85. this.onResourcesLoaded();
  86. }
  87. },
  88. clickWXLogin(sender)
  89. {
  90. //weixin login
  91. // this.loginLogic.login()
  92. },
  93. clickYKLogin(sender){
  94. //youke login
  95. cc.director.loadScene('hall');
  96. },
  97. clickZHLogin(sender){
  98. //zhang hao login
  99. sender.target.active = false
  100. this.ykLogin.node.active = false
  101. this.loginBannerNode.active = true
  102. this.ljLogin.node.active = true
  103. this.yk2Login.node.active = true
  104. },
  105. clickRegBtn(sender){
  106. this.regAndreadNode.active = true
  107. this.regNode.active = true
  108. },
  109. clickReadYsBtn(sender){
  110. this.regNode.active = false
  111. this.readNode.active = true
  112. },
  113. clickCloseReg(sender){
  114. if (this.regNode.active) {
  115. this.regAndreadNode.active = false
  116. }else{
  117. this.regNode.active = true
  118. this.readNode.active = false
  119. }
  120. },
  121. });