Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.MovieClip;
- import flash.filters.GlowFilter;
- public class BossVader3 extends MovieClip{
- public var health:Number = 120;
- public var colour:String = "red";
- public var pointValue:int = 1000;
- public var isBoss:Boolean = true;
- public var dead:Boolean = false;
- var moveDir:Number = 1;
- var speed:Number = 4;
- var attackPattern:String = "normal";
- var hitTimer:int = 60; // 1 second (due to game running at 60 frames per second)
- var canBeHit:Boolean = true;
- var fireTimer:int = 6;
- var fireRate:int = 12;
- var shotCount:int = 3;
- var parentClass:GameScreen;
- public function BossVader3() {
- // constructor code
- }
- public function doBossLogic(){
- if(!canBeHit){
- hitTimer --
- this.alpha = 0.25
- if(attackPattern != "critical"){
- attackPattern = "hit"
- }
- if(hitTimer <= 0){
- canBeHit = true;
- hitTimer = 60;
- this.alpha = 1;
- if(health <= 60 && attackPattern != "critical"){
- attackPattern = "triple"
- }
- else if(health > 60 && attackPattern != "critical"){
- attackPattern = "normal"
- }
- }
- }
- moveShip(attackPattern)
- attackPlayer(attackPattern)
- }
- function moveShip(atk){
- switch(atk){
- case "normal":
- this.x += moveDir * speed
- if(this.x > 550 && moveDir > 0){
- moveDir = -1;
- }
- if(this.x < 50 && moveDir < 0){
- moveDir = 1;
- }
- break;
- case "triple":
- this.x += moveDir * speed
- if(this.x > 550 && moveDir > 0){
- moveDir = -1;
- }
- if(this.x < 50 && moveDir < 0){
- moveDir = 1;
- }
- break;
- case "hit":
- this.x += moveDir * (speed * 3)
- if(this.x > 550 && moveDir > 0){
- moveDir = -1;
- }
- if(this.x < 50 && moveDir < 0){
- moveDir = 1;
- }
- break;
- case "critical":
- this.x += moveDir * speed
- if(this.x > 550 && moveDir > 0){
- moveDir = -1;
- }
- if(this.x < 50 && moveDir < 0){
- moveDir = 1;
- }
- break;
- }
- }
- function attackPlayer(atk){
- if(!parentClass.gamePaused){
- fireTimer --
- if(fireTimer <= 0){
- switch(atk){
- case "normal":
- parentClass.createEnemyBullet(this.x,this.y+10)
- fireTimer = fireRate;
- break;
- case "triple":
- parentClass.createEnemyBullet(this.x,this.y+10)
- parentClass.createEnemyBullet(this.x+20,this.y+10)
- parentClass.createEnemyBullet(this.x-20,this.y+10)
- fireTimer = fireRate;
- break;
- case "hit":
- parentClass.createEnemyBullet(this.x,this.y+10)
- fireTimer = 6;
- break;
- case "critical":
- parentClass.createEnemyBullet(this.x+(Math.random()*40-20),this.y+10)
- fireTimer = 6;
- break;
- }
- }
- }
- }
- public function init(pClass:GameScreen){
- parentClass = pClass
- this.health = 120
- updateSkin();
- }
- // takeDamage(amount)
- function takeDamage(amount:Number){
- if(this.health > 0 && canBeHit){
- if(attackPattern == "critical"){
- this.health -= 99
- }
- else{
- this.health -= amount
- }
- parentClass.createExplosion(this.x-40,this.y-15,this.colour);
- parentClass.createExplosion(this.x+40,this.y-15,this.colour);
- parentClass.createExplosion(this.x-80,this.y,this.colour);
- parentClass.createExplosion(this.x+80,this.y,this.colour);
- parentClass.createExplosion(this.x,this.y-30,this.colour);
- parentClass.createExplosion(this.x-40,this.y+15,this.colour);
- parentClass.createExplosion(this.x+40,this.y+15,this.colour);
- updateSkin();
- canBeHit = false;
- if(this.health <= 0){
- parentClass.createExplosion(this.x,this.y-40,"red");
- parentClass.createExplosion(this.x-40,this.y-30,"yellow");
- parentClass.createExplosion(this.x+40,this.y-30,"yellow");
- parentClass.createExplosion(this.x-80,this.y-30,"yellow");
- parentClass.createExplosion(this.x+80,this.y-30,"yellow");
- parentClass.challenges.boss3 = true;
- this.dead = true;
- }
- }
- }
- // updateSkin()
- public function updateSkin(){
- if(this.health <= 10){
- this.colour = "yellow"
- this.gotoAndStop("critical")
- this.attackPattern = "critical"
- speed = 15;
- fireRate = 12;
- }
- else if(this.health <= 20){
- this.colour = "yellow"
- this.gotoAndStop("yellow")
- speed = 4;
- fireRate = 30;
- this.attackPattern = "normal"
- }
- else if(this.health <= 30){
- this.colour = "blue"
- this.gotoAndStop("blue")
- speed = 4;
- fireRate = 22;
- }
- else if(this.health <= 40){
- this.colour = "green"
- this.gotoAndStop("green")
- speed = 4;
- fireRate = 24;
- }
- else if(this.health <= 50){
- this.colour = "red"
- this.gotoAndStop("green/red")
- speed = 3.5;
- fireRate = 24;
- }
- else if(this.health <= 60){
- this.colour = "red"
- this.gotoAndStop("red")
- speed = 3;
- fireRate = 24;
- this.attackPattern = "triple"
- }
- else if(this.health <= 70){
- this.colour = "white"
- this.gotoAndStop("red/white")
- speed = 5.25
- fireRate = 12;
- }
- else if(this.health <= 80){
- this.colour = "white"
- this.gotoAndStop("white")
- speed = 5.5;
- fireRate = 12;
- }
- else if(this.health <= 90){
- this.colour = "black"
- this.gotoAndStop("white/black")
- speed = 5.7
- fireRate = 12;
- }
- else if(this.health <= 100){
- this.colour = "black"
- this.gotoAndStop("black/white")
- speed = 5.8
- fireRate = 12;
- }
- else if(this.health <= 110){
- this.colour = "black"
- this.gotoAndStop("black")
- speed = 5.9
- fireRate = 12;
- }
- else {
- this.colour = "black"
- this.gotoAndStop("max")
- speed = 6
- fireRate = 12;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement