-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDethPlane.java
141 lines (127 loc) · 4.15 KB
/
DethPlane.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
import processing.core.*;
import processing.data.*;
import java.util.ArrayList;
class DethPlane extends StageComponent {//ground component
public static final Identifier ID = new Identifier("DeathPlane");
DethPlane(JSONObject data, boolean stage_3D) {
type="dethPlane";
x=data.getFloat("x");
y=data.getFloat("y");
dx=data.getFloat("dx");
dy=data.getFloat("dy");
if (stage_3D) {
z=data.getFloat("z");
dz=data.getFloat("dz");
}
if (!data.isNull("group")) {
group=data.getInt("group");
}
}
DethPlane(float X, float Y, float DX, float DY) {
type="dethPlane";
x=X;
y=Y;
dx=DX;
dy=DY;
}
StageComponent copy() {
return new DethPlane(x, y, dx, dy);
}
StageComponent copy(float offsetX, float offsetY) {
return new DethPlane(x+offsetX, y+offsetY, dx, dy);
}
StageComponent copy(float offsetX, float offsetY, float offsetZ) {
System.err.println("Attempted to create a 3D copy of a deth plane. This opperation is not supported");
return null;
}
public DethPlane(SerialIterator iterator){
deserial(iterator);
}
JSONObject save(boolean stage_3D) {
JSONObject part=new JSONObject();
part.setFloat("x", x);
part.setFloat("y", y);
part.setFloat("dx", dx);
part.setFloat("dy", dy);
if (stage_3D) {
part.setFloat("z", z);
part.setFloat("dz", dz);
}
part.setString("type", type);
part.setInt("group", group);
return part;
}
void draw(PGraphics render) {
Group group=getGroup();
if (!group.visable)
return;
render.fill(-114431);
render.rect(source.Scale*((x+group.xOffset)-source.drawCamPosX)-0.02f, source.Scale*((y+group.yOffset)+source.drawCamPosY)-0.02f, source.Scale*dx+0.04f, source.Scale*dy+0.04f);
}
void draw3D(PGraphics render) {
Group group=getGroup();
if (!group.visable)
return;
render.fill(-114431);
render.strokeWeight(0);
render.translate((x+group.xOffset)+dx/2, (y+group.yOffset)+dy/2, (z+group.zOffset)+dz/2);
render.box(dx, dy, dz);
render.translate(-1*((x+group.xOffset)+dx/2), -1*((y+group.yOffset)+dy/2), -1*((z+group.zOffset)+dz/2));
}
boolean colide(float x, float y, boolean c) {
Group group=getGroup();
if (!group.visable)
return false;
float x2 = (this.x+group.xOffset)+dx, y2=(this.y+group.yOffset)+dy;
if (x >= (this.x+group.xOffset) && x <= x2 && y >= (this.y+group.yOffset) && y <= y2/* terain hit box*/) {
return true;
}
return false;
}
boolean colideDethPlane(float x, float y) {
Group group=getGroup();
if (!group.visable)
return false;
float x2 =(this.x+group.xOffset)+dx, y2=(this.y+group.yOffset)+dy;
if (x >= (this.x+group.xOffset) && x <= x2 && y >= (this.y+group.yOffset) && y <= y2/* terain hit box*/) {
return true;
}
return false;
}
public Collider2D getCollider2D() {
Group group=getGroup();
if (!group.visable)
return null;
return new Collider2D(new PVector[]{
new PVector(x+group.xOffset, y+group.yOffset),
new PVector(x+group.xOffset+dx, y+group.yOffset),
new PVector(x+group.xOffset+dx, y+group.yOffset+dy),
new PVector(x+group.xOffset, y+group.yOffset+dy)
});
}
public Collider3D getCollider3D() {
Group group=getGroup();
if (!group.visable)
return null;
return new Collider3D(new PVector[]{
new PVector(x+group.xOffset, y+group.yOffset, z+group.zOffset),
new PVector(x+group.xOffset+dx, y+group.yOffset, z+group.zOffset),
new PVector(x+group.xOffset+dx, y+group.yOffset+dy, z+group.zOffset),
new PVector(x+group.xOffset, y+group.yOffset+dy, z+group.zOffset),
new PVector(x+group.xOffset, y+group.yOffset, z+group.zOffset+dz),
new PVector(x+group.xOffset+dx, y+group.yOffset, z+group.zOffset+dz),
new PVector(x+group.xOffset+dx, y+group.yOffset+dy, z+group.zOffset+dz),
new PVector(x+group.xOffset, y+group.yOffset+dy, z+group.zOffset+dz)
});
}
@Override
public SerializedData serialize() {
SerializedData data = new SerializedData(id());
serialize(data);
return data;
}
@Override
public Identifier id() {
return ID;
}
}