LeavingPrintLocationLine.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. const PlayerStateStatic = require('PlayerState');
  2. const GameStatesStatic = require('GameStates');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. Index: 0,
  7. BEnterCollision: false,
  8. HeroPro: null,
  9. PlayerStatePro: null,
  10. PlayerControlPro: null,
  11. GameStatePro: null,
  12. },
  13. start() {
  14. this.HeroPro = cc.find("Hero");
  15. this.PlayerStatePro = this.HeroPro.getComponent('PlayerState');
  16. this.PlayerControlPro = this.HeroPro.getComponent('HeroControl');
  17. this.GameStatePro = cc.find('Canvas').getComponent('GameStates');
  18. },
  19. onCollisionEnter: function (other) {
  20. // cc.log("状态 进入",other);
  21. this.BEnterCollision = true;
  22. if (!this.PlayerStatePro.TouchControlEnableTouch) {
  23. // cc.log("状态 禁用点击了之后");
  24. return;
  25. }
  26. if (other.node.name === 'LeftColl' ||
  27. other.node.name === 'LeftAccelerationBand30LeftColl' ||
  28. other.node.name === 'RightAccelerationBand30LeftColl') //AccelerationBand
  29. {
  30. this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.FrontAccelerationBand);
  31. this.PlayerStatePro.BTouchedScreenInTheZone = true;
  32. this.PlayerControlPro.resetPerfectGrade();//非完美点击,则重置perfectGrade
  33. this.PlayerControlPro.playAudioByName("ClickNormal");
  34. // console.log("当前游戏状态 ",other.node.name, this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump);
  35. if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.Javelin) {
  36. // cc.log("我现在是标枪项目 点的 加速", this.GameStatePro.CurrentProgress);
  37. this.PlayerControlPro.javeCount += 7;
  38. } else if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远
  39. this.PlayerControlPro.longJumpCount += 0.7;
  40. // console.log("LeftColl==", cc.find('Hero').getComponent('HeroControl').longJumpCount);
  41. }
  42. }
  43. else if (other.node.name === 'AccelerationBandCenter' ||
  44. other.node.name === 'LeftAccelerationBand30AccelerationBandCenter' ||
  45. other.node.name === 'RightAccelerationBand30AccelerationBandCenter') {
  46. this.PlayerStatePro.BTouchedScreenInTheZone = true;
  47. this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.AccelerationBandCenter);
  48. var Player = this.HeroPro.getChildByName('Player');
  49. Player.getComponent("Charactor").setOnTouchListener(event);
  50. //perfect完美提示
  51. cc.find('UIControl').getComponent('GameUI').hideTimerPerfect(3);
  52. this.PlayerControlPro.addPerfectGradeAndPlay();
  53. // console.log("当前游戏状态 ",other.node.name, this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump);
  54. if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.Javelin) {
  55. // cc.log("我现在是标枪项目 点的 完美加速", this.GameStatePro.CurrentProgress);
  56. this.PlayerControlPro.javeCount += 10.5;
  57. } else if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远
  58. this.PlayerControlPro.longJumpCount += 0.9;
  59. console.log("Left!==", cc.find('Hero').getComponent('HeroControl').longJumpCount);
  60. }
  61. }
  62. else if (other.node.name === 'RightColl' ||
  63. other.node.name === 'LeftAccelerationBand30RightColl' ||
  64. other.node.name === 'RightAccelerationBand30RightColl') {
  65. this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.BehindAccelerationBand);
  66. this.PlayerStatePro.BTouchedScreenInTheZone = true;
  67. this.PlayerControlPro.resetPerfectGrade();//非完美点击,则重置perfectGrade
  68. this.PlayerControlPro.playAudioByName("ClickNormal");
  69. // console.log("当前游戏状态 ",other.node.name, this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump);
  70. if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.Javelin) {
  71. // cc.log("我现在是标枪项目 点的 加速", this.GameStatePro.CurrentProgress);
  72. this.PlayerControlPro.javeCount += 7;
  73. } else if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远
  74. this.PlayerControlPro.longJumpCount += 0.7;
  75. console.log("RightColl==", cc.find('Hero').getComponent('HeroControl').longJumpCount);
  76. }
  77. }
  78. else if (other.node.name === 'PreLongJumpBand') {
  79. // console.log("当前游戏状态 PreLongJumpBand", this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump);
  80. if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//最后一个跳远点,蓝色区域
  81. this.PlayerControlPro.longJumpCount += 0.7;
  82. // console.log("PreLongJumpBand!==", cc.find('Hero').getComponent('HeroControl').longJumpCount);
  83. }
  84. this.PlayerStatePro.enableTouch = false;
  85. this.PlayerStatePro.BTouchedScreenInTheZone = true;
  86. //todo 自己写的管理跳远是否点击过的
  87. this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong = true;
  88. this.PlayerControlPro.takeOffDistance = other.node.parent.getChildByName("NodeTouchControl").convertToWorldSpaceAR(cc.Vec2.ZERO).x
  89. - this.PlayerControlPro.node.convertToWorldSpaceAR(cc.Vec2.ZERO).x;
  90. this.PlayerControlPro.HeroLongJump("Hero");
  91. // this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.FrontLongJumpBand);
  92. this.PlayerStatePro.schedule(function () {
  93. this.PlayerStatePro.enableTouch = true;
  94. }.bind(this), 0.5, 0);
  95. // console.log("self = ",this.PlayerControlPro.node.convertToWorldSpaceAR(cc.Vec2.ZERO).x, other.node.parent.getChildByName("NodeTouchControl").convertToWorldSpaceAR(cc.Vec2.ZERO).x);
  96. }
  97. else if (other.node.name === 'BunkerAccelerationBandCenter') {
  98. // console.log("当前游戏状态 BunkerAccelerationBandCenter", this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump);
  99. if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//最后一个跳远点,黄色区域
  100. this.PlayerControlPro.longJumpCount += 0.9;
  101. // console.log("BunkerAccelerationBandCenter!==", cc.find('Hero').getComponent('HeroControl').longJumpCount);
  102. }
  103. this.PlayerStatePro.enableTouch = false;
  104. this.PlayerStatePro.BTouchedScreenInTheZone = true;
  105. //todo 自己写的管理跳远是否点击过的
  106. this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong = true;
  107. this.PlayerControlPro.HeroLongJump("Hero");
  108. // this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.PerfectLongJumpBand);
  109. this.PlayerStatePro.schedule(function () {
  110. this.PlayerStatePro.enableTouch = true;
  111. }.bind(this), 0.5, 0);
  112. }
  113. else if (other.node.name === 'PreHurdleBand') {
  114. this.PlayerControlPro.resetPerfectGrade();
  115. this.PlayerStatePro.enableTouch = false;
  116. this.PlayerStatePro.TouchControlEnableTouch = false;
  117. this.PlayerStatePro.BTouchedScreenInTheZone = true;
  118. this.PlayerControlPro.HeroJump(function () {
  119. this.PlayerStatePro.TouchControlEnableTouch = true;
  120. }.bind(this));
  121. this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.PreHurdleBand);
  122. this.PlayerStatePro.schedule(function () {
  123. //卧倒
  124. this.PlayerStatePro.Barrier.getComponent("Barrier").Shake();
  125. // var Hero = cc.find("Hero");
  126. var NetworkSocket = this.HeroPro.getComponent('NetworkSocket');
  127. var data = { FunctionName: 'ShakeBarrier', ParentName: this.PlayerStatePro.Railing.parent.name, ObjName: this.PlayerStatePro.Railing.name, PositionX: this.PlayerStatePro.Railing.convertToWorldSpaceAR(cc.Vec2.ZERO).x };
  128. NetworkSocket.sendSyncData(JSON.stringify(data));
  129. }.bind(this), 0.2, 0);
  130. this.PlayerStatePro.schedule(function () {
  131. this.PlayerStatePro.enableTouch = true;
  132. }.bind(this), 0.5, 0);
  133. }
  134. else if (other.node.name === 'PerfectHurdleBand') {
  135. // cc.log("现在动作","跨栏");
  136. this.PlayerStatePro.enableTouch = false;
  137. this.PlayerStatePro.BTouchedScreenInTheZone = true;
  138. this.PlayerControlPro.HeroJump(function () {
  139. this.PlayerStatePro.TouchControlEnableTouch = true;
  140. }.bind(this));
  141. this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.PerfectHurdleBand);
  142. this.PlayerStatePro.schedule(function () {
  143. this.PlayerStatePro.enableTouch = true;
  144. }.bind(this), 0.5, 0);
  145. }
  146. // var PlayerState = cc.find("Hero").getComponent("PlayerState");
  147. this.PlayerStatePro.TouchControlEnableTouch = false;
  148. if (other.node.name === 'LongAccelerationLeftColl' || other.node.name == "LongAccelerationRightColl") {
  149. this.PlayerControlPro.resetPerfectGrade();//非完美点击,则重置perfectGrade
  150. // var PlayerState = cc.find("Hero").getComponent("PlayerState");
  151. this.PlayerStatePro.TouchControlEnableTouch = true;
  152. this.node.destroy();
  153. }
  154. //todo 你想说的话
  155. // cc.log("状态 禁用点击");
  156. },
  157. // onCollisionStay: function (other) {
  158. // // console.log('on collision stay');
  159. // },
  160. // onCollisionExit: function (other) {
  161. // // cc.log("状态 出去",other);
  162. // },
  163. update(dt) {
  164. this.Index++;
  165. if (!this.BEnterCollision && 2 == this.Index) {
  166. // var Hero = cc.find("Hero");
  167. // var this.PlayerControlPro = Hero.getComponent('HeroControl');
  168. // this.PlayerControlPro.Stagger();
  169. this.PlayerControlPro.Stagger();
  170. }
  171. },
  172. });