📄 attack.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
package org.cesar.inmotion.sea;
import java.util.Random;
import javax.microedition.lcdui.Image;
import org.cesar.inmotion.sea.basic.Fish;
import org.cesar.inmotion.util.GameItem;
import org.cesar.inmotion.util.ObjectSet;
// Referenced classes of package org.cesar.inmotion.sea:
// GameCanvas, Constants
public class Attack
{
private boolean active;
private byte maxitems;
private byte space;
private ObjectSet sharks;
private ObjectSet fishes;
private final byte margin = 45;
private byte fish_random_factor;
private byte shark_random_factor;
public Attack()
{
active = false;
fish_random_factor = 3;
shark_random_factor = 5;
init();
}
public Fish getShark(byte byte0)
{
return (Fish)sharks.getByIndex(byte0);
}
public Fish getFish(byte byte0)
{
return (Fish)fishes.getByIndex(byte0);
}
public byte getSharkCount()
{
return (byte)sharks.size();
}
public void init()
{
active = true;
if(sharks == null || sharks.isEmpty())
{
maxitems = (byte)((GameCanvas.ScreenHeight - 17 - GameCanvas.SurfaceY) / (Constants.img_diver[0][0].getHeight() * 2));
sharks = new ObjectSet(maxitems);
fishes = new ObjectSet(maxitems);
for(int i = 0; i < maxitems; i++)
{
sharks.add(new Fish(Constants.img_shark, (byte)1));
fishes.add(new Fish(Constants.img_fish, (byte)1));
}
}
boot();
}
public void boot()
{
Random random = new Random();
for(int i = 0; i < maxitems; i++)
{
Fish fish1 = (Fish)sharks.getByIndex(i);
fish1.setVisible(true);
fish1.ressurect();
fish1.setXspeed(3);
Fish fish = (Fish)fishes.getByIndex(i);
fish.setVisible(true);
fish.ressurect();
fish.setXspeed(2);
byte byte0 = (byte)(random.nextInt() % shark_random_factor);
byte byte1 = (byte)(random.nextInt() % fish_random_factor);
if(byte0 < 0)
fish1.setDirection((byte)-1);
else
if(byte0 > 0)
fish1.setDirection((byte)1);
else
fish1.setDirection((byte)0);
if(byte1 < 0)
fish.setDirection((byte)-1);
else
if(byte1 > 0)
fish.setDirection((byte)1);
else
fish.setDirection((byte)0);
if(fish1.getDirection() == 1)
fish1.setX(-45 + (Math.abs(random.nextInt() % 45) - fish1.getImage().getWidth()));
else
fish1.setX(GameCanvas.ScreenWidth + (Math.abs(random.nextInt() % 45) - fish1.getImage().getWidth()));
if(fish.getDirection() == 1)
{
fish.setX(-45 + (Math.abs(random.nextInt() % 45) - fish.getImage().getWidth()));
if(fish.intersects(fish1))
fish.setX(fish1.getX() + fish1.getImage().getWidth() + fish.getImage().getWidth());
} else
{
fish.setX(GameCanvas.ScreenWidth + 10 + (Math.abs(random.nextInt() % 45) - fish.getImage().getWidth()));
if(fish.intersects(fish1))
fish.setX(fish1.getX() - fish.getImage().getWidth());
}
fish1.setY(GameCanvas.SurfaceY + Constants.img_diver_surface[0].getHeight() + 2 * i * Constants.img_diver[0][0].getHeight());
fish.setY(fish1.getY());
}
}
public void update()
{
active = false;
for(int i = 0; i < maxitems; i++)
{
Fish fish = (Fish)sharks.getByIndex(i);
Fish fish1 = (Fish)fishes.getByIndex(i);
fish.update();
fish1.update();
if(fish.isVisible() || fish1.isVisible())
active = true;
if(!fish.isDead())
{
if(fish.intersects(fish1))
{
fish1.setDirection(fish.getDirection());
fish1.setXspeed(fish.getXspeed());
}
} else
{
fish1.setXspeed(2);
}
}
}
public boolean isActive()
{
return active;
}
public void setLevel(byte byte0)
{
for(int i = 0; i < maxitems; i++)
{
sharks.getByIndex(i).setXspeed(byte0);
fish_random_factor--;
shark_random_factor += 2;
}
}
public void setActive(boolean flag)
{
active = flag;
}
public byte getMaxitems()
{
return maxitems;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -