-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBossNPC.java
More file actions
65 lines (52 loc) · 1.42 KB
/
BossNPC.java
File metadata and controls
65 lines (52 loc) · 1.42 KB
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
import java.awt.Color;
import java.awt.Graphics2D;
public class BossNPC extends NPC {
private Assign9 main;
public BossNPC(Assign9 main, Position position) {
super("boss_npc", 100, position);
this.main = main;
setMoveDelay(800);
setDead(false);
}
@Override
public void onCollision(Entity other) {
if (other instanceof Bullet) {
final Bullet bullet = (Bullet) other;
if (!(bullet.getOwner() instanceof NPC)) {
bullet.setDead(true);
setHitpoints(getHitpoints() - 25);
if (getHitpoints() <= 0) {
setDead(true);
World.enemyCount --;
SoundEffects.BOSS_DEATH.play();
if (bullet.getOwner() instanceof Player) {
final Player player = (Player) bullet.getOwner();
player.setScore(player.getScore() + 1000);
}
}
}
} else if (other instanceof Player) {
final Player player = (Player) other;
player.setDead(true);
}
}
@Override
public void fire(Bullet bullet) {
// TODO Auto-generated method stub
}
@Override
public void update(Graphics2D g) {
if (!isDead()) {
//g.setColor(Color.RED);
//g.drawString("BOSS", getPosition().getX(), getPosition().getY() - 20);
if (System.currentTimeMillis() - getMoveDelay() > 40) {
setPosition(new Position(getPosition().getX() - 2, getPosition()
.getY()));
setMoveDelay(System.currentTimeMillis());
}
if (getPosition().getX() <= 0) {
main.setDidPassPlayer(true);
}
}
}
}