FinishLine.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var BarrierSuperClass = require("BarrierSuper");
  2. cc.Class({
  3. extends: BarrierSuperClass,
  4. properties: {
  5. bHasCompared: false,
  6. },
  7. start: function () {
  8. this.finshPlayers = [];
  9. this.GmaeStates = cc.find('Canvas').getComponent('GameStates');
  10. this.GameMode = cc.find('Canvas').getComponent('GameMode');
  11. this.GmaeStates.EnterFinishLinePlayersArray = [];
  12. this.GameMode.bHasAddScore = false;
  13. },
  14. onLoad: function () {
  15. this.finshPlayers = [];
  16. this.GmaeStates = cc.find('Canvas').getComponent('GameStates');
  17. this.GameMode = cc.find('Canvas').getComponent('GameMode');
  18. this.GmaeStates.EnterFinishLinePlayersArray = [];
  19. this.GameMode.bHasAddScore = false;
  20. },
  21. onCollisionEnter: function (other) {
  22. if (other.node.name === 'PlayerCollisionLine') {
  23. // console.log("进入了减速区域?");
  24. if (!this.GameMode.bHasAddScore) {
  25. if (other.node.parent.parent.name == "Hero") {
  26. if(!this.GmaeStates.bServer){
  27. var data = { FunctionName: 'addScore',PlayerName:'Hero'};
  28. this.GameMode.SynchronizationFun(data);
  29. }
  30. else{
  31. this.GameMode.addScore(cc.find('Hero'))
  32. }
  33. var CurrentPlayerNode = other.node.parent.parent;
  34. this.GmaeStates.EnterFinishLinePlayersArray.push(CurrentPlayerNode);
  35. var data = { FunctionName: 'PushPlayerToEnterFinishLinePlayersArray' };
  36. this.GameMode.SynchronizationFun(data);
  37. }
  38. }
  39. }
  40. else if (other.node.name == "PlayerCollisionLine_end") {
  41. var CurrentPlayerNode = other.node.parent.parent;
  42. // cc.log("上面先停止");
  43. var CurrentPlayerScript = CurrentPlayerNode.getComponent('HeroControl');
  44. CurrentPlayerScript.ResetSpeed_noType();
  45. }
  46. },
  47. });