GamesHallController.js 11 KB

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