StartLine.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const GameStatesStatic = require('GameStates');
  2. const PlayerStateStatic = require('PlayerState');
  3. var BarrierSuperClass = require("BarrierSuper");
  4. cc.Class({
  5. extends: BarrierSuperClass,
  6. properties: {
  7. NumOfCameIn:0,
  8. },
  9. onLoad: function () {
  10. },
  11. onCollisionEnter: function (other) {
  12. // return;
  13. if (other.node.name === 'PlayerCollisionLine')
  14. {
  15. cc.find('Hero').getComponent('HeroControl').StopPlayerAllSchedule();
  16. cc.find('Rivel').getComponent('HeroControl').StopPlayerAllSchedule();
  17. if(this.NumOfCameIn == 0){
  18. this.NumOfCameIn++;
  19. this.ResetPerfectGradeAndAddScore(other);
  20. // cc.log("进了StartLine"+this.NumOfCameIn);
  21. }
  22. // var CurrentPlayerNode = other.node.parent.parent;
  23. // var CurrentPlayerScript = CurrentPlayerNode.getComponent('HeroControl');
  24. // console.log("减速区域结束。");
  25. //停止减速
  26. // CurrentPlayerScript.ResetSpeed_noType_lerp_Stop();
  27. this.scheduleOnce(function() {
  28. this.GameMode = cc.find('Canvas').getComponent('GameMode');
  29. this.GameMode.bHasAddScore = false;
  30. }, 3);
  31. this.OneGameInit();
  32. }
  33. },
  34. ResetPerfectGradeAndAddScore:function(other)//项目开始前重置perfectGrade,及显示比分
  35. {
  36. if (other.node.parent.parent.name == "Hero") {
  37. cc.find('Hero').getComponent('HeroControl').resetPerfectGrade();
  38. }
  39. // var Level = cc.find('Level');
  40. // Level.getComponent('LevelControl').hidePKScore(other.node.parent.parent);
  41. },
  42. GetOtherPlayer:function(CurrentPlayerNode)
  43. {
  44. var OtherPlayerNode = null;
  45. if (CurrentPlayerNode.name == 'Hero') {
  46. OtherPlayerNode = cc.find('Rivel');
  47. }
  48. else
  49. {
  50. OtherPlayerNode = cc.find('Hero');
  51. }
  52. return OtherPlayerNode;
  53. },
  54. OneGameInit:function () {
  55. var Hero = cc.find('Hero');
  56. var HeroControl = Hero.getComponent("HeroControl");
  57. var NodeTouch = cc.find("TouchLayout").getComponent("NodeTouch");
  58. var HeroPlayerState = Hero.getComponent('PlayerState');
  59. var GameStates = cc.find('Canvas').getComponent('GameStates');
  60. GameStates.uploadValue = 0;//重置项目结束时上传的距离值
  61. HeroPlayerState.unscheduleAllCallbacks();
  62. HeroPlayerState.StayInFrontLongAccelerationBand=null;
  63. NodeTouch.TOUCH_END();
  64. NodeTouch.CanCreateYellowArea = false;
  65. HeroControl.PlayerStateScript.BStagger = false;
  66. // HeroPlayerState.unschedule(HeroPlayerState.StayInFrontLongAccelerationBand);
  67. HeroPlayerState.TouchControlEnableTouch = false;
  68. HeroPlayerState.enableTouch = false;
  69. HeroPlayerState.CurrentInZoneType = PlayerStateStatic.ZoneType.None;
  70. }
  71. });