| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- const PlayerState = require('PlayerState');
- //todo 上车没时间解释了
- var BarrierSuperClass = require("BarrierSuper");
- cc.Class({
- extends:BarrierSuperClass,
- properties: {
- inTag1 : false,
- inTag2 : false,
- HAHANum:0,
- bHasCompared:false,
- },
- start: function () {
- this.finshPlayers = [];
- this.bHasCompared = false;
- cc.find('Canvas').getComponent('GameStates').EnterFinishLinePlayersArray = [];
- cc.find('Canvas').getComponent('GameMode').bHasAddScore = false;
- },
- onLoad : function () {
- this.finshPlayers = [];
- this.bHasCompared = false;
- cc.find('Canvas').getComponent('GameStates').EnterFinishLinePlayersArray = [];
- cc.find('Canvas').getComponent('GameMode').bHasAddScore = false;
- },
- onCollisionEnter: function (other)
- {
- if(other.node.name === 'PlayerCollisionLine') {
- if (other.node.parent.parent.name == "Hero") {
- var GameMode = cc.find('Canvas').getComponent('GameMode');
- var GameStates = cc.find('Canvas').getComponent('GameStates');
- //这里是传给服务器判断的值,比如当前玩家的奔跑时间
- // let testDate = new Date();
- // let dateTime = testDate.getTime();//获取当前时间(从1970.1.1开始的毫秒数)
- // cc.log(dateTime,'当前毫秒数');
- if(GameStates.uploadValue ==0) {
- GameStates.uploadValue = cc.find('Hero').x;
- }
- let inputValue = GameStates.uploadValue;
- var finishData = { FunctionName: 'callFinishLine'};
- GameMode.SynchronizationFun(finishData);
- let deltaValue = GameMode.bikeDeltaValue;//毫秒
- if(!GameStates.bServer){
- var data = { FunctionName: 'addScore',PlayerName:'Hero',value:inputValue,deltaValue:deltaValue};
- GameMode.SynchronizationFun(data);
-
- // cc.log("--我是client,我发送给server请求加分--javelin当前项目是"+cc.find('Canvas').getComponent('GameStates').strCureentLevel);
- }
- else{
- GameMode.addScore(cc.find('Hero'),inputValue,true,deltaValue)
-
- }
- GameMode.isUploaded = true;
- var Hero = cc.find("Hero");
- var HeroControl = Hero.getComponent("HeroControl");
- HeroControl.downBikeHero("Hero");
- var data = {FunctionName:'downBikeHero',EndPositionX: Hero.x ,isCollision:true,isStop:false};
- GameMode.SynchronizationFun(data);
- }
- }
- },
- // TimerWinOrLose:function(){
- // this.callback = function () {
- // var MyScore = cc.find('Hero').getComponent("PlayerState").TerminalPoint;
- // var RivalScore = cc.find('Rivel').getComponent("PlayerState").TerminalPoint;
- // if (MyScore+RivalScore == 5) {
- // this.unschedule(this.callback);
- // this.PlayWinAudio(MyScore,RivalScore);
- // cc.log("==========55555555=========");
- // }
- // else{
- // cc.log("+++++++++++++++++++MyScore is "+MyScore+" and RivalScore is "+RivalScore);
- // }
- // }
- // this.schedule(this.callback, 1);
- // },
- // PlayWinAudio:function(MyScore,RivalScore){
- // this.scheduleOnce(function() {
- // var NetworkSocket = cc.find('Hero').getComponent("NetworkSocket");
- // MyScore = cc.find('Hero').getComponent("PlayerState").TerminalPoint;
- // RivalScore = cc.find('Rivel').getComponent("PlayerState").TerminalPoint;
- // cc.find('UIControl').getComponent('GameUI').hideTimerMiddlePKScore(MyScore,RivalScore,0);
- // if(MyScore > RivalScore){
- // cc.find('UIControl').getComponent('GameUI').displayUIWin();
- // cc.find('UIControl').getComponent('GameUI').playFireworks();
- // cc.find('Hero').getComponent('HeroControl').playAudioByName("Cheers");
- // var data = {
- // isSelf : 2
- // }
-
- // NetworkSocket.quitGame(data);
- // }else {
- // cc.find('UIControl').getComponent('GameUI').displayUILose();
- // cc.find('Hero').getComponent('HeroControl').playAudioByName("Boos");
- // var data = {
- // isSelf : 1
- // }
-
- // NetworkSocket.quitGame(data);
- // }
- // }, 0.1);
- // // if (!this.inTag1) {
- // // this.inTag1 = true;
- // // } else {
- // // return;
- // // }
- // },
- // javelinmoveRivel : function (data,view,starListener,endListener) {
- // var actionBy = cc.moveBy(data.duration, data.position, data.y);
- // var start = cc.callFunc(function () {
- // if (starListener!=null) {
- // starListener();
- // }
- // }.bind(this), this);
- // var stop = cc.callFunc(function () {
- // if (endListener!=null) {
- // endListener();
- // }
- // }.bind(this), this);
- // var myAction = cc.sequence(start,actionBy,stop);
- // view.runAction(myAction);
- // },
- // javelinmoveHero : function (data,view,starListener,endListener) {
- // var actionBy = cc.moveBy(data.duration, data.position, data.y);
- // var start = cc.callFunc(function () {
- // if (starListener!=null) {
- // starListener();
- // }
- // }.bind(this), this);
- // var stop = cc.callFunc(function () {
- // if (endListener!=null) {
- // endListener();
- // }
- // }.bind(this), this);
- // var myAction = cc.sequence(start,actionBy,stop);
- // view.runAction(myAction);
- // },
- });
|