PerfectHurdleBand.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. }
  35. },
  36. onCollisionStay: function (other) {
  37. // console.log('on collision stay');
  38. },
  39. onCollisionExit: function (other)
  40. {
  41. if(other.node.name === 'PlayerCollisionLine') {
  42. var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
  43. var HeroControlScript = PlayerCollisionLine.Hero.getComponent("HeroControl");
  44. var PlayerStateScript = PlayerCollisionLine.Hero.getComponent("PlayerState");
  45. if(!PlayerStateScript.BTouchedScreenInTheZone)
  46. {
  47. HeroControlScript.Stagger();
  48. // CustomLog("撞到了 栏杆",other.node);
  49. //下面
  50. if (other.node.parent.parent.name == "Hero") {
  51. var PlayerState = other.node.parent.parent.getComponent("PlayerState");
  52. PlayerState.TouchControlEnableTouch = true;
  53. //卧倒
  54. this.Barrier.getComponent("Barrier").FallingDown();
  55. this.Railing.getComponent("Barrier");
  56. var Hero = cc.find("Hero");
  57. var NetworkSocket = Hero.getComponent('NetworkSocket');
  58. // CustomLog("撞到了 栏杆 具体",this.Barrier);
  59. var data = {FunctionName:'PerfectHurdleBandRailing',ParentName:this.Railing.parent.name,ObjName:this.Railing.name,PositionX:this.Railing.convertToWorldSpaceAR(cc.Vec2.ZERO).x};
  60. NetworkSocket.sendSyncData(JSON.stringify(data));
  61. }
  62. if (other.node.parent.parent.name == "Rivel") {
  63. this.Railing.getComponent("Barrier").FallingDown();
  64. this.Barrier.getComponent("Barrier");
  65. var Hero = cc.find("Hero");
  66. var NetworkSocket = Hero.getComponent('NetworkSocket');
  67. var data = {FunctionName:'PerfectHurdleBandBarrier',ParentName:this.Barrier.parent.name,ObjName:this.Barrier.name,PositionX:this.Barrier.convertToWorldSpaceAR(cc.Vec2.ZERO).x};
  68. NetworkSocket.sendSyncData(JSON.stringify(data));
  69. }
  70. }
  71. PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.None;
  72. PlayerStateScript.BTouchedScreenInTheZone = false;
  73. }
  74. }
  75. });