GamesHallController.js 10 KB

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