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

📄 seafox.java

📁 经典的潜艇打商船游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            }
            double d3 = 10D + (15D * (double)(Seafox.m_lLatestTime - m_lTimeStatusUpdated)) / 500D;
            int i = 0;
            do
                Seafox.m_magneticMine[i].CollisionAnalysis(m_dX, m_dY, d3);
            while(++i < 3);
        }
    }

    public void Detonate() {
        m_nStatus = 4;
        m_lTimeStatusUpdated = Seafox.m_lLatestTime;
        Seafox.m_bPlayBigExplosion = true;
    }

    public boolean Detonate(double d, double d1) {
        if(m_nStatus == 3) {
            double d2 = 6D;
            if(d >= m_dX - d2 && d <= m_dX + d2 && d1 >= m_dY - d2 && d1 <= m_dY + d2) {
                Detonate();
                return true;
            }
        }
        return false;
    }

    public boolean Detonate(double d, double d1, double d2, double d3) {
        if(m_nStatus == 4)
            return CollisionAnalysis(d, d1, d2, d3);
        if(m_nStatus == 3) {
            double d4 = 6D;
            if(d2 >= m_dX - d4 && d <= m_dX + d4 && d3 >= m_dY - d4 && d1 <= m_dY + d4) {
                Detonate();
                return true;
            }
        }
        return false;
    }

}

class Destroyer {

    public static Image m_imageShip;
    public static double m_dShipWidth;
    public static int m_nShipHeight;
    public static final int Y_WATERLINE = 55;
    public static final int WAKE_IMAGES = 4;
    public static Image m_imageWake[] = new Image[4];
    public static int m_nWakeWidth;
    public static int m_nWakeHeight;
    public static final int MAX_SHIPS = 3;
    public static int m_nShipLimit;
    public static int m_nActiveShips;
    static final int MIN_LAUNCH_INTERVAL = 10000;
    static final int MAX_LAUNCH_INTERVAL = 15000;
    public static long m_lTimeNextLaunch;
    public static final double MIN_VELOCITY = 19D;
    public static final double MAX_VELOCITY = 21D;
    public static final int POINTS_FOR_SINKING = 250;
    static final double LEFT_CHARGE_MARGIN = 0D;
    static final double RIGHT_CHARGE_MARGIN = 40D;
    public int m_nStatus;
    static final int NORMAL = 0;
    static final int EXPLODING = 1;
    static final int SINKING = 2;
    static final int SCORING = 3;
    public static final int INACTIVE = 4;
    long m_lTimeStatusUpdated;
    long m_lTimeDepthCharge;
    DepthCharge m_depthCharge;
    double m_dXlaunch;
    public double m_dX;
    double m_dY;
    double m_dVelocity;

    public void Draw(Graphics g) {
        boolean flag = false;
        boolean flag1 = false;
        Object obj = null;
        if(m_nStatus == 4)
            return;
        if(m_nStatus == 0 || m_nStatus == 1) {
            int i = (int)(m_dX + 0.5D);
            int l = (int)m_dY;
            g.drawImage(m_imageShip, i, l, null);
            if(m_nStatus == 0) {
                i += (int)m_dShipWidth - 4;
                l = 53;
                Image image = m_imageWake[(Seafox.m_random.nextInt() & 0x7fffffff) % 4];
                g.drawImage(image, i, l, null);
                return;
            } else {
                Image image1 = CapitalShip.m_imageBlast[(Seafox.m_random.nextInt() & 0x7fffffff) % 4];
                i += ((int)m_dShipWidth - image1.getWidth(null)) / 2;
                l += (m_nShipHeight - image1.getHeight(null)) / 2;
                g.drawImage(image1, i, l, null);
                return;
            }
        }
        if(m_nStatus == 2) {
            int j1 = ((int)(Seafox.m_lLatestTime - m_lTimeStatusUpdated) * 4) / 999;
            Image image2 = CapitalShip.m_imageSink[j1];
            int j = (int)m_dX + ((int)m_dShipWidth - image2.getWidth(null)) / 2;
            int i1 = 55 - image2.getHeight(null);
            g.drawImage(image2, j, i1, null);
            return;
        }
        if(m_nStatus == 3) {
            g.setFont(Seafox.m_fontScorePopup);
            g.setColor(Color.yellow);
            String s = new String("" + 250);
            int k = (int)m_dX + 10;
            g.drawString(s, k, 55);
        }
    }

    public void Launch() {
        m_nStatus = 0;
        m_lTimeStatusUpdated = Seafox.m_lLatestTime;
        m_nActiveShips++;
        m_dXlaunch = Seafox.m_nPlayfieldWidth;
        m_dX = m_dXlaunch;
        m_dY = 55 - m_nShipHeight;
        m_dVelocity = -(19D + 2D * Seafox.m_random.nextDouble());
        m_lTimeNextLaunch = m_lTimeStatusUpdated + 10000L + (long)(5000D * Seafox.m_random.nextDouble());
        m_lTimeDepthCharge = 0L;
        m_depthCharge = null;
    }

    public boolean CollisionAnalysis(double d, double d1) {
        if(m_nStatus == 0 && d1 <= 55D && d1 >= 45D && d >= m_dX + 5D && d <= (m_dX + m_dShipWidth) - 5D) {
            m_nStatus = 1;
            m_lTimeStatusUpdated = Seafox.m_lLatestTime;
            Seafox.m_nScore += 250;
            Seafox.m_bPlayBigExplosion = true;
            if(m_depthCharge != null && m_depthCharge.m_nStatus == 1 && m_depthCharge.m_destroyer.m_dX == m_dX)
                m_depthCharge.Detonate();
            return true;
        } else {
            return false;
        }
    }

    public void Update() {
        if(m_nStatus == 4) {
            if(m_nActiveShips < m_nShipLimit && Seafox.m_lLatestTime >= m_lTimeNextLaunch)
                Launch();
            return;
        }
        if(m_nStatus == 0) {
            m_dX = m_dXlaunch + (m_dVelocity * (double)(Seafox.m_lLatestTime - m_lTimeStatusUpdated)) / 1000D;
            if(m_dX < -(m_dShipWidth + (double)m_nWakeWidth)) {
                m_nStatus = 4;
                m_nActiveShips--;
                m_lTimeStatusUpdated = Seafox.m_lLatestTime;
            }
            if(m_dX >= 0.0D && m_dX <= (double)Seafox.m_nPlayfieldWidth - m_dShipWidth - 40D && Seafox.m_lLatestTime >= m_lTimeDepthCharge && DepthCharge.m_nActiveCharges < DepthCharge.m_nChargeLimit) {
                int i = 0;
                for(i = 0; Seafox.m_depthCharge[i].m_nStatus != 0 && ++i < 3;);
                if(i < 3) {
                    m_depthCharge = Seafox.m_depthCharge[i];
                    m_lTimeDepthCharge = Seafox.m_lLatestTime + 6000L + (long)(Seafox.m_random.nextDouble() * 2000D);
                    m_depthCharge.Launch(this);
                }
            }
            return;
        }
        if(m_nStatus == 1) {
            if((int)(Seafox.m_lLatestTime - m_lTimeStatusUpdated) >= 500) {
                m_nStatus = 2;
                m_lTimeStatusUpdated = Seafox.m_lLatestTime;
            }
            return;
        }
        if(m_nStatus == 2) {
            if((int)(Seafox.m_lLatestTime - m_lTimeStatusUpdated) >= 999) {
                m_nStatus = 3;
                m_lTimeStatusUpdated = Seafox.m_lLatestTime;
            }
            return;
        }
        if(m_nStatus == 3) {
            if((int)(Seafox.m_lLatestTime - m_lTimeStatusUpdated) >= 999) {
                m_nStatus = 4;
                m_nActiveShips--;
                m_lTimeStatusUpdated = Seafox.m_lLatestTime;
            }
            return;
        } else {
            return;
        }
    }

    Destroyer() {
    }

}

class Dolphin {

    public static final int IMAGES = 4;
    public static Image m_imageDolphin[] = new Image[4];
    public static double m_dImageWidth;
    static final double X_VELOCITY = 20D;
    static final double Y_VELOCITY = -8D;
    static final int FREQUENCY = 100;
    double m_dXrelease;
    double m_dYrelease;
    long m_lReleaseTime;
    public boolean m_bActive;
    public double m_dX;
    public double m_dY;
    int m_ndxImage;

    public void Draw(Graphics g) {
        if(!m_bActive) {
            return;
        } else {
            int i = (int)(m_dX + 0.5D);
            int j = (int)(m_dY + 0.5D);
            g.drawImage(m_imageDolphin[m_ndxImage], i, j, null);
            return;
        }
    }

    public void Release(SupplySub supplysub) {
        m_dXrelease = supplysub.m_dX + 10D;
        m_dYrelease = SupplySub.m_dY;
        m_lReleaseTime = Seafox.m_lLatestTime;
        m_bActive = true;
        m_dX = m_dXrelease;
        m_dY = m_dYrelease;
        m_ndxImage = 0;
        Seafox.m_package.m_nStatus = 0;
    }

    public boolean CollisionAnalysis(double d, double d1) {
        if(!m_bActive)
            return false;
        double d2 = 0.0D;
        switch(m_ndxImage) {
        case 0: // '\0'
            d2 = 0.0D;
            break;

        case 1: // '\001'
            d2 = 2D;
            break;

        case 2: // '\002'
            d2 = 4D;
            break;

        case 3: // '\003'
            d2 = 6D;
            break;
        }
        if(d >= m_dX && d <= m_dX + m_dImageWidth && d1 >= m_dY + d2 && d1 <= m_dY + (double)m_imageDolphin[m_ndxImage].getHeight(null)) {
            m_bActive = false;
            Seafox.m_package.StartFalling();
            return true;
        } else {
            return false;
        }
    }

    Dolphin() {
    }

    public void Update() {
        if(!m_bActive)
            return;
        int i = (int)(Seafox.m_lLatestTime - m_lReleaseTime);
        m_dX = m_dXrelease + (20D * (double)i) / 1000D;
        m_dY = m_dYrelease + (-8D * (double)i) / 1000D;
        if(m_dX >= (double)Seafox.m_nPlayfieldWidth) {
            m_bActive = false;
            return;
        }
        int j = (i / 100) % 6;
        switch(j) {
        case 0: // '\0'
            m_ndxImage = 0;
            break;

        case 1: // '\001'
            m_ndxImage = 1;
            break;

        case 2: // '\002'
            m_ndxImage = 2;
            break;

        case 3: // '\003'
            m_ndxImage = 3;
            break;

        case 4: // '\004'
            m_ndxImage = 2;
            break;

        case 5: // '\005'
            m_ndxImage = 1;
            break;
        }
        double d = m_dY;
        double d1 = m_dY + (double)m_imageDolphin[m_ndxImage].getWidth(null);
        switch(m_ndxImage) {
        case 1: // '\001'
            d += 2D;
            break;

        case 2: // '\002'
            d += 4D;
            break;

        case 3: // '\003'
            d += 6D;
            break;
        }
        int k = 0;
        do
            if(Seafox.m_depthCharge[k].CollisionAnalysis(m_dX, d, m_dX + m_dImageWidth, d1)) {
                m_bActive = false;
                

⌨️ 快捷键说明

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