LeavingPrintLocationLine.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. numberOfCollisions: 0,
  5. },
  6. start() {
  7. //只要是空白区域,直接结束游戏
  8. // console.log('GlobalData.game.playerCurrentZone', GlobalData.game.playerCurrentZone)
  9. if (GlobalData.game.playerCurrentZone == GlobalData.GameManager.EnterZoneName.null) {
  10. //游戏结束
  11. GlobalData.gameMode.GameOver();
  12. }
  13. },
  14. onCollisionEnter: function (other) {
  15. // console.log(other.node.name)
  16. //只有第一个碰撞有效
  17. if (this.numberOfCollisions >= 1)
  18. return;
  19. // console.log(other.node.name)
  20. this.numberOfCollisions++;
  21. GlobalData.game.isMustTouch = true;
  22. // return;
  23. if (other.node.name === 'AccelerationBandNormal')//AccelerationBand
  24. {
  25. GlobalData.gameMode.AddGameSpeed(100);
  26. GlobalData.game.getHeroControl().resetPerfectGrade();//非完美点击,则重置perfectGrade
  27. GlobalData.game.getHeroControl().playAudioByName("ClickNormal");
  28. if (GlobalData.game.currentSpawnSport == 3) {//标枪项目
  29. GlobalData.game.javeCount += 7;
  30. }
  31. else if (GlobalData.game.currentSpawnSport == 1) {//跳远
  32. GlobalData.game.longJumpCount += 0.7;
  33. }
  34. GlobalData.game.getHeroControl().PlayerAnimControl.SpeedChange();
  35. //加分
  36. GlobalData.game.GameScore += 100;
  37. }
  38. else if (other.node.name === 'AccelerationBandPerfect') {
  39. GlobalData.gameMode.AddGameSpeed(300);
  40. // this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.AccelerationBandCenter);
  41. //perfect完美提示
  42. GlobalData.game.getGameUIState().OnPayPerfectAnimation();
  43. GlobalData.game.getHeroControl().addPerfectGradeAndPlay();
  44. if (GlobalData.game.currentSpawnSport == 3) {//标枪项目
  45. GlobalData.game.javeCount += 10.5;
  46. }
  47. else if (GlobalData.game.currentSpawnSport == 1) {//跳远
  48. GlobalData.game.longJumpCount += 0.9;
  49. }
  50. GlobalData.game.getHeroControl().PlayerAnimControl.SpeedChange();
  51. //提示白色速度带
  52. other.node.parent.getChildByName('WhiteAccelerationBandCenter').active = true;
  53. //加分
  54. GlobalData.game.GameScore += 300;
  55. } else if (other.node.name === 'EndNormalLongJumpBand') {//最后一个跳远点,蓝色区域
  56. GlobalData.game.longJumpCount += 0.7;
  57. GlobalData.game.getHeroControl().takeOffDistance = this.node.convertToWorldSpaceAR(cc.Vec2.ZERO).x + 100
  58. - GlobalData.game.getHeroControl().node.convertToWorldSpaceAR(cc.Vec2.ZERO).x;
  59. GlobalData.game.getHeroControl().HeroLongJump();
  60. }
  61. else if (other.node.name === 'EndPerfectfLongJumpBand') {//最后一个跳远点,黄色区域
  62. GlobalData.game.getHeroControl().HeroLongJump();
  63. GlobalData.game.longJumpCount += 0.9;
  64. //提示白色速度带
  65. other.node.parent.getChildByName('WhiteAccelerationBandCenter').active = true;
  66. }
  67. else if (other.node.name === 'NormalHurdleBand') {
  68. //跨栏 加速带 todo
  69. GlobalData.game.getHeroControl().PlayerAnimControl.JumpToHurdle();
  70. var animCtrl = other.node.parent.getChildByName('Railing').getComponent(cc.Animation);
  71. this.scheduleOnce(function() {
  72. animCtrl.play("RailingShake");
  73. }, 0.25);
  74. //加分
  75. GlobalData.game.GameScore += 100;
  76. }
  77. else if (other.node.name === 'PerfectHurdleBand') {
  78. //跨栏 加速带 todo
  79. GlobalData.game.getHeroControl().PlayerAnimControl.JumpToHurdle();
  80. //提示白色速度带
  81. other.node.parent.getChildByName('WhiteAccelerationBandCenter').active = true;
  82. //加分
  83. GlobalData.game.GameScore += 300;
  84. } else if (other.node.name === 'GroundCollision') {
  85. GlobalData.game.isMustTouch = false;
  86. //游戏结束
  87. GlobalData.gameMode.GameOver();
  88. }
  89. },
  90. });