ToolConfig.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. const GameStates = require("GameStates");
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. },
  6. // LIFE-CYCLE CALLBACKS:
  7. // onLoad () {},
  8. //0 star 1 redstar 2 ufo 3 stone 4 ice 5 fish 6 drink 7 boom
  9. start () {
  10. this.main = this.node.parent.parent.getComponent('GameMode')
  11. var speedArr = [3.96,3.60,3.27,2.98,2.71,2.46,2.24,2.03,1.85,1.68]
  12. var speed = this.main.speedRate*(speedArr[GameStates.levelNum-1]+1)
  13. if(this.node.name == 'tool_Stone')
  14. speed = this.main.iceSpeedRate*this.main.speedRate*(speedArr[GameStates.levelNum-1]+1)
  15. this.node.runAction(cc.moveBy(speed,0,-2000))//下落速度
  16. if(this.node.name == 'tool_Star' || this.node.name == 'tool_RedStar'){
  17. this.node.runAction(cc.repeatForever(cc.rotateBy(5,360)))
  18. }
  19. else if(this.node.name == 'tool_Stone'){
  20. this.node.runAction(cc.repeatForever(cc.rotateBy(4.5,360)))
  21. }
  22. else if(this.node.name == 'tool_Ufo'){
  23. }
  24. else{
  25. this.node.runAction(cc.repeatForever(cc.rotateBy(4,360)))
  26. }
  27. },
  28. onCollisionEnter: function (other, self) {
  29. switch (this.node.index) {
  30. case 0:
  31. if(!this.main.isUsingTool)
  32. this.main.getTool1 ++
  33. this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
  34. this.main.addScore(1)
  35. this.main.addTarget()
  36. break;
  37. case 1:
  38. if(!this.main.isUsingTool)
  39. this.main.getTool2Rule2 ++
  40. this.main.getTool2Rule4 ++
  41. this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
  42. this.main.addScore(2)
  43. this.main.addTarget()
  44. break;
  45. case 2:
  46. if(!this.main.isUsingTool)
  47. this.main.getTool3 ++
  48. this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
  49. this.main.addScore(3)
  50. this.main.addTarget()
  51. break;
  52. case 3:
  53. if(!this.main.isUsingTool)
  54. this.main.getTool4 ++
  55. this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('yunshi',1)
  56. if(other.node.name=='Player'){
  57. this.main.loseLife()
  58. }
  59. else{
  60. self.node.destroy()
  61. }
  62. break;
  63. case 4:
  64. this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
  65. this.main.useIce()
  66. break;
  67. case 5:
  68. this.main.showDefence()
  69. break;
  70. case 6:
  71. this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('cat',1)
  72. this.main.addLife()
  73. break;
  74. default:
  75. this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
  76. this.main.useBoom()
  77. break;
  78. }
  79. self.node.destroy()
  80. },
  81. update (dt) {
  82. if(this.node.y<this.main.Player.y-200){
  83. if(this.node.index == 0)
  84. this.main.missTool1 ++
  85. if(this.node.index == 1)
  86. this.main.missTool2 ++
  87. if(this.node.index == 2)
  88. this.main.missTool3 ++
  89. this.node.destroy()
  90. }
  91. },
  92. runDestroy(){
  93. setTimeout(function(){
  94. if(this.node)
  95. this.node.destroy()
  96. }.bind(this),200)
  97. }
  98. });