| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- const GameStates = require("GameStates");
- cc.Class({
- extends: cc.Component,
- properties: {
-
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- //0 star 1 redstar 2 ufo 3 stone 4 ice 5 fish 6 drink 7 boom
- start () {
- this.main = this.node.parent.parent.getComponent('GameMode')
- var speedArr = [3.96,3.60,3.27,2.98,2.71,2.46,2.24,2.03,1.85,1.68]
- var speed = this.main.speedRate*(speedArr[GameStates.levelNum-1]+1)
- if(this.node.name == 'tool_Stone')
- speed = this.main.iceSpeedRate*this.main.speedRate*(speedArr[GameStates.levelNum-1]+1)
- this.node.runAction(cc.moveBy(speed,0,-2000))//下落速度
- if(this.node.name == 'tool_Star' || this.node.name == 'tool_RedStar'){
- this.node.runAction(cc.repeatForever(cc.rotateBy(5,360)))
- }
- else if(this.node.name == 'tool_Stone'){
- this.node.runAction(cc.repeatForever(cc.rotateBy(4.5,360)))
- }
- else if(this.node.name == 'tool_Ufo'){
- }
- else{
- this.node.runAction(cc.repeatForever(cc.rotateBy(4,360)))
- }
- },
- onCollisionEnter: function (other, self) {
- switch (this.node.index) {
- case 0:
- if(!this.main.isUsingTool)
- this.main.getTool1 ++
- this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
- this.main.addScore(1)
- this.main.addTarget()
- break;
- case 1:
- if(!this.main.isUsingTool)
- this.main.getTool2Rule2 ++
- this.main.getTool2Rule4 ++
- this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
- this.main.addScore(2)
- this.main.addTarget()
- break;
- case 2:
- if(!this.main.isUsingTool)
- this.main.getTool3 ++
- this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
- this.main.addScore(3)
- this.main.addTarget()
- break;
- case 3:
- if(!this.main.isUsingTool)
- this.main.getTool4 ++
- this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('yunshi',1)
- if(other.node.name=='Player'){
- this.main.loseLife()
- }
- else{
- self.node.destroy()
- }
- break;
- case 4:
- this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
- this.main.useIce()
- break;
- case 5:
- this.main.showDefence()
-
- break;
- case 6:
- this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('cat',1)
- this.main.addLife()
-
- break;
-
- default:
- this.main.playerAnimation.getComponent(dragonBones.ArmatureDisplay).playAnimation('xingxing',1)
- this.main.useBoom()
- break;
- }
- self.node.destroy()
- },
- update (dt) {
- if(this.node.y<this.main.Player.y-200){
- if(this.node.index == 0)
- this.main.missTool1 ++
- if(this.node.index == 1)
- this.main.missTool2 ++
- if(this.node.index == 2)
- this.main.missTool3 ++
- this.node.destroy()
- }
- },
- runDestroy(){
-
- setTimeout(function(){
- if(this.node)
- this.node.destroy()
- }.bind(this),200)
- }
- });
|