()
| 53 | |
| 54 | // update() |
| 55 | public update(): void{ |
| 56 | // Calculate the distance from the player |
| 57 | var distanceFromPlayer: Pos = this.getGlobalPosition().plus(new Pos(2, 0)).getDistance(this.getQuest().getGame().getPlayer().getGlobalPosition()); |
| 58 | |
| 59 | // Handle ammunition timer |
| 60 | if(this.ammunitionTimer <= 0){ |
| 61 | if(this.ammunition < this.maxAmmunition) |
| 62 | this.ammunition += 1; |
| 63 | this.ammunitionTimer = 20; |
| 64 | } |
| 65 | else this.ammunitionTimer -= 1; |
| 66 | |
| 67 | // Handle magic spine timer |
| 68 | if(this.magicSpineTimer > 0) |
| 69 | this.magicSpineTimer -= 1; |
| 70 | |
| 71 | // Set the movement depending on the distance from the player |
| 72 | this.getQuestEntityMovement().setOffset(new Pos((distanceFromPlayer.x > 0? -1:1), 0)); |
| 73 | |
| 74 | // If the player is above the ground position |
| 75 | if(this.getQuest().getGame().getPlayer().getGlobalPosition().y < this.groundYPosition){ |
| 76 | // If the timer is okay |
| 77 | if(this.magicSpineTimer <= 0){ |
| 78 | // We shoot a magic spine on the left or on the right |
| 79 | if(this.shootMagicSpine((distanceFromPlayer.x > 0? true:false))){ // If it worked |
| 80 | this.ammunition -= 1; // We lower the ammunition |
| 81 | this.magicSpineTimer = 12; // We set the countdown |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // Call the mother class update |
| 87 | super.update(); |
| 88 | } |
| 89 | |
| 90 | // willDie() |
| 91 | public willDie(): void{ |
nothing calls this directly
no test coverage detected