PerfectHurdleBand.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. const PlayerStateStatic = require('PlayerState');
  2. var BarrierSuperClass = require("BarrierSuper");
  3. cc.Class({
  4. extends:BarrierSuperClass,
  5. properties: {
  6. Barrier: {
  7. default: null,
  8. type: cc.Node
  9. },
  10. Railing: {
  11. default: null,
  12. type: cc.Node
  13. },
  14. },
  15. start () {
  16. },
  17. onCollisionEnter: function (other) {
  18. if(other.node.name === 'PlayerCollisionLine') {
  19. var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
  20. var PlayerStateScript = PlayerCollisionLine.Hero.getComponent("PlayerState");
  21. PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.PerfectHurdleBand;
  22. // cc.log(PlayerStateScript.CurrentInZoneType );
  23. if (other.node.parent.parent.name == "Hero") {
  24. var PlayerState = other.node.parent.parent.getComponent("PlayerState");
  25. PlayerState.TouchControlEnableTouch = true;
  26. }
  27. }
  28. if(other.node.name === 'LocationLine')
  29. {
  30. //perfect完美提示
  31. cc.find('UIControl').getComponent('GameUI').hideTimerPerfect(3);
  32. cc.find('Hero').getComponent('HeroControl').addPerfectGradeAndPlay();
  33. // this.node.destroy();
  34. this.node.opacity = 0;
  35. }
  36. },
  37. onCollisionStay: function (other) {
  38. // console.log('on collision stay');
  39. },
  40. onCollisionExit: function (other)
  41. {
  42. if(other.node.name === 'PlayerCollisionLine') {
  43. var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
  44. var HeroControlScript = PlayerCollisionLine.Hero.getComponent("HeroControl");
  45. var PlayerStateScript = PlayerCollisionLine.Hero.getComponent("PlayerState");
  46. if(!PlayerStateScript.BTouchedScreenInTheZone)
  47. {
  48. HeroControlScript.Stagger();
  49. // CustomLog("撞到了 栏杆",other.node);
  50. //下面
  51. if (other.node.parent.parent.name == "Hero") {
  52. var PlayerState = other.node.parent.parent.getComponent("PlayerState");
  53. PlayerState.TouchControlEnableTouch = true;
  54. //卧倒
  55. this.Barrier.getComponent("Barrier").FallingDown();
  56. this.Railing.getComponent("Barrier");
  57. var Hero = cc.find("Hero");
  58. var NetworkSocket = Hero.getComponent('NetworkSocket');
  59. // CustomLog("撞到了 栏杆 具体",this.Barrier);
  60. var data = {FunctionName:'PerfectHurdleBandRailing',ParentName:this.Railing.parent.name,ObjName:this.Railing.name,PositionX:this.Railing.convertToWorldSpaceAR(cc.Vec2.ZERO).x};
  61. NetworkSocket.sendSyncData(JSON.stringify(data));
  62. }
  63. if (other.node.parent.parent.name == "Rivel") {
  64. this.Railing.getComponent("Barrier").FallingDown();
  65. this.Barrier.getComponent("Barrier");
  66. var Hero = cc.find("Hero");
  67. var NetworkSocket = Hero.getComponent('NetworkSocket');
  68. var data = {FunctionName:'PerfectHurdleBandBarrier',ParentName:this.Barrier.parent.name,ObjName:this.Barrier.name,PositionX:this.Barrier.convertToWorldSpaceAR(cc.Vec2.ZERO).x};
  69. NetworkSocket.sendSyncData(JSON.stringify(data));
  70. }
  71. }
  72. PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.None;
  73. PlayerStateScript.BTouchedScreenInTheZone = false;
  74. }
  75. }
  76. });