| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- var BarrierSuperClass = require("BarrierSuper");
- cc.Class({
- extends: BarrierSuperClass,
- properties: {
- bHasCompared: false,
- },
- start: function () {
- this.finshPlayers = [];
- this.GmaeStates = cc.find('Canvas').getComponent('GameStates');
- this.GameMode = cc.find('Canvas').getComponent('GameMode');
- this.GmaeStates.EnterFinishLinePlayersArray = [];
- this.GameMode.bHasAddScore = false;
- },
- onLoad: function () {
- this.finshPlayers = [];
- this.GmaeStates = cc.find('Canvas').getComponent('GameStates');
- this.GameMode = cc.find('Canvas').getComponent('GameMode');
- this.GmaeStates.EnterFinishLinePlayersArray = [];
- this.GameMode.bHasAddScore = false;
- },
- onCollisionEnter: function (other) {
- if (other.node.name === 'PlayerCollisionLine') {
- // console.log("进入了减速区域?");
- if (!this.GameMode.bHasAddScore) {
- if (other.node.parent.parent.name == "Hero") {
- if(!this.GmaeStates.bServer){
- var data = { FunctionName: 'addScore',PlayerName:'Hero'};
- this.GameMode.SynchronizationFun(data);
- }
- else{
- this.GameMode.addScore(cc.find('Hero'))
- }
- var CurrentPlayerNode = other.node.parent.parent;
- this.GmaeStates.EnterFinishLinePlayersArray.push(CurrentPlayerNode);
- var data = { FunctionName: 'PushPlayerToEnterFinishLinePlayersArray' };
- this.GameMode.SynchronizationFun(data);
- }
- }
- }
- else if (other.node.name == "PlayerCollisionLine_end") {
- var CurrentPlayerNode = other.node.parent.parent;
- // cc.log("上面先停止");
- var CurrentPlayerScript = CurrentPlayerNode.getComponent('HeroControl');
- CurrentPlayerScript.ResetSpeed_noType();
- }
- },
- });
|