⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enemy.java

📁 一个很不错的炸弹人J2ME游戏源码.画面及音效质量都不错,可供新手学习使用.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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 bombjack;

import gamelib.GameObject;
import java.util.Random;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

// Referenced classes of package bombjack:
//            ImageLoader, Player

public class Enemy extends GameObject
{

    public static final int POWERPOINTS[] = {
        100, 200, 300, 500, 800, 1200, 2000
    };
    public static final byte MAXROBOTFACTORIES = 2;
    public static final byte ENEMY_ROBOT = 10;
    public static final byte ENEMY_BIRD = 11;
    public static final byte ENEMY_HAT = 12;
    public static final byte ENEMY_BALL = 13;
    public static final byte ENEMY_ANTENNA = 14;
    public static final byte ENEMY_BALL2 = 15;
    public static final byte ENEMY_UFO = 16;
    public static final byte POWERBALL = 97;
    public static final byte BCOIN = 98;
    public static final byte ECOIN = 99;
    private static final Image smileyImage = ImageLoader.getImage(11);
    private static final Image appearImage = ImageLoader.getImage(4);
    public byte type;
    public int points;
    public byte powertype;
    protected byte direction;
    public boolean active;
    private int animCount;
    private Image animImage;
    protected int anim[][];
    public int destinationX;
    public int destinationY;
    public int speedX;
    public int speedY;
    public int calcX;
    public int calcY;
    public int latencyX;
    public int latencyY;
    public int cyclecount;
    public int cyclesToRevision;
    public int turnCount;
    public byte factory;
    public short ID;
    public boolean transformToUfo;
    public static byte gridX[] = new byte[2];
    public static byte gridY[] = new byte[2];
    public static byte maxRobots[] = new byte[2];
    public static byte producedRobots[] = new byte[2];
    public static int productionCycle[] = new int[2];
    public static int cycleCounter[] = new int[2];
    public static byte robotTurns[] = new byte[2];
    public static int wait[] = new int[2];
    private static Random random = new Random();
    private static Enemy allEnemies[];

    private Enemy()
    {
        super(0, 0);
        points = 100;
        powertype = 1;
        direction = 2;
        active = false;
        animCount = 0;
        speedX = 200;
        speedY = 0;
        cyclecount = 0;
        cyclesToRevision = 5;
        turnCount = 0;
        transformToUfo = false;
    }

    public static void freeAll()
    {
        for(int i = 0; i < allEnemies.length; i++)
            allEnemies[i].active = false;

    }

    public static void addRobotFactory(int i, byte byte0, byte byte1, byte byte2, int j, byte byte3, int k)
    {
        if(i > 1)
            return;
        gridX[i] = byte0;
        gridY[i] = byte1;
        maxRobots[i] = byte2;
        if(maxRobots[i] > 4)
            maxRobots[i] = 4;
        if(i > 0)
        {
            maxRobots[i] = 2;
            if(maxRobots[0] > 3)
                maxRobots[0] = 3;
        }
        producedRobots[i] = 0;
        productionCycle[i] = j + 13;
        cycleCounter[i] = j;
        robotTurns[i] = byte3;
        wait[i] = k;
    }

    public static void resetRobotFactories()
    {
        for(int i = 0; i < 2; i++)
        {
            cycleCounter[i] = productionCycle[i] - wait[i];
            producedRobots[i] = 0;
        }

    }

    public static Enemy getEnemy()
    {
        for(int i = 0; i < allEnemies.length; i++)
            if(!allEnemies[i].active)
            {
                allEnemies[i].active = true;
                return allEnemies[i];
            }

        return null;
    }

    public static Enemy produceRobot(byte byte0)
    {
        if(++cycleCounter[byte0] >= productionCycle[byte0] && producedRobots[byte0] < maxRobots[byte0])
        {
            cycleCounter[byte0] = 0;
            producedRobots[byte0]++;
            for(int i = 0; i < allEnemies.length; i++)
                if(!allEnemies[i].active)
                {
                    allEnemies[i].init((byte)10, gridX[byte0] * 5, gridY[byte0] * 7, ImageLoader.getImage(1), -1);
                    allEnemies[i].factory = byte0;
                    allEnemies[i].cyclesToRevision = robotTurns[byte0];
                    allEnemies[i].cyclecount = 0;
                    allEnemies[i].speedX = 100;
                    allEnemies[i].speedY = 0;
                    allEnemies[i].transformToUfo = false;
                    if(producedRobots == maxRobots)
                        allEnemies[i].transformToUfo = true;
                    else
                    if((random.nextInt() % 100) * 2 > 100)
                        allEnemies[i].transformToUfo = true;
                    allEnemies[i].active = true;
                    return allEnemies[i];
                }

        }
        return null;
    }

    public void init(byte byte0, int i, int j, Image image, int k)
    {
        x = i;
        y = j;
        points = 100;
        powertype = 1;
        direction = 2;
        animCount = 0;
        speedX = 200;
        speedY = 0;
        cyclecount = 0;
        cyclesToRevision = 5;
        turnCount = 0;
        type = byte0;
        mode = 6;
        ID = (short)k;
        isDying = false;
        transformToUfo = false;
        destinationX = i;
        destinationY = j;
        calcX = i * 100;
        calcY = j * 100;
        animImage = image;
        if(byte0 == 10)
        {
            width = 12;
            height = 14;
            anim = new int[5][];
            anim[0] = (new int[] {
                5, 5, 6, 6, 7, 7
            });
            anim[1] = (new int[] {
                2, 2, 3, 3, 4, 4
            });
            anim[2] = (new int[] {
                0
            });
            anim[4] = (new int[] {
                1
            });
            anim[3] = (new int[] {
                1
            });
            direction = 1;
        } else
        if(byte0 == 12)
        {
            width = 12;
            height = 12;
            anim = new int[5][];
            anim[0] = (new int[] {
                4, 4, 5, 5, 6, 6, 7, 7
            });
            anim[1] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3
            });
            anim[2] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3
            });
            anim[4] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3
            });
            anim[3] = (new int[] {
                4, 4, 5, 5, 6, 6, 7, 7
            });
            direction = 1;
            mode = 5;
        } else
        if(byte0 == 13)
        {
            width = 12;
            height = 12;
            anim = new int[5][];
            anim[0] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5, 6, 6, 7, 7, 8, 8
            });
            anim[1] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5, 6, 6, 7, 7, 8, 8
            });
            anim[2] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5, 6, 6, 7, 7, 8, 8
            });
            anim[4] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5, 6, 6, 7, 7, 8, 8
            });
            anim[3] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5, 6, 6, 7, 7, 8, 8
            });
            direction = 1;
            mode = 5;
            speedX = 100;
            speedY = -100;
        } else
        if(byte0 == 15)
        {
            width = 11;
            height = 11;
            anim = new int[5][];
            anim[0] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5
            });
            anim[1] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5
            });
            anim[2] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5
            });
            anim[4] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5
            });
            anim[3] = (new int[] {
                0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 
                5, 5
            });
            direction = 0;
            mode = 5;
            speedX = -110;
            speedY = 130;
        } else
        if(byte0 == 14)
        {
            width = 12;
            height = 12;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -