LeavingPrintLocationLine.js 11 KB

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