GamesHallController.js 12 KB

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