| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- import FireEventObserver from '../framework/FireEventObserver';
- import ViewManager from '../ui/ViewManager';
- import PreloadManager from '../common/PreloadManager';
- import AudioControlManager from '../common/AudioControlManager';
- import Event from '../net/Event';
- import LogicUnitManager from '../framework/LogicUnitManager'
- import Common from '../common/Common';
- // import sql from '../common/autogensqlitebindings_api'
- cc.Class({
- extends: FireEventObserver,
- properties: {
- nvren:cc.Node,
- hallsBtns:cc.Node,
- dzjjHall:cc.Node,
- carsHall:cc.Node,
- sportsHall:cc.Node,
- dzyyHall:cc.Node,
- buyuHall:cc.Node,
- caipiaoHall:cc.Node,
- zhenrenHall:cc.Node,
- webviewNode:cc.Node,
- Gundong:cc.Label,
- GundongMask:cc.Mask,
- Gundong1:cc.Layout,
- GundongMask1:cc.Mask,
- returnNode:cc.Node,
- shareNode:cc.Node,
- listLayoutNode:cc.Node,
- halllist:cc.Node,
- listView:cc.ScrollView,
- tipsLayer:cc.Node,
- hallListBtn:cc.Node,
- shopNode:cc.Node,
- gameHallItem:cc.Prefab,
- },
- onLoad()
- {
- // window['onGameBoot']();
- // cc.macro.ENABLE_CULLING = false;
- // this.loginBtnNode.active = false
- // this.progressBarTarget = 0;
- // this.scale = 1;
- // this.initListener();
- // this.preloadCount = 0;
- // this.preloadTotal = 5;
- // this.lum = LogicUnitManager;
- // this.loginLogic = this.lum.getBehavior('LoginBehavior');
- // // this.loginLogic.CreateLoginStart();
- // this.bloaded = true
- // this.node.Opacity=0;
- // this.node.runAction(cc.fadeIn(1.0));
- this.dzjjHall.active = false
- this.carsHall.active = false
- this.sportsHall.active = false
- this.dzyyHall.active = false
- this.buyuHall.active = false
- this.caipiaoHall.active = false
- this.webviewNode.active = false
- this.returnNode.active =false
- this.shareNode.active =true
- this.hallListBtn.active = false
-
- // this.halllist.active = false
- // this.playShow()
- // this.animation = this.nvren.getComponent(cc.Animation);
-
- // this.animation.on('finished', this.onGuideFinished, this);
- // this.animation.play('nrcome1');
- var self = this
- this.gundongText()
- // this.gundongText2()
- this.dtNum = 0
- this.animation = this.nvren.getComponent(cc.Animation);
-
- this.animation.on('finished', this.onGuideFinished, this);
- this.animation.play('nrcome1');
- // this._db = new sql.SQLiteWrapper();
- // this._dbPath = this._db.initializing("data.db","res","");
- cc.vv.userMgr.getGameList(null,this.OnGetGamelist.bind(this)); //获取游戏列表
- var subhall= [
- [1 , this.caipiaoHall.getComponent('CaiPiaoHallController')],
- [2 , this.carsHall.getComponent('CarsHallController')],
- [3 , this.dzyyHall.getComponent('DianziYouyiHallController')],
- [4 , this.zhenrenHall.getComponent('ZhenrenHallController')],
- [5 , this.dzjjHall.getComponent('DzjjHallController')],
- [6 , this.buyuHall.getComponent('BuyuHallController')],
- // ['7' , this.sportsHall.getComponent('SportsHallController')]
- [7 , this.webviewNode.getComponent('WebviewCtrl')]
- ]
- this.myhallMap = new Map(subhall);
- console.log(this.myhallMap.keys());
- this.setHalllist()
- this.halllist.moved = false
- ViewManager.registerView('tips',this.tipsLayer)
- },
-
- OnGetGamelist(ret){
- if (ret.data.data && ret.data.data.length>0) {
- this.hallsBtns.children.forEach(element => {
- element.destroy()
- });
- var gameitems = ret.data.data
- var xStartPos = 135
- var yStarPos = 350
- var stepX = 300
- gameitems.sort(function (a,b) {
- return a.id - b.id
- })
- for (let index = 0; index < gameitems.length; index++) {
- const data = gameitems[index]
- var gameItem = cc.instantiate(this.gameHallItem)
- gameItem.name = "item"+data.id
- var itemx = xStartPos + index*stepX
- var itemy = yStarPos
- gameItem.getComponent('GameHallItem').setGameData(itemx,itemy,data,this)
- this.hallsBtns.addChild(gameItem)
- }
- this.hallsBtns.width = gameitems.length*(gameItem.width+30)
- this.hallsBtns.height = 600
- }
- },
- onGuideFinished(){
- console.log("onGuideFinished--------------------")
- this.animation.play('nrcome')
- },
- initListener()
- {
- // this.onBehaviorEvent('LoginBehavior',Event.COM_MSG.PRELOAD_DONE,this.onLoaded.bind(this));
- // this.onBehaviorEvent('LoginBehavior',Event.SOCKET_MSG.OPEN, this.onSocketOpen.bind(this));
- },
- onSocketOpen(sender,result)
- {
- this.bloaded = true
- },
- onLoaded(sender, result)
- {
- this.preloadCount++;
- this.progressBarTarget = this.preloadCount / this.preloadTotal;
- console.log("this.preloadCount:"+this.preloadCount+"this.progressBarTarget:"+this.progressBarTarget+"")
- if (this.progressBarTarget >= 1 && this.bloaded)
- {
- this.onResourcesLoaded();
- }
-
- },
- gundongText:function(){
- var self = this;
- setTimeout(function(){
- // var notifyRes = JSON.parse(cc.sys.localStorage.getItem('notify'));
- // var gundongNode = cc.find("Canvas/gundong");
- // if(notifyRes != null){
- // if(gundongNode){
- // gundongNode.active = true;
- // }
- // self.Gundong.string = notifyRes;
- // }else{
- // if(gundongNode){
- // gundongNode.active = false;
- // }
- // }
- var text = self.Gundong;
- var width = self.GundongMask.node.width;
- text.node.runAction(cc.repeatForever(cc.sequence(
- cc.moveTo(text.node.width/width*10,cc.v2(-text.node.width-width/5,text.node.y)),
- cc.callFunc(function(){
- text.node.x = width;
- }))));
- },300);
- },
- gundongText2:function(){
- var self = this;
- setTimeout(function(){
- // var notifyRes = JSON.parse(cc.sys.localStorage.getItem('notify'));
- // var gundongNode = cc.find("Canvas/gundong");
- // if(notifyRes != null){
- // if(gundongNode){
- // gundongNode.active = true;
- // }
- // self.Gundong.string = notifyRes;
- // }else{
- // if(gundongNode){
- // gundongNode.active = false;
- // }
- // }
- var text = self.Gundong1;
- var height = self.GundongMask1.node.height;
- text.node.runAction(cc.repeatForever(cc.sequence(
- cc.moveTo(1,cc.v2(text.node.x,text.node.y+57)),
- cc.callFunc(function(){
- if (text.node.height == Math.abs(text.node.y)+17) {
- text.node.y = 17;
- }
- }))));
- },300);
- },
- start()
- {
- // this.preloadManager = new PreloadManager();
- // this.audioControlManager = new AudioControlManager();
- // //加载动画和预制体
- // this.preloadManager.run();
- // //加载音频
- // this.audioControlManager.run();
- // var self = this;
- // cc.director.preloadScene("hall", function(){
- // console.log("preload scene battle");
- // self.onLoaded();
- // })
- },
- onResourcesLoaded()
- {
- this.loginBtnNode.active = true
- this.loadproNode.active = false
- },
- update(dt)
- {
- this.dtNum += dt
- if (this.dtNum >=2) {
- var text = this.Gundong1;
- // var height = this.GundongMask1.node.height;
- text.node.runAction(cc.sequence(
- cc.moveTo(1,cc.v2(text.node.x,text.node.y+50)),
- cc.callFunc(function(){
- if (text.node.height <= Math.abs(text.node.y)+13) {
- text.node.y = 13;
- }
- })));
- this.dtNum =0
- }
- // console.log("time is:",dt)
- // if (this.progressBar.progress < this.progressBarTarget)
- // {
- // this.progressBar.progress += dt*this.scale
- // }
- // if (this.progressBarTarget >= 1 && this.bloaded && this.loginLogic.needShowAuth == false) {
- // this.onResourcesLoaded();
- // } else if (this.progressBarTarget >= 5 / 6 && this.bloaded && this.loginLogic.needShowAuth == false) {
- // this.onResourcesLoaded();
- // }
-
- },
- clickWXLogin(sender)
- {
- //weixin login
- // this.loginLogic.login()
- },
- clickYKLogin(sender){
- //youke login
- cc.director.loadScene('hall');
- },
- clickZHLogin(sender){
- //zhang hao login
- sender.target.active = false
- this.ykLogin.node.active = false
- this.loginBannerNode.active = true
- this.ljLogin.node.active = true
- this.yk2Login.node.active = true
- },
- clickRegBtn(sender){
- this.regAndreadNode.active = true
- this.regNode.active = true
- },
- clickReadYsBtn(sender){
- this.regNode.active = false
- this.readNode.active = true
-
- },
- clickCloseReg(sender){
- if (this.regNode.active) {
- this.regAndreadNode.active = false
- }else{
- this.regNode.active = true
- this.readNode.active = false
- }
- },
- clickHall(sender,customEventData){
- this.showingHall = this.myhallMap.get(customEventData)
- this.showingHall.parentScene = this
- this.showingHall.initScene(customEventData)
- this.setHalllist(customEventData)
- this.display()
- },
- clickHallList(sender,customEventData){
-
- var nextScene = this.myhallMap.get(Number(customEventData))
- nextScene.initScene(Number(customEventData))
- nextScene.parentScene = this
- this.setHalllist(Number(customEventData))
- if (nextScene) {
- this.showingHall.playEnd(nextScene)
- }
- },
-
- display(){
- if (this.showingHall.SceneLevel == 1) {
- this.setHalllistBtnDisplay(true)
- }
- var animation = this.hallsBtns.getComponent(cc.Animation);
- var hallsGoFinished = function(){
- this.showingHall.playShow(this.setShowingHall)
- this.hallsBtns._parent._parent.active = false
- };
- animation.on('finished', hallsGoFinished, this);
- animation.play('hallsgo');
- this.animation.play('nrgo')
- },
- clickReturnBtn(){
- if (this.showingHall) {
- this.showingHall.playEnd()
- }
- },
- playShow(param)
- {
- this.setHalllistBtnDisplay(false)
- this.hallsBtns._parent._parent.active = true
- this.animation = this.nvren.getComponent(cc.Animation);
- this.hallsBtns.getComponent(cc.Animation).off("finished")
- this.hallsBtns.y = 0
- this.hallsBtns.x = 0
- // this.nvren.x = -180
- this.hallsBtns.getComponent(cc.Animation).play('hallscome');
-
- this.animation.on('finished', this.onGuideFinished, this);
- this.animation.play('nrcome1');
- },
- setShowingHall(Hall){
- this.showingHall = Hall
- this.returnNode.active =Hall!=this
- this.shareNode.active =Hall==this
- if (this.halllist.moved) {
- this.setHalllistDisplay(!this.halllist.moved)
- }
- this.setHalllistBtnDisplay(this.showingHall.SceneLevel ==1 && !this.halllist.moved)
- },
- setHalllistBtnDisplay(display){
- this.hallListBtn.active = display
- },
- onClickedHallListBtn(){
- this.hallListBtn.active = this.halllist.moved
- this.setHalllistDisplay(!this.halllist.moved)
- },
- setHalllistDisplay(display)
- {
- if (this.halllist.moved!=display) {
- var actionTo1 = display?cc.moveBy(0.3, cc.v2(367, 0)):cc.moveBy(0.3, cc.v2(-367, 0));
- this.halllist.runAction(actionTo1)
- this.halllist.moved = display
- }
-
- },
- setHalllist(num){
- this.listLayoutNode.children.forEach(element => {
- element.getChildByName('select').active = false
- element.getChildByName('normal').active = true
- });
- if (num) {
- this.listView.scrollToOffset(cc.v2(0, num<=3?0:(num-1)*70), 1)
- this.listLayoutNode.getChildByName('tiem'+num).getChildByName('select').active = true
- this.listLayoutNode.getChildByName('tiem'+num).getChildByName('normal').active = false
- }
- },
- showTips(sender,mode){
- var tipsLayer = ViewManager.PushView('tips')
- tipsLayer.getComponent('TipsLayerController').setTipsMode(sender,mode)
- },
- shopShow(render,cmd){
- var display = cmd==1?true:false
- this.shopNode.active = display
- this.node.getChildByName('top').getChildByName('shopreturnBtn').active = display
- this.node.getChildByName('top').getChildByName('shoptiitle').active = display
- this.node.getChildByName('content').active = !display
- this.node.getChildByName('bottom').active = !display
- this.node.getChildByName('top').getChildByName('topBanner').active = !display
- this.node.getChildByName('top').getChildByName('notice2').active = !display
- }
- });
|