GamesHallController.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. Gundong:cc.Label,
  31. GundongMask:cc.Mask,
  32. Gundong1:cc.Layout,
  33. GundongMask1:cc.Mask,
  34. },
  35. onLoad()
  36. {
  37. // window['onGameBoot']();
  38. // cc.macro.ENABLE_CULLING = false;
  39. // this.loginBtnNode.active = false
  40. // this.progressBarTarget = 0;
  41. // this.scale = 1;
  42. // this.initListener();
  43. // this.preloadCount = 0;
  44. // this.preloadTotal = 5;
  45. // this.lum = LogicUnitManager;
  46. // this.loginLogic = this.lum.getBehavior('LoginBehavior');
  47. // // this.loginLogic.CreateLoginStart();
  48. // this.bloaded = true
  49. // this.node.Opacity=0;
  50. // this.node.runAction(cc.fadeIn(1.0));
  51. this.dzjjHall.active = false
  52. this.carsHall.active = false
  53. this.sportsHall.active = false
  54. this.dzyyHall.active = false
  55. this.buyuHall.active = false
  56. this.playShow()
  57. // this.animation = this.nvren.getComponent(cc.Animation);
  58. // this.animation.on('finished', this.onGuideFinished, this);
  59. // this.animation.play('nrcome1');
  60. var self = this
  61. this.gundongText()
  62. // this.gundongText2()
  63. this.dtNum = 0
  64. },
  65. onGuideFinished(){
  66. console.log("onGuideFinished--------------------")
  67. this.animation.play('nrcome')
  68. },
  69. initListener()
  70. {
  71. // this.onBehaviorEvent('LoginBehavior',Event.COM_MSG.PRELOAD_DONE,this.onLoaded.bind(this));
  72. // this.onBehaviorEvent('LoginBehavior',Event.SOCKET_MSG.OPEN, this.onSocketOpen.bind(this));
  73. },
  74. onSocketOpen(sender,result)
  75. {
  76. this.bloaded = true
  77. },
  78. onLoaded(sender, result)
  79. {
  80. this.preloadCount++;
  81. this.progressBarTarget = this.preloadCount / this.preloadTotal;
  82. console.log("this.preloadCount:"+this.preloadCount+"this.progressBarTarget:"+this.progressBarTarget+"")
  83. if (this.progressBarTarget >= 1 && this.bloaded)
  84. {
  85. this.onResourcesLoaded();
  86. }
  87. },
  88. gundongText:function(){
  89. var self = this;
  90. setTimeout(function(){
  91. // var notifyRes = JSON.parse(cc.sys.localStorage.getItem('notify'));
  92. // var gundongNode = cc.find("Canvas/gundong");
  93. // if(notifyRes != null){
  94. // if(gundongNode){
  95. // gundongNode.active = true;
  96. // }
  97. // self.Gundong.string = notifyRes;
  98. // }else{
  99. // if(gundongNode){
  100. // gundongNode.active = false;
  101. // }
  102. // }
  103. var text = self.Gundong;
  104. var width = self.GundongMask.node.width;
  105. text.node.runAction(cc.repeatForever(cc.sequence(
  106. cc.moveTo(text.node.width/width*10,cc.p(-text.node.width-width/5,text.node.y)),
  107. cc.callFunc(function(){
  108. text.node.x = width;
  109. }))));
  110. },300);
  111. },
  112. gundongText2:function(){
  113. var self = this;
  114. setTimeout(function(){
  115. // var notifyRes = JSON.parse(cc.sys.localStorage.getItem('notify'));
  116. // var gundongNode = cc.find("Canvas/gundong");
  117. // if(notifyRes != null){
  118. // if(gundongNode){
  119. // gundongNode.active = true;
  120. // }
  121. // self.Gundong.string = notifyRes;
  122. // }else{
  123. // if(gundongNode){
  124. // gundongNode.active = false;
  125. // }
  126. // }
  127. var text = self.Gundong1;
  128. var height = self.GundongMask1.node.height;
  129. text.node.runAction(cc.repeatForever(cc.sequence(
  130. cc.moveTo(1,cc.p(text.node.x,text.node.y+57)),
  131. cc.callFunc(function(){
  132. if (text.node.height == Math.abs(text.node.y)+17) {
  133. text.node.y = 17;
  134. }
  135. }))));
  136. },300);
  137. },
  138. start()
  139. {
  140. // this.preloadManager = new PreloadManager();
  141. // this.audioControlManager = new AudioControlManager();
  142. // //加载动画和预制体
  143. // this.preloadManager.run();
  144. // //加载音频
  145. // this.audioControlManager.run();
  146. // var self = this;
  147. // cc.director.preloadScene("hall", function(){
  148. // console.log("preload scene battle");
  149. // self.onLoaded();
  150. // })
  151. },
  152. onResourcesLoaded()
  153. {
  154. this.loginBtnNode.active = true
  155. this.loadproNode.active = false
  156. },
  157. update(dt)
  158. {
  159. this.dtNum += dt
  160. if (this.dtNum >=2) {
  161. var text = this.Gundong1;
  162. // var height = this.GundongMask1.node.height;
  163. text.node.runAction(cc.sequence(
  164. cc.moveTo(1,cc.p(text.node.x,text.node.y+50)),
  165. cc.callFunc(function(){
  166. if (text.node.height <= Math.abs(text.node.y)+13) {
  167. text.node.y = 13;
  168. }
  169. })));
  170. this.dtNum =0
  171. }
  172. console.log("time is:",dt)
  173. // if (this.progressBar.progress < this.progressBarTarget)
  174. // {
  175. // this.progressBar.progress += dt*this.scale
  176. // }
  177. // if (this.progressBarTarget >= 1 && this.bloaded && this.loginLogic.needShowAuth == false) {
  178. // this.onResourcesLoaded();
  179. // } else if (this.progressBarTarget >= 5 / 6 && this.bloaded && this.loginLogic.needShowAuth == false) {
  180. // this.onResourcesLoaded();
  181. // }
  182. },
  183. clickWXLogin(sender)
  184. {
  185. //weixin login
  186. // this.loginLogic.login()
  187. },
  188. clickYKLogin(sender){
  189. //youke login
  190. cc.director.loadScene('hall');
  191. },
  192. clickZHLogin(sender){
  193. //zhang hao login
  194. sender.target.active = false
  195. this.ykLogin.node.active = false
  196. this.loginBannerNode.active = true
  197. this.ljLogin.node.active = true
  198. this.yk2Login.node.active = true
  199. },
  200. clickRegBtn(sender){
  201. this.regAndreadNode.active = true
  202. this.regNode.active = true
  203. },
  204. clickReadYsBtn(sender){
  205. this.regNode.active = false
  206. this.readNode.active = true
  207. },
  208. clickCloseReg(sender){
  209. if (this.regNode.active) {
  210. this.regAndreadNode.active = false
  211. }else{
  212. this.regNode.active = true
  213. this.readNode.active = false
  214. }
  215. },
  216. clickCarGameHall(sender){
  217. this.showingHall = this.carsHall.getComponent('CarsHallController')
  218. this.display()
  219. },
  220. clickDZJJHall(sender){
  221. this.showingHall = this.dzjjHall.getComponent('DzjjHallController')
  222. this.display()
  223. },
  224. clickSportsHall(sender){
  225. this.showingHall = this.sportsHall.getComponent('SportsHallController')
  226. this.display()
  227. },
  228. clickDZYYHall(sender){
  229. this.showingHall = this.dzyyHall.getComponent('DianziYouyiHallController')
  230. this.display()
  231. },
  232. clickBuYuHall(sender){
  233. this.showingHall = this.buyuHall.getComponent('BuyuHallController')
  234. this.display()
  235. },
  236. display(){
  237. var animation = this.hallsBtns.getComponent(cc.Animation);
  238. var hallsGoFinished = function(){
  239. this.showingHall.playShow(this)
  240. this.hallsBtns._parent._parent.active = false
  241. };
  242. animation.on('finished', hallsGoFinished, this);
  243. animation.play('hallsgo');
  244. this.animation.play('nrgo')
  245. },
  246. clickReturnBtn(){
  247. if (this.showingHall) {
  248. this.showingHall.playEnd(true)
  249. }
  250. },
  251. playShow(param)
  252. {
  253. this.hallsBtns._parent._parent.active = true
  254. this.animation = this.nvren.getComponent(cc.Animation);
  255. this.hallsBtns.getComponent(cc.Animation).off("finished")
  256. this.hallsBtns.y = 0
  257. this.hallsBtns.x = 0
  258. this.hallsBtns.getComponent(cc.Animation).play('hallscome');
  259. this.animation.on('finished', this.onGuideFinished, this);
  260. this.animation.play('nrcome1');
  261. },
  262. setShowingHall(Hall){
  263. this.showingHall = Hall==this?null:Hall
  264. }
  265. });