import FireEventObserver from '../framework/FireEventObserver'; 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'; cc.Class({ extends: FireEventObserver, properties: { // progressBar: cc.ProgressBar, // wxLogin:cc.Button, // ykLogin:cc.Button, // zhLogin:cc.Button, // ljLogin:cc.Button, // yk2Login:cc.Button, // loginBtnNode:cc.Node, // loadproNode:cc.Node, // loginBannerNode:cc.Node, // regAndreadNode:cc.Node, // regNode:cc.Node, // readNode:cc.Node, // gotoRegBtn:cc.Node, nvren:cc.Node, hallsBtns:cc.Node, dzjjHall:cc.Node, carsHall:cc.Node, sportsHall:cc.Node, dzyyHall:cc.Node, buyuHall:cc.Node, caipiaoHall:cc.Node, Gundong:cc.Label, GundongMask:cc.Mask, Gundong1:cc.Layout, GundongMask1:cc.Mask, }, 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.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'); // var ss= [['1' , []], // ['2' , [19,20,32]], // ['3' , [5,6,11,14,17,22,27,29]], // ['4' , [2,8,12,16,18]], // ['5' , [3,10,13,25,26,28,30,31]], // ['7' , [1,7,23,24]], // ['9' , [4,9,15,21]]] // var myMap = new Map(ss); // console.log(myMap.keys()); }, 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.p(-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.p(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.p(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 } }, clickCarGameHall(sender){ this.showingHall = this.carsHall.getComponent('CarsHallController') this.display() }, clickDZJJHall(sender){ this.showingHall = this.dzjjHall.getComponent('DzjjHallController') this.display() }, clickSportsHall(sender){ this.showingHall = this.sportsHall.getComponent('SportsHallController') this.display() }, clickDZYYHall(sender){ this.showingHall = this.dzyyHall.getComponent('DianziYouyiHallController') this.display() }, clickBuYuHall(sender){ this.showingHall = this.buyuHall.getComponent('BuyuHallController') this.display() }, clickCaipiaoHall(sender){ this.showingHall = this.caipiaoHall.getComponent('CaiPiaoHallController') this.display() }, display(){ var animation = this.hallsBtns.getComponent(cc.Animation); var hallsGoFinished = function(){ this.showingHall.playShow(this) 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(true) } }, playShow(param) { 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?null:Hall } });