private void init(State state) { if (state == State.GAME) { // If the state is ingame... level = Level.createLevel(0); // Load the spawn level (level 0) TileCoordinate playerSpawn = new TileCoordinate( 15, 60); // Create player coodinates. This class creates coordinates from pixels and // converts it to tile coordinates (16 pixels -> 1 tile) String playerName = ""; // Initiate the players name if (FileHandler.fileExists(FileHandler.localUserFile)) playerName = FileHandler .getPlayerName(); // If the player already exists, set the players name to the // stored name else playerName = sc .getPlayerName(); // Otherwise retrieve the name from the start screen that the user // has typed into the name box player = new Player( playerName, playerSpawn.x(), playerSpawn.y(), key); // Create a new player. Pass in the name, spawn location (in tile coordinates), // and the keyboard class. changeLevel( Level .activeLevel); // Set the level to the current level (0, as we set that in the // beginning) FileHandler.save(player); // Save everything initPause = false; // Set pause to false, just in case it is true c.clearTextArea(); // Clear the console System.out.println( "Controls: \n W/up -> Player up \n A/left -> Player left \n S/down -> Player down \n D/right -> Player right \n " + "Q -> Inventory \n Shift -> Sprint \n HOME -> home level \n M -> Map \n numbers 1-6 -> Weapons"); // Output the controls so the user can see what to do } else if (state == State.START) { // If the state is the start screen... sc = new StartScreen(); // Initiate the start screen uiManager.addPanel( sc); // Add the startscreen to the UI manager, which will render and update it } else if (state == State.PAUSE) { // If the state is in pause... pause = new Pause(); // Instantiate a new pause menu uiManager.addPanel( pause); // Add the pause menu to the UI manager, ready for rendering and updating initPause = true; // Tell the game we have created a pause menu (prevent more than 1 opening) paused = true; // Tell the game we are paused } STATE = State .WAITING; // Once the correct state is set up, set the state wo WAITING, which tells the // game we are waiting for the state to change. }
/** {@inheritDoc} */ @Override @requires("java-runtime>=7") public boolean invoke(final String command, final boolean consumed, final Scanner scanner) { if (command.equals("help")) { if (consumed) return true; System.out.println("COMMANDS: DESCRIPTIONS:"); System.out.println("help Leads here..."); System.out.println("show c Show copyright notice."); System.out.println("show w Show warranty notice."); System.out.println("show l Show licenses."); System.out.println("version Print version information about this program."); System.out.println("credits Shows the credits of this program and all aktiv plug-ins."); } else if (command.equals("show c")) { if (consumed) return true; System.out.println("Paradis — Ever growing network for parallell and distributed computing."); System.out.println("Copyright © 2012 Mattias Andrée"); System.out.println(); System.out.println("This program is free software: you can redistribute it and/or modify"); System.out.println( "it under the terms of the GNU Affero General Public License as published by"); System.out.println("the Free Software Foundation, either version 3 of the License, or"); System.out.println("(at your option) any later version."); System.out.println(); System.out.println( "You should have received a copy of the GNU Affero General Public License"); System.out.println("along with this program. If not, see <http://www.gnu.org/licenses/>."); } else if (command.equals("show w")) { if (consumed) return true; System.out.println("This program is distributed in the hope that it will be useful,"); System.out.println("but WITHOUT ANY WARRANTY; without even the implied warranty of"); System.out.println("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"); System.out.println("GNU Affero General Public License for more details."); } else if (command.equals("show l")) { if (consumed) return true; final String pager = Properties.getPager(); if (FileHandler.fileExists("res/COPYING+colour")) Pager.pageFile(pager, "Copyright information", "res/COPYING+colour"); else if (FileHandler.fileExists("res/COPYING")) Pager.pageFile(pager, "Copyright information", "res/COPYING"); else Pager.pageFile(pager, "Copyright information", "COPYING"); if (FileHandler.fileExists("res/LICENSE.AGPL3+colour")) Pager.pageFile(pager, "GNU Affero General Public License v3", "res/LICENSE.AGPL3+colour"); else if (FileHandler.fileExists("res/LICENSE.AGPL3")) Pager.pageFile(pager, "GNU Affero General Public License v3", "res/LICENSE.AGPL3"); else Pager.pageFile(pager, "GNU Affero General Public License v3", "LICENSE.AGPL3"); if (FileHandler.fileExists("res/LICENSE.GPL3+colour")) Pager.pageFile(pager, "GNU General Public License v3", "res/LICENSE.GPL3+colour"); else if (FileHandler.fileExists("res/LICENSE.GPL3")) Pager.pageFile(pager, "GNU General Public License v3", "res/LICENSE.GPL3"); else Pager.pageFile(pager, "GNU General Public License v3", "LICENSE.GPL3"); if (FileHandler.fileExists("res/LICENSE.GPL2+colour")) Pager.pageFile(pager, "GNU General Public License v2", "res/LICENSE.GPL2+colour"); else if (FileHandler.fileExists("res/LICENSE.GPL2")) Pager.pageFile(pager, "GNU General Public License v2", "res/LICENSE.GPL2"); else Pager.pageFile(pager, "GNU General Public License v2", "LICENSE.GPL2"); } else if (command.equals("version")) { if (consumed) return true; System.out.println("Package: " + Program.PACKAGE); System.out.println("Fork path: " + Program.FORK); System.out.println("Version: " + Program.VERSION); System.out.println(); System.out.println("Website: " + Program.WEBSITE); } else if (command.equals("credits")) { if (consumed) return true; System.out.println("Paradis — Ever growing network for parallell and distributed computing."); System.out.println("Copyright © 2012 Mattias Andrée"); } else if (command.equals("shell")) { if (consumed) return true; String shell = Properties.getShell(); if ((shell == null) || shell.isEmpty()) System.out.println( "Impossible to determine shell, your shell should export SHELL to it's file name (e.g. bash)."); else try { final ProcessBuilder builder = new ProcessBuilder(shell); builder.inheritIO(); builder.start().waitFor(); } catch (final Throwable err) { System.out.print("Cannot manage to start shell"); } } else if (command.equals("pacman") || command.startsWith("pacman ")) { if (consumed) return true; Pacman.main( command.equals("pacman") ? new String[0] : command.substring("pacman ".length()).split(" ")); } else if (command.equals("makepkg") || command.startsWith("makepkg ")) { if (consumed) return true; Makepkg.main( command.equals("makepkg") ? new String[0] : command.substring("makepkg ".length()).split(" ")); } else return false; return true; }