亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? minepanel.java

?? 用java實現(xiàn)的全真模擬windows下的掃雷程序。不過目前實現(xiàn)以button方式實現(xiàn)。改進可以考慮以位圖形式實現(xiàn)
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
        }
    }

    /**
     * 處理地雷按鈕左鍵單擊(當(dāng)釋放鼠標(biāo)左鍵時激發(fā)),踩地雷按鈕
     * 如果中雷犧牲,就處理地雷爆炸方法
     * 如果是“1”~“8”,就顯示出來
     * 如果是“0”,就處理連翻(遞歸算法)
     */
    public void treadMineButton(MineButton mb) {
        if (state != READY && state != PLAY)
            return;

        if (state == READY || state == PAUSE) {
            timer.start();
            state = PLAY;
        }

        if (mb.getIconStyle() != MineButton.ICON_NULL
                && mb.getIconStyle() != MineButton.ICON_MARK) {
            return;
        }
        // 是地雷
        if (mb.isMine()) {
            mb.setIconStyle(MineButton.ICON_MINE_EXPLODED);
            doLose();
            return;
        }

        // 不是地雷
        int aroundMines = countAroundMines(mb);
        mb.setIconStyle(aroundMines);

        // 處理連翻
        if (aroundMines == 0) {
            int h = mb.getRow();
            int w = mb.getColumn();

            if (h > 0) {
                treadMineButton(mineButton[h-1][w]);
            }
            if (h < mineRows-1) {
                treadMineButton(mineButton[h+1][w]);
            }
            if (w > 0) {
                treadMineButton(mineButton[h][w-1]);
            }
            if (w < mineColumns-1) {
                treadMineButton(mineButton[h][w+1]);
            }
            if (h > 0 && w > 0) {
                treadMineButton(mineButton[h-1][w-1]);
            }
            if (h > 0 && w < mineColumns-1) {
                treadMineButton(mineButton[h-1][w+1]);
            }
            if (h < mineRows-1 && w > 0) {
                treadMineButton(mineButton[h+1][w-1]);
            }
            if (h < mineRows-1 && w < mineColumns-1) {
                treadMineButton(mineButton[h+1][w+1]);
            }
        }  // if (aroundMines == 0)

        if (checkWinning()) {
            doWin();
        }
    }

    /**
     * 處理掃雷勝利的方法
     */
    private void doWin() {
        state = WIN;  // 勝利結(jié)束了!
        timer.stop();
        faceButton.setIconStyle(FaceButton.FACE_WIN);

        // 把有地雷的按鈕標(biāo)記上旗幟
        for (int i = 0; i < mineRows; i++) {
            for (int j = 0; j < mineColumns; j++) {
                if (mineButton[i][j].isMine()
                        && mineButton[i][j].getIconStyle() != MineButton.ICON_FLAG) {
                    mineButton[i][j].setIconStyle(MineButton.ICON_FLAG);
                }
            }
        }
        remainMines.setNumber(0);

        if (gameLevel == CUSTOM_LEVEL)
            return;

        if (JMine.mineProps.isRecordBreaker(gameLevel, totalTime.getNumber())) {
            String title = "破紀錄啦!";
            String gameLevelStr = null;
            if (gameLevel == LOW_LEVEL)
                gameLevelStr = "初";
            if (gameLevel == MIDDLE_LEVEL)
                gameLevelStr = "中";
            if (gameLevel == HIGH_LEVEL)
                gameLevelStr = "高";
            JLabel message1 = new JLabel("已破" + gameLevelStr + "級記錄。");
            JLabel message2 = new JLabel("請留尊姓大名。");
            JTextField nameField = new JTextField("佚名");
            //nameField.setText("佚名");
            // 重新設(shè)置菜單的字體
            Font font = new Font(message1.getFont().getName(), Font.PLAIN, 12);
            message1.setFont(font);
            message2.setFont(font);
            nameField.setFont(font);

            if (isSound) {
                Toolkit.getDefaultToolkit().beep();
            }
            JOptionPane.showMessageDialog(
                    this,                                           // 父組件
                    new Object[] {message1, message2, nameField},   // 顯示的信息數(shù)組
                    title,                                          // 對話框的標(biāo)題
                    JOptionPane.INFORMATION_MESSAGE                 // 信息類型
            );

            JMine.mineProps.setRecord(gameLevel, nameField.getText(), totalTime.getNumber());
            jmine.showTopListDialog();
        }
    }

    /**
     * 測試是否已經(jīng)取得掃雷任務(wù)的勝利
     */
    public boolean checkWinning() {
        for (int i = 0; i < mineRows; i++) {
            for (int j = 0; j < mineColumns; j++) {
                // 檢查是否所有沒有地雷的按鈕已全部被試探過
                if (!mineButton[i][j].isMine()) {
                    int iconStyle = mineButton[i][j].getIconStyle();
                    if (iconStyle ==MineButton.ICON_NULL
                            || iconStyle == MineButton.ICON_MARK
                            || iconStyle == MineButton.ICON_FLAG) {
                        return false;
                    }
                }
            }
        }

        return true;
    }

    /**
     * 翻開所有地雷按鈕
     */
    private void openAllMines() {
        for (int i = 0; i < mineRows; i++) {
            for (int j = 0; j < mineColumns; j++) {
                switch (mineButton[i][j].getIconStyle()) {
                    case MineButton.ICON_MARK:  // drop down
                    case MineButton.ICON_NULL:
                        if (mineButton[i][j].isMine()) {
                            mineButton[i][j].setIconStyle(MineButton.ICON_MINE_BLACK);
                        }
                        else {
                            mineButton[i][j].setIconStyle(countAroundMines(mineButton[i][j]));
                        }
                        break;
                    case MineButton.ICON_FLAG:
                        if (!mineButton[i][j].isMine()) {
                            mineButton[i][j].setIconStyle(MineButton.ICON_MINE_ERROR);
                        }
                        break;
                    default:  // ICON_M0~M8 ICON_MINE_BLACK ICON_MINE_ERROR ICON_MINE_BURST
                        break;
                }  // switch
            }  // for (j)
        }  // for (i)
    }  // openAllMines()

    /**
     * 對踩爆地雷的處理
     */
    private void doLose() {
        state = LOSE;  // 失敗結(jié)束——被地雷炸死了!
        timer.stop();
        faceButton.setIconStyle(FaceButton.FACE_LOSE);

    	if (isSound) {
    	    Toolkit.getDefaultToolkit().beep();
    	}

        // 掀開所有地雷或標(biāo)記錯誤的地雷
        for (int i = 0; i < mineRows; i++) {
            for (int j = 0; j < mineColumns; j++) {
                int iconStyle = mineButton[i][j].getIconStyle();
                boolean isMine = mineButton[i][j].isMine();
                if ((iconStyle == MineButton.ICON_NULL
                        || iconStyle == MineButton.ICON_MARK)
                        && isMine) {
                    mineButton[i][j].setIconStyle(MineButton.ICON_MINE_BLACK);
                }
                if (iconStyle == MineButton.ICON_FLAG && !isMine) {
                    mineButton[i][j].setIconStyle(MineButton.ICON_MINE_ERROR);
                }
            }  // for (j)
        }  // for (i)
    }  // openAllMines()

    /**
     * @param mb 地雷按鈕
     * @return 地雷按鈕周圍的地雷總數(shù)
     */
    private int countAroundMines(MineButton mb) {
        int h = mb.getRow();
        int w = mb.getColumn();
        int aroundMines = 0;

        if (h > 0) {
            aroundMines += (mineButton[h-1][w].isMine() ? 1 : 0);
        }
        if (h < mineRows-1) {
            aroundMines += (mineButton[h+1][w].isMine() ? 1 : 0);
        }
        if (w > 0) {
            aroundMines += (mineButton[h][w-1].isMine() ? 1 : 0);
        }
        if (w < mineColumns-1) {
            aroundMines += (mineButton[h][w+1].isMine() ? 1 : 0);
        }
        if (h > 0 && w > 0) {
            aroundMines += (mineButton[h-1][w-1].isMine() ? 1 : 0);
        }
        if (h > 0 && w < mineColumns-1) {
            aroundMines += (mineButton[h-1][w+1].isMine() ? 1 : 0);
        }
        if (h < mineRows-1 && w > 0) {
            aroundMines += (mineButton[h+1][w-1].isMine() ? 1 : 0);
        }
        if (h < mineRows-1 && w < mineColumns-1) {
            aroundMines += (mineButton[h+1][w+1].isMine() ? 1 : 0);
        }

        return aroundMines;
    }

    /**
     * @return 地雷按鈕周圍的紅旗總數(shù)
     */
    private int countAroundFlags(MineButton mb) {
        int h = mb.getRow();
        int w = mb.getColumn();
        int aroundFlags = 0;

        if (h > 0) {
            aroundFlags += (mineButton[h-1][w].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }
        if (h < mineRows-1) {
            aroundFlags += (mineButton[h+1][w].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }
        if (w > 0) {
            aroundFlags += (mineButton[h][w-1].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }
        if (w < mineColumns-1) {
            aroundFlags += (mineButton[h][w+1].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }
        if (h > 0 && w > 0) {
            aroundFlags += (mineButton[h-1][w-1].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }
        if (h > 0 && w < mineColumns-1) {
            aroundFlags += (mineButton[h-1][w+1].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }
        if (h < mineRows-1 && w > 0) {
            aroundFlags += (mineButton[h+1][w-1].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }
        if (h < mineRows-1 && w < mineColumns-1) {
            aroundFlags += (mineButton[h+1][w+1].getIconStyle() == MineButton.ICON_FLAG ? 1 : 0);
        }

        return aroundFlags;
    }

    /**
     * 使指定地雷按鈕周圍的按鈕邊框為凹入型
     * @param mb 地雷按鈕
     */
    public void doDownAround(MineButton mb) {
        int h = mb.getRow();
        int w = mb.getColumn();
        Vector vAroundMines = new Vector(8);

        if (h > 0) {
            vAroundMines.add(mineButton[h-1][w]);
        }
        if (h < mineRows-1) {
            vAroundMines.add(mineButton[h+1][w]);
        }
        if (w > 0) {
            vAroundMines.add(mineButton[h][w-1]);
        }
        if (w < mineColumns-1) {
            vAroundMines.add(mineButton[h][w+1]);
        }
        if (h > 0 && w > 0) {
            vAroundMines.add(mineButton[h-1][w-1]);
        }
        if (h > 0 && w < mineColumns-1) {
            vAroundMines.add(mineButton[h-1][w+1]);
        }
        if (h < mineRows-1 && w > 0) {
            vAroundMines.add(mineButton[h+1][w-1]);
        }
        if (h < mineRows-1 && w < mineColumns-1) {
            vAroundMines.add(mineButton[h+1][w+1]);
        }

        for (int i = 0; i < vAroundMines.size(); i++) {
            MineButton mb2 = (MineButton) vAroundMines.elementAt(i);
            if (mb2.getIconStyle() == MineButton.ICON_NULL
                    || mb2.getIconStyle() == MineButton.ICON_MARK) {
                mb2.setBorderDown();
            }
        }
        vAroundMines.clear();
    }

    /**
     * 使指定地雷按鈕周圍的按鈕邊框為凸出型
     */
    public void doUpAround(MineButton mb) {
        int h = mb.getRow();
        int w = mb.getColumn();
        Vector vAroundMines = new Vector(8);

        if (h > 0) {
            vAroundMines.add(mineButton[h-1][w]);
        }
        if (h < mineRows-1) {
            vAroundMines.add(mineButton[h+1][w]);
        }
        if (w > 0) {
            vAroundMines.add(mineButton[h][w-1]);
        }
        if (w < mineColumns-1) {
            vAroundMines.add(mineButton[h][w+1]);
        }
        if (h > 0 && w > 0) {
            vAroundMines.add(mineButton[h-1][w-1]);
        }
        if (h > 0 && w < mineColumns-1) {
            vAroundMines.add(mineButton[h-1][w+1]);
        }
        if (h < mineRows-1 && w > 0) {
            vAroundMines.add(mineButton[h+1][w-1]);
        }
        if (h < mineRows-1 && w < mineColumns-1) {
            vAroundMines.add(mineButton[h+1][w+1]);
        }

        for (int i = 0; i < vAroundMines.size(); i++) {
            MineButton mb2 = (MineButton) vAroundMines.elementAt(i);
            if (mb2.getIconStyle() == MineButton.ICON_NULL
                    || mb2.getIconStyle() == MineButton.ICON_MARK) {
                mb2.setBorderUp();
            }
        }
        vAroundMines.clear();
    }

    /**
     * 處理左右雙鈕同時釋放的鼠標(biāo)事件
     */
    public void doDoubleDownReleased(MineButton mb) {
        int iconStyle = mb.getIconStyle();
        int h = mb.getRow();
        int w = mb.getColumn();
        Vector vAroundMines = new Vector(8);

        if (h > 0) {
            vAroundMines.add(mineButton[h-1][w]);
        }
        if (h < mineRows-1) {
            vAroundMines.add(mineButton[h+1][w]);
        }
        if (w > 0) {
            vAroundMines.add(mineButton[h][w-1]);
        }
        if (w < mineColumns-1) {
            vAroundMines.add(mineButton[h][w+1]);
        }
        if (h > 0 && w > 0) {
            vAroundMines.add(mineButton[h-1][w-1]);
        }
        if (h > 0 && w < mineColumns-1) {
            vAroundMines.add(mineButton[h-1][w+1]);
        }
        if (h < mineRows-1 && w > 0) {
            vAroundMines.add(mineButton[h+1][w-1]);
        }
        if (h < mineRows-1 && w < mineColumns-1) {
            vAroundMines.add(mineButton[h+1][w+1]);
        }

        if (iconStyle >= MineButton.ICON_M0 && iconStyle <= MineButton.ICON_M8
                && countAroundMines(mb) == countAroundFlags(mb)) {
            for (int i = 0; i < vAroundMines.size(); i++) {
                // 按下周圍的各個按鈕
                treadMineButton((MineButton) vAroundMines.elementAt(i));
            }
        }
        else {
            if (mb.getIconStyle() == MineButton.ICON_NULL
                    || mb.getIconStyle() == MineButton.ICON_MARK) {
                mb.setBorderUp();// 凸起本按鈕
            }
            doUpAround(mb); // 凸起周圍的各個按鈕
        }
        vAroundMines.clear();
    }  // doDoubleDownReleased()

    /**
     * 時鐘暫停計時
     */
    public void pause() {
        if (state == PLAY) {
            timer.stop();
            state = PAUSE;
        }
    }

    /**
     * 時鐘繼續(xù)計時
     */
    public void resume() {
        if (state == PAUSE) {
            timer.start();
            state = PLAY;
        }
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产午夜精品久久| 91在线无精精品入口| 欧美精品欧美精品系列| 亚洲高清在线视频| 欧洲精品一区二区三区在线观看| 国产精品国产三级国产普通话99| av亚洲精华国产精华精华| 国产精品剧情在线亚洲| www.日韩av| 国产精品毛片高清在线完整版| 韩国一区二区在线观看| 日韩精品中文字幕一区| 男人的天堂亚洲一区| 日韩一级黄色大片| 狠狠色伊人亚洲综合成人| 久久久久久久久久看片| 北条麻妃一区二区三区| 亚洲精品国产第一综合99久久| 91免费观看在线| 亚洲一区自拍偷拍| 欧美色图天堂网| 日韩黄色片在线观看| 久久免费看少妇高潮| 懂色一区二区三区免费观看| 国产精品动漫网站| 成人黄色在线看| 亚洲免费av在线| 欧美精品一二三| 九一九一国产精品| 国产精品美女久久久久aⅴ| 97国产一区二区| 免费在线观看一区| 国产三级欧美三级日产三级99 | 日韩精品一区二区三区视频在线观看| 性做久久久久久免费观看 | 成人短视频下载| 亚洲福利电影网| 精品国产乱码久久久久久影片| 国产91富婆露脸刺激对白| 午夜精品福利一区二区三区av| 久久免费美女视频| 91成人看片片| 国产成人a级片| 午夜视频一区二区三区| 久久色中文字幕| 欧美日韩你懂得| 国内精品国产三级国产a久久 | 一区二区三区在线不卡| 91精品国产欧美一区二区18| 粉嫩av一区二区三区| 美女视频黄久久| 亚洲丝袜美腿综合| 精品少妇一区二区三区视频免付费 | 国产精品乡下勾搭老头1| 一卡二卡欧美日韩| 久久精品一区二区三区四区| 在线视频观看一区| www.欧美亚洲| 日本视频在线一区| 亚洲男帅同性gay1069| 国产午夜精品一区二区| 欧美精品自拍偷拍| 94-欧美-setu| 北条麻妃一区二区三区| 国产在线麻豆精品观看| 亚洲一区二区偷拍精品| 亚洲免费观看高清| 亚洲国产成人一区二区三区| 一本色道久久加勒比精品| 粉嫩久久99精品久久久久久夜| 日本中文字幕一区| 亚洲自拍偷拍图区| 一区二区三区在线视频观看| 国产人妖乱国产精品人妖| 在线一区二区三区四区| 色伊人久久综合中文字幕| 成人午夜又粗又硬又大| 韩国一区二区三区| 国产麻豆9l精品三级站| 激情综合网激情| 日韩高清在线一区| 水蜜桃久久夜色精品一区的特点| 亚洲精品高清在线| 亚洲免费观看高清完整版在线| 中文字幕av不卡| 久久五月婷婷丁香社区| 欧美成人精品1314www| 欧美日韩国产一二三| 欧美性猛交xxxx黑人交| 色88888久久久久久影院按摩| 91网站最新地址| av一本久道久久综合久久鬼色| 粉嫩在线一区二区三区视频| 波多野结衣亚洲一区| 波多野洁衣一区| k8久久久一区二区三区 | 成人国产精品免费观看动漫| 免费看欧美女人艹b| 秋霞午夜鲁丝一区二区老狼| 日韩和的一区二区| 亚洲三级免费电影| 中文字幕一区二区三区在线不卡| 亚洲欧美偷拍另类a∨色屁股| 日韩毛片一二三区| 精品成a人在线观看| 国产日产亚洲精品系列| 中文字幕精品一区二区三区精品| 亚洲三级免费观看| 洋洋成人永久网站入口| 一区二区三区欧美亚洲| 日本在线不卡视频一二三区| 久久精品国产一区二区| 婷婷开心久久网| 国产精品99久久久久久久女警| 国产盗摄一区二区| 色成年激情久久综合| 538在线一区二区精品国产| 日韩一区二区麻豆国产| 国产精品麻豆网站| 亚洲午夜在线电影| 久久激情五月激情| 成人激情免费电影网址| 在线免费不卡视频| 欧美二区乱c少妇| 中文字幕制服丝袜一区二区三区 | 正在播放亚洲一区| 久久久久久久久久久久久夜| 久久精品人人爽人人爽| 一区二区三区中文在线| 激情综合一区二区三区| 99国产精品久久久久久久久久久| 成人黄色软件下载| 精品国精品国产| 亚洲欧美日韩电影| 国产乱子伦一区二区三区国色天香| 99视频精品全部免费在线| 欧美日韩视频在线一区二区| 欧美经典一区二区| 亚洲高清免费在线| 国产精品一区二区在线观看网站| 欧美日韩一区二区三区不卡 | 91麻豆精品国产91| 国产精品国产精品国产专区不蜜| 日本午夜一本久久久综合| 国产九色精品成人porny| 成人免费高清视频| 2021中文字幕一区亚洲| 一区二区三区电影在线播| 午夜精品一区二区三区免费视频| 国产精品一区二区三区99| 色激情天天射综合网| 国产精品国产三级国产aⅴ无密码| 麻豆中文一区二区| 色悠悠久久综合| 亚洲欧美在线视频观看| 韩国毛片一区二区三区| 91小视频免费观看| 国产精品第13页| 久久er99热精品一区二区| 一本色道综合亚洲| 国产精品久久久久三级| 国精产品一区一区三区mba桃花| 欧美日韩国产影片| 一区二区三区免费在线观看| 粉嫩绯色av一区二区在线观看| 久久人人超碰精品| 美女视频一区二区| 色综合咪咪久久| 亚洲精品高清在线| 99精品1区2区| 亚洲免费观看在线视频| 成人一道本在线| 欧美精品一区视频| 国产在线一区观看| 日韩精品在线看片z| 国产精品福利在线播放| 一本一道波多野结衣一区二区| 国产精品毛片无遮挡高清| 成人亚洲精品久久久久软件| 精品国产91乱码一区二区三区| 久久国产精品无码网站| 日韩久久久精品| 美脚の诱脚舐め脚责91 | 日韩欧美高清dvd碟片| 久久69国产一区二区蜜臀| 久久婷婷综合激情| 国产乱子轮精品视频| 国产精品私人自拍| 91麻豆国产精品久久| 亚洲主播在线观看| 6080日韩午夜伦伦午夜伦| 国内精品嫩模私拍在线| 国产精品久久国产精麻豆99网站 | 亚洲成国产人片在线观看| 欧美一级欧美一级在线播放| 久久精品国产精品亚洲精品| 国产午夜亚洲精品理论片色戒| 成人激情小说乱人伦| 天天影视涩香欲综合网| 精品国产a毛片|