GamesHallController.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. nvren:cc.Node,
  24. hallsBtns:cc.Node,
  25. dzjjHall:cc.Node,
  26. carsHall:cc.Node,
  27. sportsHall:cc.Node,
  28. dzyyHall:cc.Node,
  29. buyuHall:cc.Node,
  30. },
  31. onLoad()
  32. {
  33. // window['onGameBoot']();
  34. // cc.macro.ENABLE_CULLING = false;
  35. // this.loginBtnNode.active = false
  36. // this.progressBarTarget = 0;
  37. // this.scale = 1;
  38. // this.initListener();
  39. // this.preloadCount = 0;
  40. // this.preloadTotal = 5;
  41. // this.lum = LogicUnitManager;
  42. // this.loginLogic = this.lum.getBehavior('LoginBehavior');
  43. // // this.loginLogic.CreateLoginStart();
  44. // this.bloaded = true
  45. // this.node.Opacity=0;
  46. // this.node.runAction(cc.fadeIn(1.0));
  47. this.dzjjHall.active = false
  48. this.carsHall.active = false
  49. this.sportsHall.active = false
  50. this.dzyyHall.active = false
  51. this.buyuHall.active = false
  52. this.show()
  53. // this.animation = this.nvren.getComponent(cc.Animation);
  54. // this.animation.on('finished', this.onGuideFinished, this);
  55. // this.animation.play('nrcome1');
  56. var self = this
  57. },
  58. onGuideFinished(){
  59. console.log("onGuideFinished--------------------")
  60. this.animation.play('nrcome')
  61. },
  62. initListener()
  63. {
  64. // this.onBehaviorEvent('LoginBehavior',Event.COM_MSG.PRELOAD_DONE,this.onLoaded.bind(this));
  65. // this.onBehaviorEvent('LoginBehavior',Event.SOCKET_MSG.OPEN, this.onSocketOpen.bind(this));
  66. },
  67. onSocketOpen(sender,result)
  68. {
  69. this.bloaded = true
  70. },
  71. onLoaded(sender, result)
  72. {
  73. this.preloadCount++;
  74. this.progressBarTarget = this.preloadCount / this.preloadTotal;
  75. console.log("this.preloadCount:"+this.preloadCount+"this.progressBarTarget:"+this.progressBarTarget+"")
  76. if (this.progressBarTarget >= 1 && this.bloaded)
  77. {
  78. this.onResourcesLoaded();
  79. }
  80. },
  81. start()
  82. {
  83. // this.preloadManager = new PreloadManager();
  84. // this.audioControlManager = new AudioControlManager();
  85. // //加载动画和预制体
  86. // this.preloadManager.run();
  87. // //加载音频
  88. // this.audioControlManager.run();
  89. // var self = this;
  90. // cc.director.preloadScene("hall", function(){
  91. // console.log("preload scene battle");
  92. // self.onLoaded();
  93. // })
  94. },
  95. onResourcesLoaded()
  96. {
  97. this.loginBtnNode.active = true
  98. this.loadproNode.active = false
  99. },
  100. update(dt)
  101. {
  102. // if (this.progressBar.progress < this.progressBarTarget)
  103. // {
  104. // this.progressBar.progress += dt*this.scale
  105. // }
  106. // if (this.progressBarTarget >= 1 && this.bloaded && this.loginLogic.needShowAuth == false) {
  107. // this.onResourcesLoaded();
  108. // } else if (this.progressBarTarget >= 5 / 6 && this.bloaded && this.loginLogic.needShowAuth == false) {
  109. // this.onResourcesLoaded();
  110. // }
  111. },
  112. clickWXLogin(sender)
  113. {
  114. //weixin login
  115. // this.loginLogic.login()
  116. },
  117. clickYKLogin(sender){
  118. //youke login
  119. cc.director.loadScene('hall');
  120. },
  121. clickZHLogin(sender){
  122. //zhang hao login
  123. sender.target.active = false
  124. this.ykLogin.node.active = false
  125. this.loginBannerNode.active = true
  126. this.ljLogin.node.active = true
  127. this.yk2Login.node.active = true
  128. },
  129. clickRegBtn(sender){
  130. this.regAndreadNode.active = true
  131. this.regNode.active = true
  132. },
  133. clickReadYsBtn(sender){
  134. this.regNode.active = false
  135. this.readNode.active = true
  136. },
  137. clickCloseReg(sender){
  138. if (this.regNode.active) {
  139. this.regAndreadNode.active = false
  140. }else{
  141. this.regNode.active = true
  142. this.readNode.active = false
  143. }
  144. },
  145. clickCarGameHall(sender){
  146. this.showingHall = this.carsHall.getComponent('CarsHallController')
  147. this.display()
  148. },
  149. clickDZJJHall(sender){
  150. this.showingHall = this.dzjjHall.getComponent('DzjjHallController')
  151. this.display()
  152. },
  153. clickSportsHall(sender){
  154. this.showingHall = this.sportsHall.getComponent('SportsHallController')
  155. this.display()
  156. },
  157. clickDZYYHall(sender){
  158. this.showingHall = this.dzyyHall.getComponent('DianziYouyiHallController')
  159. this.display()
  160. },
  161. clickBuYuHall(sender){
  162. this.showingHall = this.buyuHall.getComponent('BuyuHallController')
  163. this.display()
  164. },
  165. display(){
  166. var animation = this.hallsBtns.getComponent(cc.Animation);
  167. var hallsGoFinished = function(){
  168. this.showingHall.playShow()
  169. this.hallsBtns._parent._parent.active = false
  170. };
  171. animation.on('finished', hallsGoFinished, this);
  172. animation.play('hallsgo');
  173. this.animation.play('nrgo')
  174. },
  175. clickReturnBtn(){
  176. if (this.showingHall) {
  177. this.showingHall.playEnd(this)
  178. this.showingHall = null
  179. }
  180. },
  181. show(param)
  182. {
  183. this.hallsBtns._parent._parent.active = true
  184. this.animation = this.nvren.getComponent(cc.Animation);
  185. this.hallsBtns.getComponent(cc.Animation).off("finished")
  186. this.hallsBtns.y = 0
  187. this.hallsBtns.x = 0
  188. this.hallsBtns.getComponent(cc.Animation).play('hallscome');
  189. this.animation.on('finished', this.onGuideFinished, this);
  190. this.animation.play('nrcome1');
  191. }
  192. });