GamesHallController.js 9.7 KB

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