GamesHallController.js 12 KB

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