-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomeMadeGroup.java
More file actions
144 lines (128 loc) · 3.43 KB
/
Copy pathhomeMadeGroup.java
File metadata and controls
144 lines (128 loc) · 3.43 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
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
class homeMadeBoss implements Serializable {
private int clock;
private int groupType;
private int chickenType;
private int groupSpeedX =1;
private int groupSpeedY =1;
private int number;
private int n;
private int m;
// private int x;
// private int y;
private final ArrayList<ChickenObject> chickenObjects = new ArrayList<>();
private final ArrayList<int[]> locs=new ArrayList<>();
public homeMadeGroup(int number,int wave,int chickenType,int m) {
clock =0;
this.m=m;
setText(wave!=-1?"Wave "+wave:"final Wave");
this.chickenType=chickenType;
this.number=number;
n=7;
}
private int[] getNowLocation(){
return new int[]{getX(), getY()};
}
private void updateLocations (int i){
int X=0;
int Y=0;
X+=groupSpeedX;
Y+=groupSpeedY;
if(X<50){
groupSpeedX =1;
}else if(X > Constants.frameWidth-50)
groupSpeedX =-1;
if(Y<50){
groupSpeedX =1;
}else if(X > Constants.frameHeight-50)
groupSpeedX =-1;
chickenObjects.get(i).stepToLocation(new int[]{X, Y});
}
public int[] getChickenLocation(int i){
return chickenObjects.get(i).getLocation();
}
@Override
public void stepClock(){
clock++;
move();
makeChickens();
}
@Override
public boolean dispose() {
return getChickenObjectsize()==0&&number==0;
}
public ArrayList<ChickenObject> getChickenObjects(){
return new ArrayList<>(chickenObjects);
}
public int getChickenObjectsize(){
return chickenObjects.size();
}
public void remove(ChickenObject chicken){
chickenObjects.remove(chicken);
}
public int getGroupType() {
return groupType;
}
public int getChickenType() {
return chickenType;
}
public boolean Alarm(){
return clock<2000;
}
private void makeChickens(){
if (!Alarm() && clock%50==0 && getChickenObjectsize()<number){
chickenObjects.add(new ChickenObject(Constants.frameWidth/2,-Constants.frameHeight/2,5,1,m));
}
if(getChickenObjectsize()==number){
number=0;
}
}
private void move(){
if(clock%10==0) {
if(groupType ==1) {
setX(getX() + groupSpeedX);
}else if(groupType ==2) {
setX(getX() + groupSpeedX);
setY(getY() + groupSpeedY);
}else{
setX(0);
setY(0);
}
}
for (int i = 0; i < getChickenObjectsize(); i++) {
updateLocations(i);
}
}
public int getFrame(){
if(groupType!=5)
return clock/40;
else
return chickenObjects.get(0).getFrameForBoss();
}
// public homeMadeBoss (int x, int y, int width, int height, String text, String paintMethod) {
//
// }
// public abstract int[] getChickenLocation(int i){
//
// }
// public abstract ArrayList<ChickenObject> getChickenObjects(){
//
// }
// public abstract int getChickenObjectsize(){
//
// }
// public abstract void remove(ChickenObject chicken){
//
// }
// public abstract int getGroupType(){
//
// }
// public abstract int getChickenType(){
//
// }
// public abstract boolean Alarm(){
//
// }
// public abstract int getFrame(){
//
// }
}