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

📄 netintruderutility.java

📁 斜45度游戏《NetIntruder》
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            introFrames.put("1", "/introBW/1.png");            introFrames.put("2", "/introBW/2.png");            introFrames.put("3", "/introBW/3.png");            introFrames.put("4", "/introBW/4.png");                        introFrames.put("11", "/introBW/chair1.png");            introFrames.put("13", "/introBW/chair2.png");            introFrames.put("14", "/introBW/chair3.png");            introFrames.put("15", "/introBW/flux.png");            introFrames.put("20", "/introBW/smoke2.png");            introFrames.put("21", "/introBW/smoke1.png");            introFrames.put("22", "/introBW/smoke2.png");            introFrames.put("23", "/introBW/smoke1.png");            introFrames.put("24", "/introBW/smoke2.png");            introFrames.put("25", "/introBW/smoke1.png");            introFrames.put("26", "/introBW/smoke2.png");            introFrames.put("27", "/introBW/smoke1.png");            introFrames.put("28", "/introBW/smoke2.png");            introFrames.put("29", "/introBW/smoke1.png");            introFrames.put("30", "/introBW/smoke1.png");            introFrames.put("31", "/introBW/hand.png");            introFrames.put("40", "/introBW/flux.png");            introFrames.put("49", "/introBW/smoke1.png");            introFrames.put("50", "/introBW/smoke2.png");            introFrames.put("51", "/introBW/smoke1.png");            introFrames.put("52", "/introBW/smoke2.png");            introFrames.put("53", "/introBW/smoke1.png");            introFrames.put("54", "/introBW/smoke2.png");            introFrames.put("55", "/introBW/smoke1.png");            introFrames.put("56", "/introBW/smoke2.png");            introFrames.put("57", "/introBW/access.png");            introFrames.put("69", "/introBW/logo.png");            introFrames.put("79", "stop");            //introSpeech.put("5", "test...");            introSpeech                    .put("11", "L'hacking e' l'arte di risolvere problemi...");            introSpeech.put("15", "");            introSpeech.put("18", "...in modo brillante ed originale!");            introSpeech.put("22", "");            introSpeech.put("25",                    "L'hacking e' quindi una metafora della vita.");            introSpeech.put("38", "");            introSpeech.put("42", "Beh...");            introSpeech.put("48", "");            introSpeech.put("51", "Questo gioco e' una metafora...");            introSpeech.put("56", "");            introSpeech.put("57", "...dell'essere hacker!");            introSpeech.put("62", "");        }        if (currentTimeLast < (System.currentTimeMillis() - timer) / 500) {            currentTimeLast = (System.currentTimeMillis() - timer) / 500;//#ifdef nokia//#            if (currentTimeLast == introFrames.size() / 2) {//#                com.nokia.mid.ui.DeviceControl.setLights(0, 100); //TODO nokia light//#            }//#endif            if (introFrames.containsKey(currentTimeLast + "")) {                if ("stop".equals(introFrames.get(currentTimeLast + ""))) {                    canvas.gamePhase++;                    return;                }                paintBackground(g);                try {                    Image temp = Image.createImage((String) introFrames                            .get(currentTimeLast + ""));                    g.drawImage(temp, g.getClipWidth() / 2, canvas.getHeight()                            / 2 - temp.getHeight() / 2, Graphics.TOP                            | Graphics.HCENTER);                } catch (IOException e) {                                    }            }            if (introSpeech.containsKey(currentTimeLast + "")) {                introPhrase = (String) introSpeech.get(currentTimeLast + "");            }            paintIntroSpeech(g);        }    }    private void paintIntroSpeech(Graphics g) {        if (!"".equals(introPhrase)) {            g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD,                    Font.SIZE_SMALL));            paintMessageBox(g, introPhrase, g.getClipWidth() / 2, canvas                    .getHeight(), g.getClipWidth() - 6, 0x000000, 0xffffff,                    0xff0000, 0xcc0000);        }    }    private int paintMessageBox(Graphics g, String message, int xText,            int yText, int widthText, int borderColor, int backgroundColor,            int fontPrimaryColor, int fontSecondary) {        Vector list = divideString(message, widthText, g.getFont());        int fontHeight = g.getFont().getHeight() + 1;        g.setColor(backgroundColor);        int heightText = list.size() * fontHeight + 4;        if (yText + heightText / 2 > canvas.getHeight()) {            yText = canvas.getHeight() - heightText / 2;        }        g.fillRect(xText - widthText / 2, yText - heightText / 2, widthText,                heightText);        g.setColor(borderColor);        g.drawRect(xText - widthText / 2, yText - heightText / 2, widthText,                heightText);        g.setColor(fontPrimaryColor);        xText += 2;        yText += 2;        for (int i = 0; i < list.size(); i++) {            g.drawString(list.elementAt(i).toString(), xText - widthText / 2,                    yText - heightText / 2 + (i * fontHeight), Graphics.TOP                            | Graphics.LEFT);        }        return (list.size() - 1) * fontHeight;    }    public void paintPuzzle(Graphics g) {        if (puzzlePasswordsTotal <= puzzlePasswordsFound) {            canMove = true;            canvas.gamePhase = 3;            return; // Win        }                 if (!puzzleStarted) {// Init Puzzle            puzzleStarted = true;            puzzleMark = 0xcccccc;            puzzleArray = puzzleArrayEmpty;            puzzleTimer = System.currentTimeMillis();            g.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());            g.setColor(0xffffff);            g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD,                    Font.SIZE_SMALL));            g.drawString(msg[3], 10, 5, Graphics.TOP | Graphics.LEFT);            g.setColor(0xffffff);            g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD,                    Font.SIZE_SMALL));            g                    .drawString(                            msg[4]                                    + (100 / puzzlePasswordsTotal * puzzlePasswordsFound)                                    + "%", canvas.getWidth() - 10, canvas                                    .getHeight() / 6 * 5, Graphics.TOP                                    | Graphics.RIGHT);        } else {            if (System.currentTimeMillis() - puzzleTimer > puzzleSpeed) {                puzzleVerified = false;                puzzleTimer = System.currentTimeMillis();                puzzleMark = 0xcccccc;                runPuzzle();                if (puzzlePasswordsFound < 0) {//                  canvas.gamePhase = 3;//                  canMove = false;                  puzzlePasswordsFound = 0;//                  return;// Loose              }                                g.setColor(0x000000);                g.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());                g.setColor(0xffffff);                g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD,                        Font.SIZE_SMALL));                g.drawString(msg[3], 10, 5, Graphics.TOP | Graphics.LEFT);                for (int i = 0; i < 4; i++) {                    g.setColor(0x006600);                    g.drawLine(0, canvas.getHeight() / 6 * (i + 1), canvas                            .getWidth(), canvas.getHeight() / 6 * (i + 1));                    g.setColor(0x00cc00);                    if (puzzleArray[i].indexOf("---  CHECKED  ---") > 0) {                        g.setColor(0xff0000);                    }                    g.setFont(Font.getFont(Font.FACE_MONOSPACE,                            Font.STYLE_PLAIN, Font.SIZE_SMALL));                    g.drawString(puzzleArray[i], canvas.getWidth() - 10, canvas                            .getHeight()                            / 6 * (i + 1), Graphics.TOP | Graphics.RIGHT);                }                g.setColor(0xffffff);                g.setFont(Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD,                        Font.SIZE_SMALL));                g.drawString(msg[4] //TODO                        + (100 / puzzlePasswordsTotal * puzzlePasswordsFound)                        + "%", canvas.getWidth() - 10,                        canvas.getHeight() / 6 * 5, Graphics.TOP                                | Graphics.RIGHT);            }            g.setColor(puzzleMark);            g.drawRect(0, canvas.getHeight() / 6, canvas.getWidth() - 1, canvas                    .getHeight() / 6);            if (puzzleMark == 0x00cccc) {                g.drawString("WoW!", 0, canvas.getHeight() / 6, Graphics.TOP | Graphics.LEFT);             } else if (puzzleMark == 0xcc00cc){                g.drawString("Good!", 0, canvas.getHeight() / 6, Graphics.TOP | Graphics.LEFT);            } else if (puzzleMark == 0xff0000) {                g.drawString("Bad!!", 0, canvas.getHeight() / 6, Graphics.TOP | Graphics.LEFT);            }            if (puzzleArray[0].indexOf("PASS") > 0) {                paintTip(g, "1");            }            if (puzzleArray[0].indexOf("USER") > 0) {                paintTip(g, "3");            }        }    }    public void paintSimpleImage(Graphics g, String fileName) {        if (!simpleImagePainted) {            // music.playSound("/netintruder_title.mid", -1);            Image simpleImageTemp = null;            try {                simpleImageTemp = Image.createImage(fileName);            } catch (IOException e) {                e.printStackTrace();            } finally {                paintBackground(g);                g.drawImage(simpleImageTemp, g.getClipWidth() / 2                        - simpleImageTemp.getWidth() / 2, canvas.getHeight()                        / 2 - simpleImageTemp.getHeight() / 2, Graphics.TOP                        | Graphics.LEFT);                simpleImageTemp = null;                simpleImagePainted = true;            }        }    }    public void performMovement(short keyCode) {        // System.out.println("key: " + keyCode);        int newX, newY, newZ, oldX, oldY, oldZ;        oldX = player.x;        oldY = player.y;        oldZ = player.z;        newX = player.x;        newY = player.y;        newZ = player.z;        if (keyCode == Canvas.KEY_NUM3 || keyCode == -1 || keyCode == 38) {            newY = player.y - 1;            player.setCurrentAction("sprites/playerNE");        }        if (keyCode == Canvas.KEY_NUM1 || keyCode == -3 || keyCode == 37) {            newX = player.x - 1;            player.setCurrentAction("sprites/playerNW");        }        if (keyCode == Canvas.KEY_NUM9 || keyCode == -4 || keyCode == 39) {            newX = player.x + 1;            player.setCurrentAction("sprites/playerSE");        }        if (keyCode == Canvas.KEY_NUM7 || keyCode == -2 || keyCode == 40) {            newY = player.y + 1;            player.setCurrentAction("sprites/playerSW");        }        // canGo is the method to determine if the player can move in that        // cell from his starting position        // System.out.println("move");        if (canGo(oldX, oldY, newX, newY, board)) {            player.x = newX;            player.y = newY;            player.z = newZ;            // player.isMoving = true;            // System.out.println("can go");            board.moveCharacter(player, oldX, oldY, oldZ, player.x, player.y,                    player.z, false);        } else {            board.moveCharacter(player, oldX, oldY, oldZ, oldX, oldY, oldZ,                    false);            player.speed = 1;        }    }    private void runPuzzle() {        String[] temp = new String[puzzleArray.length];        temp[temp.length - 1] = generateRandomString();        for (int i = temp.length - 2; i >= 0; i--) {            temp[i] = puzzleArray[i + 1];        }        if (puzzleArray[0].indexOf("PASS") > 0) { // Missed password            puzzlePasswordsFound--;        }        if (puzzleArray[0].indexOf("USER") > 0) { // Missed password            puzzlePasswordsFound--;        }        puzzleArray = temp;    }    private Vector tokenizeString(String s, String separator) {        Vector list = new Vector();        StringBuffer tempString = new StringBuffer();        for (int i = 0; i < s.length(); i++) {            if (s.charAt(i) != separator.charAt(0)) {                tempString.append(s.charAt(i));            } else {                String newString = tempString.toString();                list.addElement(newString);                tempString.delete(0, tempString.length());            }        }        String newString = tempString.toString();        list.addElement(newString);        return list;    }    public void updateCamera() {        if ((player.lastDrawnX < 10 || player.lastDrawnX > canvas.getWidth() - 10)                || (player.lastDrawnY < 10                        || player.lastDrawnY > canvas.getHeight()                                - player.getCurrentImage().getHeight() || player.lastDrawnX == 0)) {            initCamera();        }    }}

⌨️ 快捷键说明

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