GamesHallController.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. },
  33. onLoad()
  34. {
  35. // window['onGameBoot']();
  36. // cc.macro.ENABLE_CULLING = false;
  37. // this.loginBtnNode.active = false
  38. // this.progressBarTarget = 0;
  39. // this.scale = 1;
  40. // this.initListener();
  41. // this.preloadCount = 0;
  42. // this.preloadTotal = 5;
  43. // this.lum = LogicUnitManager;
  44. // this.loginLogic = this.lum.getBehavior('LoginBehavior');
  45. // // this.loginLogic.CreateLoginStart();
  46. // this.bloaded = true
  47. // this.node.Opacity=0;
  48. // this.node.runAction(cc.fadeIn(1.0));
  49. this.dzjjHall.active = false
  50. this.carsHall.active = false
  51. this.sportsHall.active = false
  52. this.dzyyHall.active = false
  53. this.buyuHall.active = false
  54. this.caipiaoHall.active = false
  55. this.returnNode.active =false
  56. this.shareNode.active =true
  57. this.hallListBtn.active = false
  58. // this.halllist.active = false
  59. // this.playShow()
  60. // this.animation = this.nvren.getComponent(cc.Animation);
  61. // this.animation.on('finished', this.onGuideFinished, this);
  62. // this.animation.play('nrcome1');
  63. var self = this
  64. this.gundongText()
  65. // this.gundongText2()
  66. this.dtNum = 0
  67. this.animation = this.nvren.getComponent(cc.Animation);
  68. this.animation.on('finished', this.onGuideFinished, this);
  69. this.animation.play('nrcome1');
  70. // this._db = new sql.SQLiteWrapper();
  71. // this._dbPath = this._db.initializing("data.db","res","");
  72. var subhall= [
  73. ['1' , this.caipiaoHall.getComponent('CaiPiaoHallController')],
  74. ['2' , this.carsHall.getComponent('CarsHallController')],
  75. ['3' , this.dzyyHall.getComponent('DianziYouyiHallController')],
  76. ['4' , this.zhenrenHall.getComponent('ZhenrenHallController')],
  77. ['5' , this.dzjjHall.getComponent('DzjjHallController')],
  78. ['6' , this.buyuHall.getComponent('BuyuHallController')],
  79. ['7' , this.sportsHall.getComponent('SportsHallController')]]
  80. this.myhallMap = new Map(subhall);
  81. console.log(this.myhallMap.keys());
  82. this.setHalllist()
  83. this.halllist.moved = false
  84. ViewManager.registerView('tips',this.tipsLayer)
  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.v2(-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.v2(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.v2(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. clickHall(sender,customEventData){
  238. this.showingHall = this.myhallMap.get(customEventData)
  239. this.showingHall.parentScene = this
  240. this.showingHall.initScene()
  241. this.setHalllist(customEventData)
  242. this.display()
  243. },
  244. clickHallList(sender,customEventData){
  245. var nextScene = this.myhallMap.get(customEventData)
  246. nextScene.initScene()
  247. nextScene.parentScene = this
  248. this.setHalllist(customEventData)
  249. if (nextScene) {
  250. this.showingHall.playEnd(nextScene)
  251. }
  252. },
  253. display(){
  254. if (this.showingHall.SceneLevel == 1) {
  255. this.setHalllistBtnDisplay(true)
  256. }
  257. var animation = this.hallsBtns.getComponent(cc.Animation);
  258. var hallsGoFinished = function(){
  259. this.showingHall.playShow(this.setShowingHall)
  260. this.hallsBtns._parent._parent.active = false
  261. };
  262. animation.on('finished', hallsGoFinished, this);
  263. animation.play('hallsgo');
  264. this.animation.play('nrgo')
  265. },
  266. clickReturnBtn(){
  267. if (this.showingHall) {
  268. this.showingHall.playEnd()
  269. }
  270. },
  271. playShow(param)
  272. {
  273. this.setHalllistBtnDisplay(false)
  274. this.hallsBtns._parent._parent.active = true
  275. this.animation = this.nvren.getComponent(cc.Animation);
  276. this.hallsBtns.getComponent(cc.Animation).off("finished")
  277. this.hallsBtns.y = 0
  278. this.hallsBtns.x = 0
  279. // this.nvren.x = -180
  280. this.hallsBtns.getComponent(cc.Animation).play('hallscome');
  281. this.animation.on('finished', this.onGuideFinished, this);
  282. this.animation.play('nrcome1');
  283. },
  284. setShowingHall(Hall){
  285. this.showingHall = Hall
  286. this.returnNode.active =Hall!=this
  287. this.shareNode.active =Hall==this
  288. if (this.halllist.moved) {
  289. this.setHalllistDisplay(!this.halllist.moved)
  290. }
  291. this.setHalllistBtnDisplay(this.showingHall.SceneLevel ==1 && !this.halllist.moved)
  292. },
  293. setHalllistBtnDisplay(display){
  294. this.hallListBtn.active = display
  295. },
  296. onClickedHallListBtn(){
  297. this.hallListBtn.active = this.halllist.moved
  298. this.setHalllistDisplay(!this.halllist.moved)
  299. },
  300. setHalllistDisplay(display)
  301. {
  302. if (this.halllist.moved!=display) {
  303. var actionTo1 = display?cc.moveBy(0.3, cc.v2(367, 0)):cc.moveBy(0.3, cc.v2(-367, 0));
  304. this.halllist.runAction(actionTo1)
  305. this.halllist.moved = display
  306. }
  307. },
  308. setHalllist(num){
  309. this.listLayoutNode.children.forEach(element => {
  310. element.getChildByName('select').active = false
  311. element.getChildByName('normal').active = true
  312. });
  313. if (num) {
  314. this.listView.scrollToOffset(cc.v2(0, num<=3?0:(num-1)*70), 1)
  315. this.listLayoutNode.getChildByName('tiem'+num).getChildByName('select').active = true
  316. this.listLayoutNode.getChildByName('tiem'+num).getChildByName('normal').active = false
  317. }
  318. },
  319. showTips(sender,mode){
  320. var tipsLayer = ViewManager.PushView('tips')
  321. tipsLayer.getComponent('TipsLayerController').setTipsMode(sender,mode)
  322. }
  323. });