239 lines
8.4 KiB
Java
239 lines
8.4 KiB
Java
package p000;
|
|
|
|
import java.util.Vector;
|
|
import javax.microedition.m3g.Appearance;
|
|
import javax.microedition.m3g.Background;
|
|
import javax.microedition.m3g.CompositingMode;
|
|
import javax.microedition.m3g.Group;
|
|
import javax.microedition.m3g.Image2D;
|
|
import javax.microedition.m3g.Light;
|
|
import javax.microedition.m3g.Loader;
|
|
import javax.microedition.m3g.Mesh;
|
|
import javax.microedition.m3g.Sprite3D;
|
|
import javax.microedition.m3g.World;
|
|
|
|
/* renamed from: aa */
|
|
/* loaded from: microcounterstrike.jar:aa.class */
|
|
public final class MapManager {
|
|
|
|
/* renamed from: f */
|
|
private static MapManager instance;
|
|
|
|
/* renamed from: b */
|
|
public World world;
|
|
|
|
/* renamed from: c */
|
|
public int currentMapIndex;
|
|
|
|
/* renamed from: d */
|
|
public float[] worldBoundsXZ;
|
|
|
|
/* renamed from: e */
|
|
public Vector[][] collisionCells;
|
|
|
|
/* renamed from: a */
|
|
public Vector maps = new Vector();
|
|
|
|
/* renamed from: g */
|
|
private Vector decorations = null;
|
|
|
|
static {
|
|
PlatformServices.getInstance().registerBuiltInMaps();
|
|
}
|
|
|
|
private MapManager() {
|
|
}
|
|
|
|
/* renamed from: a */
|
|
public static MapManager getInstance() {
|
|
if (instance == null) {
|
|
instance = new MapManager();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
/* renamed from: b */
|
|
public final World loadCurrentMap() {
|
|
try {
|
|
World[] worldArrLoad = Loader.load(getCurrentMapInfo().resourcePath);
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= worldArrLoad.length) {
|
|
break;
|
|
}
|
|
if (worldArrLoad[i] instanceof World) {
|
|
this.world = worldArrLoad[i];
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
applyMapLighting(this.currentMapIndex);
|
|
addDirectionalLight();
|
|
buildCollisionGrid();
|
|
} catch (Exception e) {
|
|
System.out.println("Load map error!");
|
|
e.printStackTrace();
|
|
}
|
|
return this.world;
|
|
}
|
|
|
|
/* renamed from: a */
|
|
private void applyMapLighting(int i) {
|
|
if (i != 5) {
|
|
addMoonSprite();
|
|
}
|
|
switch (i) {
|
|
case 1:
|
|
createTrees();
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* renamed from: f */
|
|
private void addMoonSprite() {
|
|
try {
|
|
Image2D image2DM129a = ResourceLoader.loadM3G129("/res/map/moon.png");
|
|
Appearance appearance = new Appearance();
|
|
CompositingMode compositingMode = new CompositingMode();
|
|
compositingMode.setBlending(68);
|
|
appearance.setCompositingMode(compositingMode);
|
|
Sprite3D sprite3D = new Sprite3D(false, image2DM129a, appearance);
|
|
this.world.addChild(sprite3D);
|
|
sprite3D.setTranslation(0.0f, 50.0f, 0.0f);
|
|
} catch (Exception e) {
|
|
System.out.println(new StringBuffer("createMoon error!").append(e).toString());
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
/* renamed from: g */
|
|
private void createTrees() {
|
|
this.decorations = new Vector();
|
|
Image2D image2DM132b = ResourceLoader.loadImages132("/res/map/tree.png");
|
|
BillboardSprite c0013am = new BillboardSprite(image2DM132b, CameraManager.getInstance().getCamera121("MAIN"), 38.8f, 8.0f, 59.1f, 16.0f);
|
|
this.decorations.addElement(c0013am);
|
|
this.world.addChild(c0013am.mesh75);
|
|
BillboardSprite c0013am2 = new BillboardSprite(image2DM132b, CameraManager.getInstance().getCamera121("MAIN"), 31.9f, 8.0f, 90.2f, 16.0f);
|
|
this.decorations.addElement(c0013am2);
|
|
this.world.addChild(c0013am2.mesh75);
|
|
BillboardSprite c0013am3 = new BillboardSprite(image2DM132b, CameraManager.getInstance().getCamera121("MAIN"), -57.9f, 8.0f, -51.7f, 16.0f);
|
|
this.decorations.addElement(c0013am3);
|
|
this.world.addChild(c0013am3.mesh75);
|
|
}
|
|
|
|
/* renamed from: c */
|
|
public final void updateDecorations() {
|
|
if (this.decorations == null) {
|
|
return;
|
|
}
|
|
for (int i = 0; i < this.decorations.size(); i++) {
|
|
((BillboardSprite) this.decorations.elementAt(i)).execute106();
|
|
}
|
|
}
|
|
|
|
/* renamed from: h */
|
|
private void addDirectionalLight() {
|
|
Light light = new Light();
|
|
light.setMode(128);
|
|
light.setIntensity(3.0f);
|
|
this.world.addChild(light);
|
|
}
|
|
|
|
/* renamed from: i */
|
|
private void buildCollisionGrid() {
|
|
int[] iArr = getCurrentMapInfo().collisionObjectIds;
|
|
this.worldBoundsXZ = new float[4];
|
|
if (iArr == null) {
|
|
this.worldBoundsXZ[0] = -400.0f;
|
|
this.worldBoundsXZ[1] = -400.0f;
|
|
this.worldBoundsXZ[2] = 400.0f;
|
|
this.worldBoundsXZ[3] = 400.0f;
|
|
this.collisionCells = new Vector[(int) Math.ceil((this.worldBoundsXZ[3] - this.worldBoundsXZ[1]) / 20.0f)][(int) Math.ceil((this.worldBoundsXZ[2] - this.worldBoundsXZ[0]) / 20.0f)];
|
|
return;
|
|
}
|
|
this.worldBoundsXZ[0] = Float.MAX_VALUE;
|
|
this.worldBoundsXZ[1] = Float.MAX_VALUE;
|
|
this.worldBoundsXZ[2] = -3.4028235E38f;
|
|
this.worldBoundsXZ[3] = -3.4028235E38f;
|
|
AxisAlignedBoundingBox[] c0025ayArr = new AxisAlignedBoundingBox[iArr.length];
|
|
for (int i = 0; i < iArr.length; i++) {
|
|
Mesh meshFind = this.world.find(iArr[i]);
|
|
AxisAlignedBoundingBox c0025ay = new AxisAlignedBoundingBox(ResourceLoader.getFloatArray134(meshFind, (Group) this.world), meshFind);
|
|
c0025ayArr[i] = c0025ay;
|
|
float[] fArr = c0025ay.value109;
|
|
float[] fArr2 = c0025ay.value110;
|
|
if (fArr[0] < this.worldBoundsXZ[0]) {
|
|
this.worldBoundsXZ[0] = fArr[0];
|
|
}
|
|
if (fArr[2] < this.worldBoundsXZ[1]) {
|
|
this.worldBoundsXZ[1] = fArr[2];
|
|
}
|
|
if (fArr2[0] > this.worldBoundsXZ[2]) {
|
|
this.worldBoundsXZ[2] = fArr2[0];
|
|
}
|
|
if (fArr2[2] > this.worldBoundsXZ[3]) {
|
|
this.worldBoundsXZ[3] = fArr2[2];
|
|
}
|
|
}
|
|
float[] fArr3 = this.worldBoundsXZ;
|
|
fArr3[0] = fArr3[0] - 2.0f;
|
|
float[] fArr4 = this.worldBoundsXZ;
|
|
fArr4[1] = fArr4[1] - 2.0f;
|
|
float[] fArr5 = this.worldBoundsXZ;
|
|
fArr5[2] = fArr5[2] + 2.0f;
|
|
float[] fArr6 = this.worldBoundsXZ;
|
|
fArr6[3] = fArr6[3] + 2.0f;
|
|
float f = this.worldBoundsXZ[2] - this.worldBoundsXZ[0];
|
|
this.collisionCells = new Vector[(int) Math.ceil((this.worldBoundsXZ[3] - this.worldBoundsXZ[1]) / 20.0f)][(int) Math.ceil(f / 20.0f)];
|
|
for (AxisAlignedBoundingBox c0025ay2 : c0025ayArr) {
|
|
float f2 = c0025ay2.value109[0];
|
|
float f3 = c0025ay2.value109[2];
|
|
float f4 = c0025ay2.value110[0];
|
|
float f5 = c0025ay2.value110[2];
|
|
float f6 = (f3 - this.worldBoundsXZ[1]) / 20.0f;
|
|
int iFloor = f6 < 1.0f ? 0 : (int) Math.floor(f6);
|
|
float f7 = (f2 - this.worldBoundsXZ[0]) / 20.0f;
|
|
int iFloor2 = f7 < 1.0f ? 0 : (int) Math.floor(f7);
|
|
float f8 = (f5 - this.worldBoundsXZ[1]) / 20.0f;
|
|
int iFloor3 = f8 < 1.0f ? 0 : (int) Math.floor(f8);
|
|
float f9 = (f4 - this.worldBoundsXZ[0]) / 20.0f;
|
|
int iFloor4 = f9 < 1.0f ? 0 : (int) Math.floor(f9);
|
|
for (int i2 = iFloor; i2 <= iFloor3; i2++) {
|
|
for (int i3 = iFloor2; i3 <= iFloor4; i3++) {
|
|
if (this.collisionCells[i2][i3] == null) {
|
|
this.collisionCells[i2][i3] = new Vector();
|
|
}
|
|
this.collisionCells[i2][i3].addElement(c0025ay2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: d */
|
|
public final void unloadMap() {
|
|
this.world = null;
|
|
this.worldBoundsXZ = null;
|
|
this.collisionCells = null;
|
|
this.decorations = null;
|
|
}
|
|
|
|
/* renamed from: a */
|
|
public final void setBackgroundCrop(int i, int i2) {
|
|
Background background = this.world.getBackground();
|
|
if (background != null) {
|
|
background.setImageMode(33, 32);
|
|
background.setCrop(0, (background.getImage().getHeight() - i2) / 2, i, i2);
|
|
}
|
|
}
|
|
|
|
/* renamed from: a */
|
|
public final void addMap(MapInfo c0009ai) {
|
|
this.maps.addElement(c0009ai);
|
|
}
|
|
|
|
/* renamed from: e */
|
|
public final MapInfo getCurrentMapInfo() {
|
|
return (MapInfo) this.maps.elementAt(this.currentMapIndex);
|
|
}
|
|
}
|