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

📄 netintruderutility.java

📁 斜45度游戏《NetIntruder》
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
import isoj2me.Board;import isoj2me.Character;import java.io.IOException;import java.io.InputStream;import java.util.Hashtable;import java.util.Random;import java.util.Vector;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Graphics;import javax.microedition.lcdui.Image;/** * Net Intruder: utility class *  * This software is released under GNU LGPL license. View license.txt for more details. *  * @version 0.9 * @author Massimo Maria Avvisati (http://www.mondonerd.com) *  */public class netIntruderUtility {    private static final String BASE_MAP = "/map";    public static boolean canMove = false;    private static final String LEVELS_DEF = "/levels.txt";    private static final int TILE_HEIGHT = 8;    private static final String TILE_SET = "base";    private static final int TILE_WIDTH = 32;    private Image tipImage = null;    public void paintTip(Graphics g, String keysSuggested) {        if (tipImage == null) {            try {                tipImage = Image.createImage("/ui/tip.png");            } catch (IOException e) {                            }        }//TODO better solution possible...        if (keysSuggested.indexOf("1") >= 0) {            g.setColor(0xffff00);            g.fillRect(10  + 4,canvas.getHeight() - 5 - tipImage.getHeight() + 5, 9, 9);        }        if (keysSuggested.indexOf("3") >= 0) {            g.setColor(0xffff00);            g.fillRect(10 + 28, canvas.getHeight() - 5 - tipImage.getHeight() + 5, 9, 9);        }        if (keysSuggested.indexOf("0") >= 0) {            g.setColor(0xffff00);            g.fillRect(10 + 16, canvas.getHeight() - 5 - tipImage.getHeight() + 41, 9, 9);        }        g.drawImage(tipImage, 10, canvas.getHeight() - 5 - tipImage.getHeight(), Graphics.TOP | Graphics.LEFT);            }    private static boolean moveMemory(int oldX, int oldY, int x, int y,            Board board) {        if (!canMove) {            return false;        }        if (oldX < x && x + 1 < board.map.getWidth()) { // from left            try {                int tempCellCode = board.map.getCell(0, x + 1, y);                if (tempCellCode == 49) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x + 1, y, 90);                    board.changed = true;                    return true;                } else if (tempCellCode == 48) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x + 1, y, 49);                    board.changed = true;                    return true;                }                {                    return false;                }            } catch (Exception ex) {                return false;            }        }        if (oldX > x && x - 1 >= 0) { // from right            try {                int tempCellCode = board.map.getCell(0, x - 1, y);                if (tempCellCode == 49) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x - 1, y, 90);                    board.changed = true;                    return true;                } else if (tempCellCode == 48) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x - 1, y, 49);                    board.changed = true;                    return true;                }                {                    return false;                }            } catch (Exception ex) {                return false;            }        }        if (oldY > y && y - 1 >= 0) { // from bottom            try {                int tempCellCode = board.map.getCell(0, x, y - 1);                if (tempCellCode == 49) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x, y - 1, 90);                    board.changed = true;                    return true;                } else if (tempCellCode == 48) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x, y - 1, 49);                    board.changed = true;                    return true;                }                {                    return false;                }            } catch (Exception ex) {                return false;            }        }        if (oldY < y && y + 1 < board.map.getHeight()) { // from top            try {                int tempCellCode = board.map.getCell(0, x, y + 1);                if (tempCellCode == 49) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x, y + 1, 90);                    board.changed = true;                    return true;                } else if (tempCellCode == 48) {                    board.map.setCell(0, x, y, 49);                    board.map.setCell(0, x, y + 1, 49);                    board.changed = true;                    return true;                }                {                    return false;                }            } catch (Exception ex) {                return false;            }        }        return false;    }    Board board = null;    netIntruderCanvas canvas = null;    public boolean centered = false;    int counter = 100;    private long currentTimeLast = 0;    public boolean fullscreenMessagePainted = false;//    private boolean gameStarted = false;    public int gameTime = 700;    public int gameTimeInit = gameTime;    long gameTimeTemp = System.currentTimeMillis();    private Hashtable introFrames = new Hashtable();    private String introPhrase = "";    private Hashtable introSpeech = new Hashtable();    public long lastMessagePainted = 0;    int level = 0;    private long movementTime;    public String[] msg = {            "Sicuro?",            "Per informazioni visitare http://www.yos.it",            "Benvenuto. Avvicinati alle email e leggi le mie indicazioni premento 0",            "Sniffing...",            "Completato: ",            "Complimenti! Hai completato questo gioco. Sei nell'Elite :) Non dimenticare di visitare http://www.yos.it ed inserire il tuo codice: ",            "Sei stato lento e ti sei fatto prendere... Sorry, per te il gioco e' finito!",            "Premi 0...",            "0 = si, 1 = no",            "0 = esci, 1 = continua",            "Blocchi di memoria ripristinati nella posizione iniziale"};//    public String[] msg = {//            "Sure?",//            "For info go to http://www.yos.it",//            "Benvenuto. Avvicinati alle email e leggi le mie indicazioni premento 0",//            "Sniffing...",//            "Complete: ",//            "Cool! You finished this game. You are in the Elite :) Don't forget to visit http://www.yos.it and use there your code: ",//            "Too slow... Sorry, the game is over for you!",//            "Push 0...",//            "0 = yes, 1 = no",//            "0 = exit, 1 = continue"};    public String[] rules = {            "devi spiare i dati della rete rubando le password e spostare i blocchi di memoria per raggiungere il server.",            "Non puoi spostare i blocchi di memoria se prima non hai rubato le password. In alto vedi il tempo che ti rimane.",            "Per leggere le istruzioni contenute nelle mail premi 0. Premi 5 per centrare la telecamera sul giocatore."    };    //    public String[] msgLevel = {//            "Ci siamo solo riscaldati. Nel prossimo livello non ti ho lasciato suggerimenti: te la caverai... vero?",//            "Questo era facile. Ma dovrai ancora faticare un bel po'...",//            "Nessun computer e' sicuro. Ma alcuni sono, come hai visto, piu' sicuri di altri...",//            "Sapevi che questo gioco che vedi e' fatto tutto in Linux?...",//            "Che dici? E' facile!? Beh, vediamo come te la cavi con la prossima rete!",//            "Il tempo corre. Fossi in te da ora farei caso alla barra del tempo in alto!",//            "Se sai programmare puoi fare cose fichissime. Come ad esempio giochi per cellulari ;)",//            "Ci siamo ormai...", "Non ho parole... prendi carte e penna..." };//    public String[] msgLevel = {//            "Level 1 done", //            "Level 2 done", //            "Level 3 done", //            "Level 4 done", //            "Level 5 done", //            "Level 6 done", //            "Level 7 done", //            "Level 8 done",//            "Level 9 done"};        public String[] msgLevel = {            "Livello 1 completato",             "Livello 2 completato",             "Livello 3 completato",             "Livello 4 completato",             "Livello 5 completato",             "Livello 6 completato",             "Livello 7 completato",             "Livello 8 completato",            "Livello 9 completato"};    public final short NUMBER_OF_LEVELS = 9;    private short numberTilesPerSide = 0;    String[] packages = {            "7465 4510 0213 f001 10be 2bff 3dee 212e   .......eFTP...",            "4510 0213 f001 10be 2bff 3dee 212e f001   ...winzozProt...",            "4510 0213 f001 10be 2bff 3dee 212e 7465   ...mondonerd.com",            "10be 2bff 4510 0213 f001 3dee 212e 212e   ...wiEmail..t...",            "10be 2bff 4510 0213 f001 3dee 212e 212e   USER.imbeciX.",            "4510 0213 f001 10be 2bff 3dee 212e 7465   ...WWW.....yos.it",            "10be 2bff 4510 10be 2bff 0213 f001 3dee   ...USER..tonto2006",            "3dee 212e 4510 0213 10be 2bff 7465 f001   .)...PASS7v.2pL..",            "4510 0213 f001 10be 2bff 3dee 212e 2bff   E..(:.@.@.Jm....",            "4510 0213 f001 10be 2bff 3dee 212e 2bff   ..private.mpg....",            "10be 2bff 4510 0213 f001 3dee 212e 7465   .233.64.in-addr.",            "4510 0213 f001 10be 2bff 3dee 212e 4510   ...PASS12345678.",            "4510 0213 f001 10be 2bff 3dee 212e 4510   ...PASS....sex..." };    Character player = null;        String[] puzzleArrayEmpty = { "", "", "", "", "", "" };    String[] puzzleArray = puzzleArrayEmpty;    public int puzzleMark = 0xcccccc;    public short puzzlePasswordsFound = 0;    public short puzzlePasswordsTotal = 5;    public short puzzleSpeed = 900;    public boolean puzzleStarted = false;    long puzzleTimer = System.currentTimeMillis();    public boolean puzzleVerified = false;    Random randomGen = new Random();    public boolean simpleImagePainted = false;    private int startingPointX = 0;    private int startingPointY = 0;    private long timer = 0;    Hashtable tips = null;    private int yMod;    public netIntruderUtility(netIntruderCanvas parentCanvas) {        this.canvas = parentCanvas;        numberTilesPerSide = (short) calculateBoardSize();        initBoard();        initPlayer();    }    private int calculateBoardSize() {        if (canvas.getHeight() > 65) {            return (canvas.getHeight() / 11 - 1);        }        return 9;    }    public boolean canGo(int oldX, int oldY, int x, int y, Board board) {        // Cannot go out of the board        if (x < 0 || x >= board.map.getWidth()) {            return false;        }        if (y < 0 || y >= board.map.getHeight()) {            return false;        }        // Cannot walk trhou another character or an object (if not walkable)        if (board.isCharacter(x, y, 0) != null) {        }        // Check if the map cell is a walkable floor or a wall/building        int cell = 999;        //int oldCell = 999;        try {            cell = board.map.getCell(0, x, y);            //oldCell = board.map.getCell(0, oldX, oldY);        } catch (Exception ex) {        }        if (cell == 90) {            if (moveMemory(oldX, oldY, x, y, board)) {                return true;            } else {                return false;            }

⌨️ 快捷键说明

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