-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoss.as
122 lines (111 loc) · 2.94 KB
/
Boss.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Boss
package {
import net.flashpunk.*;
import net.flashpunk.graphics.*;
import net.flashpunk.masks.*
public class Boss extends Entity {
[Embed(source="assets/boss.png")]
public var bossclass:Class;
[Embed(source="assets/bossL.png")]
public var bossLclass:Class;
private var speed:Number = 100;
public static var bosshealth:int = 30;
public static var hpDecrease:Boolean = false;
public static var bosskilled:Boolean = false;
private var myspeed:Number = speed;
private var killedcounter:Number = 0;
public var img:Image = new Image(bossclass);
public var imgL:Image = new Image(bossLclass);
public var moveLeft:Boolean = false;
public var moveRight:Boolean = false;
public var shotfired:Boolean = false;
private var reloadTime:int = 20;
private var lastShot:Number = reloadTime;
public static var h:int;
public var spriteR:BloomWrapper = new BloomWrapper(new BlurWrapper(img, SWorld.blur));
public var spriteL:BloomWrapper = new BloomWrapper(new BlurWrapper(imgL, SWorld.blur));
public function Boss(_x:int, _y:int):void {
mask = new Pixelmask(bossclass);
SWorld.bloom.register(spriteR);
graphic = spriteR;
width = img.width;
height = img.height;
h = height;
x = _x;
y = _y;
type = "boss"
}
override public function update():void {
move();
lastShot++
var bullet:Bullet = collide("bullet", x,y) as Bullet;
if (bullet) {
bosshealth -= 1;
hpDecrease = true;
SWorld.score += 50;
bullet.destroy();
}
if (bosshealth == 0) {
SWorld.score += 5000;
speed = 0;
SWorld.exp1.explode(x+width/2,y+height/2);
SWorld.exp1.explode(x+width/2,y+height/2);
SWorld.exp1.explode(x+width/2,y+height/2);
SWorld.exp1.explode(x+width/2,y+height/2);
SWorld.exp1.explode(x+width/2,y+height/2);
SWorld.exp1.explode(x+width/2,y+height/2);
visible = false;
bosskilled = true;
bosshealth = 1000;
}
if (bosskilled) {
killedcounter++;
}
if (killedcounter >= 48) {
bossBullet.remove = true;
destroy();
}
}
private function move():void {
if (visible) {fire(x, y);}
if (y < 10) {
y += speed * FP.elapsed;
moveLeft = true;
}
else {
if (moveLeft) {
mask = new Pixelmask(bossLclass);
SWorld.bloom.register(spriteL);
graphic = spriteL;
x -= speed * FP.elapsed;
if (x <= 1) {
moveLeft = false;
moveRight = true;
}
}
else if (moveRight) {
mask = new Pixelmask(bossclass);
SWorld.bloom.register(spriteR);
graphic = spriteR;
x += speed * FP.elapsed;
if (x >= FP.screen.width - width) {
moveRight = false;
moveLeft = true;
}
}
}
}
public function destroy():void {
HUD.gameOver = true;
HUD.gameWon = true;
FP.world.remove(this);
}
public function fire(x:int,y:int):void {
if (lastShot >= reloadTime) {
world.add(new bossBullet(x+94,y+height - 5));//y+104));
lastShot = 0;
shotfired = true;
}
}
}
}