LoadingUIController.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. self.onLoaded();
  67. },
  68. onResourcesLoaded()
  69. {
  70. this.loginBtnNode.active = true
  71. this.loadproNode.active = false
  72. },
  73. update(dt)
  74. {
  75. if (this.progressBar.progress < this.progressBarTarget)
  76. {
  77. this.progressBar.progress += dt*this.scale
  78. }
  79. if (this.progressBarTarget >= 1 && this.bloaded && this.loginLogic.needShowAuth == false) {
  80. this.onResourcesLoaded();
  81. } else if (this.progressBarTarget >= 5 / 6 && this.bloaded && this.loginLogic.needShowAuth == false) {
  82. this.onResourcesLoaded();
  83. }
  84. },
  85. clickWXLogin(sender)
  86. {
  87. //weixin login
  88. // this.loginLogic.login()
  89. },
  90. clickYKLogin(sender){
  91. //youke login
  92. },
  93. clickZHLogin(sender){
  94. //zhang hao login
  95. sender.target.active = false
  96. this.ykLogin.node.active = false
  97. this.loginBannerNode.active = true
  98. this.ljLogin.node.active = true
  99. this.yk2Login.node.active = true
  100. },
  101. clickRegBtn(sender){
  102. this.regAndreadNode.active = true
  103. this.regNode.active = true
  104. },
  105. clickReadYsBtn(sender){
  106. this.regNode.active = false
  107. this.readNode.active = true
  108. },
  109. clickCloseReg(sender){
  110. if (this.regNode.active) {
  111. this.regAndreadNode.active = false
  112. }else{
  113. this.regNode.active = true
  114. this.readNode.active = false
  115. }
  116. },
  117. });