-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConehead.java
163 lines (144 loc) · 5.16 KB
/
Conehead.java
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class BasicZombie here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Conehead extends Zombie
{
/**
* Act - do whatever the BasicZombie wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public boolean cone = true;
public GreenfootImage[] idle;
public GreenfootImage[] walk;
public GreenfootImage[] armless;
public GreenfootImage[] eat;
public GreenfootImage[] armlesseat;
public GreenfootImage[] conehead;
public GreenfootImage[] coneheadwalk;
public GreenfootImage[] coneheadwalkd;
public GreenfootImage[] coneheadwalkdd;
public GreenfootImage[] coneheadeat;
public GreenfootImage[] coneheadeatd;
public GreenfootImage[] coneheadeatdd;
public Conehead() {
idle = importSprites("zombieidle", 4);
walk = importSprites("zombiewalk", 7);
eat = importSprites("zombieeating", 7);
armlesseat = importSprites("armlesszombieeating", 7);
armless = importSprites("armlesszombie", 7);
//Conehead
coneheadwalk = importSprites("coneheadwalk", 7);
coneheadwalkd = importSprites("coneheadwalkd", 7);
coneheadwalkdd = importSprites("coneheadwalkdd", 7);
coneheadeat = importSprites("coneheadeat", 7);
coneheadeatd = importSprites("coneheadeatd", 7);
coneheadeatdd = importSprites("coneheadeatdd", 7);
walkSpeed = Random.Double(11, 14);
maxHp = 300;
hp = maxHp;
}
public void update() {
if (hp > 232) {
if (!isEating()) {
animate(coneheadwalk, 350, true);
move(-walkSpeed);
} else {
animate(coneheadeat, 200, true);
playEating();
}
} else if (hp > 166) {
if (!isEating()) {
animate(coneheadwalkd, 350, true);
move(-walkSpeed);
} else {
animate(coneheadeatd, 200, true);
playEating();
}
} else if (hp > 100) {
if (!isEating()) {
animate(coneheadwalkdd, 350, true);
move(-walkSpeed);
} else {
animate(coneheadeatdd, 200, true);
playEating();
}
} else {
if (cone) {
cone = false;
MyWorld.addObject(new Cone(), getX(), getY()-25);
}
if (hp > 50) {
if (!isEating()) {
animate(walk, 350, true);
move(-walkSpeed);
} else {
animate(eat, 200, true);
playEating();
}
} else {
if (!fallen) {
fallen = true;
AudioPlayer.play(80, "limbs_pop.mp3");
MyWorld.addObject(new Arm(), getX()+8, getY()+20);
}
if (!isEating()) {
animate(armless, 350, true);
move(-walkSpeed);
} else {
animate(armlesseat, 200, true);
playEating();
}
}
}
}
public void hit(int dmg) {
AudioPlayer.play(70, "plastichit.mp3", "plastichit2.mp3");
AudioPlayer.play(70, "splat.mp3", "splat2.mp3", "splat3.mp3");
if (isLiving()) {
if (hp > 232) {
if (!isEating()) {
hitFlash(coneheadwalk, "coneheadwalk");
} else {
hitFlash(coneheadeat, "coneheadeat");
}
} else if (hp > 166) {
if (!isEating()) {
hitFlash(coneheadwalkd, "coneheadwalkd");
} else {
hitFlash(coneheadeatd, "coneheadeatd");
}
} else if (hp > 100) {
if (!isEating()) {
hitFlash(coneheadwalkdd, "coneheadwalkdd");
} else {
hitFlash(coneheadeatdd, "coneheadeatdd");
}
} else {
if (!fallen) {
if (!eating) {
hitFlash(walk, "zombiewalk");
} else {
hitFlash(eat, "zombieeating");
}
} else {
if (!eating) {
hitFlash(armless, "armlesszombie");
} else {
hitFlash(armlesseat, "armlesszombieeating");
}
}
}
hp -= dmg;
} else if (!finalDeath) {
if (!eating) {
hitFlash(headless, "zombieheadless");
} else {
hitFlash(headlesseating, "headlesszombieeating");
}
}
}
}