Implemented additional menu items for avatars and available controls, refactored player avatars to accommodate as well as reduce redundant code.
This commit is contained in:
parent
0786afb4d9
commit
a660adb81c
@ -2,6 +2,8 @@ package com.droidquest;
|
||||
|
||||
//This is the source code for DroidQuest 2.7. Copyright 2003 by Thomas Foote.
|
||||
|
||||
import com.droidquest.avatars.Avatar;
|
||||
import com.droidquest.avatars.LabCursor;
|
||||
import com.droidquest.levels.MainMenu;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -12,6 +14,19 @@ import java.util.Set;
|
||||
public class DQ extends JFrame implements ActionListener {
|
||||
private RoomDisplay myRoom;
|
||||
|
||||
private JCheckBoxMenuItem menuToggleHot = null;
|
||||
private JMenuItem menuItemCursor = null;
|
||||
private JMenuItem menuItemSolderpen = null;
|
||||
private JMenuItem menuItemPaintbrush = null;
|
||||
private JCheckBoxMenuItem menuItemRadio = null;
|
||||
private JMenuItem menuItemToolbox = null;
|
||||
|
||||
private JMenuItem menuRotateRight = null;
|
||||
private JMenuItem menuRotateLeft = null;
|
||||
private JMenuItem menuLoadChip = null;
|
||||
|
||||
private JMenuItem menuFlipDevice = null;
|
||||
|
||||
private DQ() {
|
||||
// Constructor
|
||||
super("DroidQuest");
|
||||
@ -27,8 +42,7 @@ public class DQ extends JFrame implements ActionListener {
|
||||
setIconImage(new ImageIcon("images/helper0.gif").getImage());
|
||||
|
||||
Container contentPane = getContentPane();
|
||||
myRoom = new RoomDisplay();
|
||||
myRoom.dq = this;
|
||||
myRoom = new RoomDisplay(this);
|
||||
|
||||
addFocusListener(new FocusAdapter() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
@ -41,6 +55,9 @@ public class DQ extends JFrame implements ActionListener {
|
||||
|
||||
JMenuBar menuBar;
|
||||
JMenu fileMenu;
|
||||
JMenu avatarMenu;
|
||||
JMenu controlMenu;
|
||||
JMenu helpMenu;
|
||||
JMenuItem menuItemSave;
|
||||
JMenuItem menuItemMain;
|
||||
JCheckBoxMenuItem menuItemSound;
|
||||
@ -66,6 +83,91 @@ public class DQ extends JFrame implements ActionListener {
|
||||
menuItemSound.addActionListener(this);
|
||||
menuItemExit.addActionListener(this);
|
||||
|
||||
avatarMenu = new JMenu("Avatar");
|
||||
avatarMenu.setMnemonic(KeyEvent.VK_A);
|
||||
menuBar.add(avatarMenu);
|
||||
|
||||
|
||||
menuItemCursor = new JRadioButtonMenuItem("Cursor");
|
||||
avatarMenu.add(menuItemCursor);
|
||||
menuItemCursor.addActionListener(this);
|
||||
|
||||
menuItemSolderpen = new JRadioButtonMenuItem("Solderpen");
|
||||
avatarMenu.add(menuItemSolderpen);
|
||||
menuItemSolderpen.setEnabled(false);
|
||||
menuItemSolderpen.addActionListener(this);
|
||||
|
||||
menuItemPaintbrush = new JRadioButtonMenuItem("Paintbrush");
|
||||
avatarMenu.add(menuItemPaintbrush);
|
||||
menuItemPaintbrush.setEnabled(false);
|
||||
menuItemPaintbrush.addActionListener(this);
|
||||
|
||||
ButtonGroup menuItemAvatarButtonGroup = new ButtonGroup();
|
||||
menuItemAvatarButtonGroup.add(menuItemCursor);
|
||||
menuItemAvatarButtonGroup.add(menuItemSolderpen);
|
||||
menuItemAvatarButtonGroup.add(menuItemPaintbrush);
|
||||
menuItemCursor.setSelected(true);
|
||||
|
||||
controlMenu = new JMenu("Controls");
|
||||
controlMenu.setMnemonic(KeyEvent.VK_C);
|
||||
menuBar.add(controlMenu);
|
||||
|
||||
|
||||
menuItemToolbox = new JMenuItem("Toolbox");
|
||||
controlMenu.add(menuItemToolbox);
|
||||
menuItemToolbox.addActionListener(this);
|
||||
|
||||
menuItemRadio = new JCheckBoxMenuItem("Radio");
|
||||
controlMenu.add(menuItemRadio);
|
||||
menuItemRadio.setSelected(false);
|
||||
menuItemRadio.setEnabled(false);
|
||||
menuItemRadio.addActionListener(this);
|
||||
|
||||
menuRotateRight = new JMenuItem("Rotate Part Clockwise");
|
||||
controlMenu.add(menuRotateRight);
|
||||
menuRotateRight.setEnabled(false);
|
||||
menuRotateRight.addActionListener(this);
|
||||
|
||||
menuRotateLeft = new JMenuItem("Rotate Part Counter-clockwise");
|
||||
controlMenu.add(menuRotateLeft);
|
||||
menuRotateLeft.setEnabled(false);
|
||||
menuRotateLeft.addActionListener(this);
|
||||
|
||||
menuToggleHot = new JCheckBoxMenuItem("Hot Cursor", false);
|
||||
menuToggleHot.setEnabled(false);
|
||||
controlMenu.add(menuToggleHot);
|
||||
menuToggleHot.addActionListener(this);
|
||||
|
||||
|
||||
menuLoadChip = new JMenuItem("Load Chip");
|
||||
controlMenu.add(menuLoadChip);
|
||||
menuLoadChip.setEnabled(false);
|
||||
menuLoadChip.addActionListener(this);
|
||||
|
||||
|
||||
JMenuItem menuEnterRobot = new JMenuItem("Enter Robot");
|
||||
controlMenu.add(menuEnterRobot);
|
||||
menuEnterRobot.addActionListener(this);
|
||||
|
||||
JMenuItem menuExitRobot = new JMenuItem("Exit Robot");
|
||||
controlMenu.add(menuExitRobot);
|
||||
menuExitRobot.addActionListener(this);
|
||||
|
||||
menuFlipDevice = new JMenuItem("Flip Device/Wire");
|
||||
controlMenu.add(menuFlipDevice);
|
||||
menuFlipDevice.setEnabled(false);
|
||||
menuFlipDevice.addActionListener(this);
|
||||
|
||||
menuBar.add(Box.createHorizontalGlue());
|
||||
|
||||
helpMenu = new JMenu("Help");
|
||||
helpMenu.setMnemonic(KeyEvent.VK_H);
|
||||
menuBar.add(helpMenu);
|
||||
|
||||
JMenuItem helpInfo = new JMenuItem("Help");
|
||||
helpMenu.add(helpInfo);
|
||||
helpInfo.addActionListener(this);
|
||||
|
||||
try {
|
||||
System.setErr(System.out);
|
||||
}
|
||||
@ -83,6 +185,98 @@ public class DQ extends JFrame implements ActionListener {
|
||||
|
||||
}
|
||||
|
||||
public void setHotCursorSelected(boolean selected) {
|
||||
if (null != this.menuToggleHot) {
|
||||
this.menuToggleHot.setSelected(selected);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHotCursorEnabled(boolean enabled) {
|
||||
if (null != this.menuToggleHot) {
|
||||
this.menuToggleHot.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRotateEnabled(boolean enabled) {
|
||||
if (null != this.menuRotateRight && null != this.menuRotateLeft) {
|
||||
this.menuRotateRight.setEnabled(enabled);
|
||||
this.menuRotateLeft.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLoadChipEnabled(boolean enabled) {
|
||||
if (null != this.menuLoadChip) {
|
||||
this.menuLoadChip.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFlipDeviceEnabled(boolean enabled) {
|
||||
if(null != this.menuFlipDevice) {
|
||||
this.menuFlipDevice.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void setToolboxEnabled(boolean enabled) {
|
||||
if (null != this.menuItemToolbox) {
|
||||
this.menuItemToolbox.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void selectCursor() {
|
||||
if (null != this.menuItemCursor) {
|
||||
this.menuItemCursor.setSelected(true);
|
||||
if (null != myRoom && null != myRoom.level && myRoom.level.gameCursor instanceof LabCursor) {
|
||||
setHotCursorEnabled(true);
|
||||
}
|
||||
setToolboxEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSolderPenEnabled(boolean enabled) {
|
||||
if (null != this.menuItemSolderpen) {
|
||||
this.menuItemSolderpen.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void selectSolderpen() {
|
||||
if (null != this.menuItemSolderpen) {
|
||||
this.menuItemSolderpen.setSelected(true);
|
||||
this.setHotCursorEnabled(false);
|
||||
setToolboxEnabled(false);
|
||||
setFlipDeviceEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPaintbrushEnabled(boolean enabled) {
|
||||
if (null != this.menuItemPaintbrush) {
|
||||
this.menuItemPaintbrush.setEnabled(enabled);
|
||||
setFlipDeviceEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void selectPaintBrush() {
|
||||
if (null != this.menuItemPaintbrush) {
|
||||
this.menuItemPaintbrush.setSelected(true);
|
||||
this.setHotCursorEnabled(false);
|
||||
this.setToolboxEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setRadioEnabled(boolean enabled) {
|
||||
if (null != this.menuItemRadio) {
|
||||
this.menuItemRadio.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRadioSelected(boolean selected) {
|
||||
if (null != this.menuItemRadio) {
|
||||
this.menuItemRadio.setSelected(selected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("Save Level")) {
|
||||
FileDialog fd = new FileDialog(this, "Save Level", FileDialog.SAVE);
|
||||
@ -95,14 +289,106 @@ public class DQ extends JFrame implements ActionListener {
|
||||
myRoom.SaveLevel(fd.getDirectory() + fd.getFile());
|
||||
}
|
||||
}
|
||||
|
||||
if (e.getActionCommand().equals("Main Menu")) {
|
||||
else if (e.getActionCommand().equals("Cursor")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleGameCursor();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Solderpen")) {
|
||||
// Handle Solderpen
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleSolderPen();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Paintbrush")) {
|
||||
// Handle Paintbrush
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handlePaintbrush();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Toolbox")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleToolbox();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Radio")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleRadio();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Rotate Part Clockwise")) {
|
||||
// Rotate a part clockwise
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleRotateDevice(1);
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Rotate Part Counter-clockwise")) {
|
||||
// Rotate counter clockwise
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleRotateDevice(-1);
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Hot Cursor")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleHotCursor();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Load Chip")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleLoadSmallChip();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Help")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleHelp();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Enter Robot")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleEnterRoom();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Exit Robot")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleExitRoom();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Flip Device/Wire")) {
|
||||
if (null != myRoom.level && null != myRoom.level.player && myRoom.level.player instanceof Avatar) {
|
||||
Avatar playerAvatar = (Avatar) myRoom.level.player;
|
||||
playerAvatar.handleFlipDevice();
|
||||
}
|
||||
}
|
||||
else if (e.getActionCommand().equals("Main Menu")) {
|
||||
int n = JOptionPane.showConfirmDialog(this, "Do you want to quit this level?",
|
||||
"return to Main Menu", JOptionPane.YES_NO_OPTION);
|
||||
if (n == 0) {
|
||||
myRoom.level.Empty();
|
||||
myRoom.level = new MainMenu(myRoom);
|
||||
myRoom.level.Init();
|
||||
setHotCursorEnabled(false);
|
||||
setHotCursorSelected(false);
|
||||
setRotateEnabled(false);
|
||||
setLoadChipEnabled(false);
|
||||
setPaintbrushEnabled(false);
|
||||
setFlipDeviceEnabled(false);
|
||||
setToolboxEnabled(false);
|
||||
setSolderPenEnabled(false);
|
||||
setRadioSelected(false);
|
||||
setRadioEnabled(false);
|
||||
selectCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class RoomDisplay extends JPanel {
|
||||
public DQ dq;
|
||||
public final DQ dq;
|
||||
Level level;
|
||||
public Timer timer;
|
||||
private int timerspeed = 128;
|
||||
@ -36,7 +36,8 @@ public class RoomDisplay extends JPanel {
|
||||
return (true);
|
||||
}
|
||||
|
||||
public RoomDisplay() {
|
||||
public RoomDisplay(final DQ dq) {
|
||||
this.dq = dq;
|
||||
setSize(new Dimension(560, 384));
|
||||
level = new MainMenu(this);
|
||||
level.Init();
|
||||
@ -188,6 +189,45 @@ public class RoomDisplay extends JPanel {
|
||||
|
||||
level.roomdisplay.useSounds = tempsound;
|
||||
level.PlaySound(level.currentViewer.room, Level.TRANSPORTSOUND);
|
||||
|
||||
|
||||
// Handle menu item initialization
|
||||
if (level.gameCursor instanceof LabCursor) {
|
||||
dq.setHotCursorSelected(false);
|
||||
dq.setHotCursorEnabled(true);
|
||||
}
|
||||
else {
|
||||
dq.setHotCursorSelected(false);
|
||||
dq.setHotCursorEnabled(false);
|
||||
}
|
||||
|
||||
if(null == level.solderingPen) {
|
||||
dq.setSolderPenEnabled(false);
|
||||
}
|
||||
else {
|
||||
dq.setSolderPenEnabled(true);
|
||||
}
|
||||
|
||||
if(null == level.paintbrush) {
|
||||
dq.setPaintbrushEnabled(false);
|
||||
}
|
||||
else {
|
||||
dq.setPaintbrushEnabled(true);
|
||||
}
|
||||
|
||||
if(null == level.remote) {
|
||||
dq.setRadioEnabled(false);
|
||||
dq.setRadioSelected(false);
|
||||
}
|
||||
else {
|
||||
dq.setRadioEnabled(true);
|
||||
dq.setRadioSelected(true);
|
||||
}
|
||||
|
||||
// Always start with cursor
|
||||
dq.selectCursor();
|
||||
|
||||
|
||||
}
|
||||
Electricity();
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
@ -210,7 +250,7 @@ public class RoomDisplay extends JPanel {
|
||||
|
||||
repaint();
|
||||
for (int a = 0; a < level.sparks.size(); a++) {
|
||||
Spark spark = (Spark) level.sparks.elementAt(a);
|
||||
Spark spark = level.sparks.elementAt(a);
|
||||
spark.Age();
|
||||
if (spark.age > 6) {
|
||||
level.sparks.removeElement(spark);
|
||||
@ -284,7 +324,7 @@ public class RoomDisplay extends JPanel {
|
||||
|
||||
// Paint Sparks
|
||||
for (int a = 0; a < level.sparks.size(); a++) {
|
||||
Spark spark = (Spark) level.sparks.elementAt(a);
|
||||
Spark spark = level.sparks.elementAt(a);
|
||||
if (spark.room == level.currentViewer.room) {
|
||||
spark.Draw(g2);
|
||||
}
|
||||
|
83
src/com/droidquest/avatars/Avatar.java
Normal file
83
src/com/droidquest/avatars/Avatar.java
Normal file
@ -0,0 +1,83 @@
|
||||
package com.droidquest.avatars;
|
||||
|
||||
/**
|
||||
* Interface to support handling a common interface for player types.
|
||||
* Particularly, since SolderingPen needs to be a Device, this can
|
||||
* be used to provide a player avatar contract.
|
||||
*/
|
||||
public interface Avatar {
|
||||
|
||||
/**
|
||||
* Handle change to game cursor.
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleGameCursor();
|
||||
|
||||
/**
|
||||
* Handle change to solder pen.
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleSolderPen();
|
||||
|
||||
/**
|
||||
* Handle opening / summoning the toolbox
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleToolbox();
|
||||
|
||||
/**
|
||||
* Handle starting / stopping the remote.
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleRadio();
|
||||
|
||||
/**
|
||||
* Handle rotating a Device object
|
||||
* @param direction -1 for counter clockwise, 1 for clockwise
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleRotateDevice(int direction);
|
||||
|
||||
/**
|
||||
* Handle setting the cursor to hot.
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleHotCursor();
|
||||
|
||||
/**
|
||||
* Handle transforming player to the paintbrush
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handlePaintbrush();
|
||||
|
||||
/**
|
||||
* Handle loading a small chip from a saved program.
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleLoadSmallChip();
|
||||
|
||||
/**
|
||||
* Handle context specific help (including chip help)
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleHelp();
|
||||
|
||||
/**
|
||||
* Handle entering an inner room (robot)
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleEnterRoom();
|
||||
|
||||
/**
|
||||
* Handle exiting an inner room (robot)
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleExitRoom();
|
||||
|
||||
/**
|
||||
* Handle flipping a device - either state or direction.
|
||||
* @return boolean whether the change was handled.
|
||||
*/
|
||||
public boolean handleFlipDevice();
|
||||
|
||||
}
|
@ -2,20 +2,13 @@ package com.droidquest.avatars;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.RoomDisplay;
|
||||
import com.droidquest.devices.Device;
|
||||
import com.droidquest.devices.GenericChip;
|
||||
import com.droidquest.devices.SmallChip;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.ToolBox;
|
||||
import com.droidquest.items.Train;
|
||||
import com.droidquest.items.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class GameCursor extends Item {
|
||||
public class GameCursor extends Player {
|
||||
private int walk = 0; // 0 or 1, used in animation
|
||||
private boolean outline; // Draw outline around GameCursor?
|
||||
|
||||
@ -268,74 +261,30 @@ public class GameCursor extends Item {
|
||||
|
||||
}
|
||||
|
||||
public void MoveUp(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.UpEnterOverlap(this)) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 320; // 10 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveUp(nudge);
|
||||
@Override
|
||||
public void moveUp(boolean nudge) {
|
||||
super.moveUp(nudge);
|
||||
walk = 1 - walk;
|
||||
currentIcon = icons[0 + walk].getImage();
|
||||
}
|
||||
|
||||
public void MoveDown(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.DownEnterOverlap(this)) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 0; // 0 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveDown(nudge);
|
||||
@Override
|
||||
public void moveDown(boolean nudge) {
|
||||
super.moveDown(nudge);
|
||||
walk = 1 - walk;
|
||||
currentIcon = icons[2 + walk].getImage();
|
||||
}
|
||||
|
||||
public void MoveLeft(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.LeftEnterOverlap(this)) {
|
||||
int newX = 532; // 19 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveLeft(nudge);
|
||||
@Override
|
||||
public void moveLeft(boolean nudge) {
|
||||
super.moveLeft(nudge);
|
||||
walk = 1 - walk;
|
||||
currentIcon = icons[4 + walk].getImage();
|
||||
}
|
||||
|
||||
public void MoveRight(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.RightEnterOverlap(this)) {
|
||||
int newX = 0; // 0 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveRight(nudge);
|
||||
@Override
|
||||
public void moveRight(boolean nudge) {
|
||||
super.moveRight(nudge);
|
||||
walk = 1 - walk;
|
||||
currentIcon = icons[6 + walk].getImage();
|
||||
}
|
||||
@ -352,303 +301,27 @@ public class GameCursor extends Item {
|
||||
return !i.getClass().toString().endsWith("Robot");
|
||||
}
|
||||
|
||||
public boolean KeyUp(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_L) {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof SmallChip) {
|
||||
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Load Chip", FileDialog.LOAD);
|
||||
fd.setDirectory("chips");
|
||||
fd.show();
|
||||
System.out.println("Dialog returned with "
|
||||
+ fd.getDirectory()
|
||||
+ fd.getFile());
|
||||
if (fd.getFile() != null) {
|
||||
((SmallChip) carrying).Empty();
|
||||
((SmallChip) carrying).LoadChip(fd.getDirectory() + fd.getFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_S) {
|
||||
if (level.solderingPen == null) {
|
||||
return false;
|
||||
}
|
||||
if (carrying != null) {
|
||||
Drops();
|
||||
}
|
||||
level.solderingPen.x = x;
|
||||
level.solderingPen.y = y;
|
||||
level.solderingPen.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.solderingPen;
|
||||
}
|
||||
level.player = level.solderingPen;
|
||||
if (level.remote != null) {
|
||||
if (level.remote.carriedBy != null) {
|
||||
level.remote.carriedBy = level.player;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||
if (level.remote == null) {
|
||||
return false;
|
||||
}
|
||||
if (level.remote.carriedBy == null) { // Summon Remote
|
||||
level.remote.x = 28;
|
||||
level.remote.y = -20;
|
||||
level.remote.carriedBy = level.player;
|
||||
level.remote.room = level.player.room;
|
||||
level.electricity = true;
|
||||
}
|
||||
else { // Hide Remote
|
||||
level.remote.carriedBy = null;
|
||||
level.remote.room = null;
|
||||
level.electricity = false;
|
||||
}
|
||||
// if (carrying != null)
|
||||
// Drops();
|
||||
// level.remote.x = x;
|
||||
// level.remote.y = y;
|
||||
// level.remote.room = room;
|
||||
// room = null;
|
||||
// if (level.currentViewer == level.player)
|
||||
// level.currentViewer=level.remote;
|
||||
// level.player = level.remote;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_T) {
|
||||
if (level.toolbox == null) {
|
||||
if (carrying != null) {
|
||||
Drops();
|
||||
}
|
||||
level.toolbox = new ToolBox(x, y + 8, room);
|
||||
level.items.addElement(level.toolbox);
|
||||
((ToolBox) level.toolbox).Toggle();
|
||||
PicksUp(level.toolbox);
|
||||
}
|
||||
if (level.toolbox.room != room) {
|
||||
// Summon Toolbox
|
||||
if (carrying != null) {
|
||||
return false;
|
||||
}
|
||||
if (((ToolBox) level.toolbox).open) {
|
||||
((ToolBox) level.toolbox).Toggle();
|
||||
}
|
||||
level.toolbox.room = room;
|
||||
level.toolbox.x = x + 28;
|
||||
level.toolbox.y = y + 6;
|
||||
PicksUp(level.toolbox);
|
||||
}
|
||||
else {
|
||||
((ToolBox) level.toolbox).Toggle();
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_SLASH) {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof GenericChip) {
|
||||
((GenericChip) carrying).ShowText(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (level.helpCam == null) {
|
||||
return false;
|
||||
}
|
||||
level.player = level.helpCam;
|
||||
level.currentViewer = level.helpCam;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
if (level.cheatmode) {
|
||||
if (e.isShiftDown() && room != null) {
|
||||
SetRoom(room.rightRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveRight(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
if (level.cheatmode) {
|
||||
if (e.isShiftDown() && room != null) {
|
||||
SetRoom(room.leftRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveLeft(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
if (level.cheatmode) {
|
||||
if (e.isShiftDown() && room != null) {
|
||||
SetRoom(room.upRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveUp(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
if (level.cheatmode) {
|
||||
if (e.isShiftDown() && room != null) {
|
||||
SetRoom(room.downRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveDown(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
{
|
||||
|
||||
@Override
|
||||
protected boolean handleTrain() {
|
||||
Item item = level.FindNearestItem(level.gameCursor);
|
||||
if (item != null) {
|
||||
if (item instanceof Train) {
|
||||
item.CanBePickedUp(this);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (carrying != null) {
|
||||
Drops();
|
||||
}
|
||||
else {
|
||||
Item item = level.FindNearestItem(level.gameCursor);
|
||||
if (item != null) {
|
||||
if (item.CanBePickedUp(level.gameCursor)) {
|
||||
PicksUp(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
outline = false;
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_CLOSE_BRACKET) {
|
||||
if (carrying != null) {
|
||||
if (carrying.isDevice()) {
|
||||
((Device) carrying).rotate(1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_OPEN_BRACKET) {
|
||||
if (carrying != null) {
|
||||
if (carrying.isDevice()) {
|
||||
((Device) carrying).rotate(-1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_E) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (Overlaps(item))
|
||||
// if (x>=item.x && y>=item.y
|
||||
// && x+width <= item.x + item.width
|
||||
// && y+height <= item.y + item.height)
|
||||
{
|
||||
if (!item.OverWall()) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_X) {
|
||||
if (room != null && room.portalItem != null) {
|
||||
Dimension d = room.portalItem.GetXY();
|
||||
int newX = d.width
|
||||
+ room.portalItem.getWidth() / 2
|
||||
- width / 2;
|
||||
int newY = d.height
|
||||
+ room.portalItem.getHeight() / 4 * 2
|
||||
- height / 2;
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(room.portalItem.room);
|
||||
level.currentViewer = level.player;
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_F) {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof Device) {
|
||||
((Device) carrying).flip();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_M) {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
long freemem = runtime.freeMemory();
|
||||
long totalmem = runtime.totalMemory();
|
||||
System.out.println("Total Memory = " + totalmem
|
||||
+ ", (" + totalmem / 1024 + "K), ("
|
||||
+ totalmem / 1024 / 1024 + "M)");
|
||||
System.out.println("Free Memory = " + freemem
|
||||
+ ", (" + freemem / 1024 + "K), ("
|
||||
+ freemem / 1024 / 1024 + "M)");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean KeyDown(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
repeating++;
|
||||
if (repeating > 5) {
|
||||
if (carriedBy == null) {
|
||||
MoveRight(e.isControlDown());
|
||||
@Override
|
||||
protected void setOutline(boolean outline) {
|
||||
this.outline = outline;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
repeating++;
|
||||
if (repeating > 5) {
|
||||
if (carriedBy == null) {
|
||||
MoveLeft(e.isControlDown());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
repeating++;
|
||||
if (repeating > 5) {
|
||||
if (carriedBy == null) {
|
||||
MoveUp(e.isControlDown());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
repeating++;
|
||||
if (repeating > 5) {
|
||||
if (carriedBy == null) {
|
||||
MoveDown(e.isControlDown());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
if (level.player == level.gameCursor) {
|
||||
outline = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@Override
|
||||
protected boolean isCheatMode() {
|
||||
return level.cheatmode;
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
@ -692,38 +365,38 @@ public class GameCursor extends Item {
|
||||
}
|
||||
}
|
||||
if (dx > 0) {
|
||||
MoveRight(dx);
|
||||
moveRight(dx);
|
||||
}
|
||||
if (dx < 0) {
|
||||
MoveLeft(-dx);
|
||||
moveLeft(-dx);
|
||||
}
|
||||
if (dy > 0) {
|
||||
MoveDown(dy);
|
||||
moveDown(dy);
|
||||
}
|
||||
if (dy < 0) {
|
||||
MoveUp(-dy);
|
||||
moveUp(-dy);
|
||||
}
|
||||
}
|
||||
if (automove == 2) {
|
||||
walk = 1 - walk;
|
||||
if (autoX > 0) {
|
||||
currentIcon = icons[6 + walk].getImage();
|
||||
MoveRight(autoX);
|
||||
moveRight(autoX);
|
||||
}
|
||||
|
||||
if (autoX < 0) {
|
||||
currentIcon = icons[4 + walk].getImage();
|
||||
MoveLeft(-autoX);
|
||||
moveLeft(-autoX);
|
||||
}
|
||||
|
||||
if (autoY > 0) {
|
||||
currentIcon = icons[2 + walk].getImage();
|
||||
MoveDown(autoY);
|
||||
moveDown(autoY);
|
||||
}
|
||||
|
||||
if (autoY < 0) {
|
||||
currentIcon = icons[0 + walk].getImage();
|
||||
MoveUp(-autoY);
|
||||
moveUp(-autoY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class HelpCam extends Item {
|
||||
public class HelpCam extends Item implements Avatar {
|
||||
public HelpCam(Room r) {
|
||||
charge = 0;
|
||||
x = 28;
|
||||
@ -38,4 +38,63 @@ public class HelpCam extends Item {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handleGameCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSolderPen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleToolbox() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRadio() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRotateDevice(int direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHotCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePaintbrush() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleLoadSmallChip() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHelp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleEnterRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleExitRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFlipDevice() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.droidquest.avatars;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.devices.Device;
|
||||
import com.droidquest.devices.GenericChip;
|
||||
import com.droidquest.devices.SmallChip;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
@ -10,14 +8,12 @@ import com.droidquest.items.ToolBox;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class LabCursor extends Item {
|
||||
public class LabCursor extends Player {
|
||||
public boolean hot;
|
||||
|
||||
|
||||
|
||||
public LabCursor(int X, int Y, Room r) {
|
||||
x = X;
|
||||
y = Y;
|
||||
@ -26,6 +22,10 @@ public class LabCursor extends Item {
|
||||
width = 28;
|
||||
height = 32;
|
||||
GenerateIcons();
|
||||
|
||||
// Lab cursor has a longer key repeat rate than the game cursor
|
||||
setKeyRepeatRate(10);
|
||||
|
||||
}
|
||||
|
||||
public void GenerateIcons() {
|
||||
@ -63,37 +63,9 @@ public class LabCursor extends Item {
|
||||
return !(i instanceof GenericRobot);
|
||||
}
|
||||
|
||||
public boolean KeyUp(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_L) {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof SmallChip) {
|
||||
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Load Chip", FileDialog.LOAD);
|
||||
fd.setDirectory("chips");
|
||||
fd.show();
|
||||
System.out.println("Dialog returned with "
|
||||
+ fd.getDirectory()
|
||||
+ fd.getFile());
|
||||
if (fd.getFile() != null) {
|
||||
((SmallChip) carrying).Empty();
|
||||
((SmallChip) carrying).LoadChip(fd.getDirectory() + fd.getFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_H) {
|
||||
hot = !hot;
|
||||
if (hot) {
|
||||
currentIcon = icons[1].getImage();
|
||||
}
|
||||
else {
|
||||
currentIcon = icons[0].getImage();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_S) {
|
||||
if (level.solderingPen == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleSaveSmallChip() {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof SmallChip) {
|
||||
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Save Chip", FileDialog.SAVE);
|
||||
@ -105,53 +77,30 @@ public class LabCursor extends Item {
|
||||
if (fd.getFile() != null) {
|
||||
((SmallChip) carrying).SaveChip(fd.getDirectory() + fd.getFile());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handleHotCursor() {
|
||||
hot = !hot;
|
||||
if (hot) {
|
||||
currentIcon = icons[1].getImage();
|
||||
}
|
||||
if (carrying != null) {
|
||||
Drops();
|
||||
else {
|
||||
currentIcon = icons[0].getImage();
|
||||
}
|
||||
level.solderingPen.x = x;
|
||||
level.solderingPen.y = y;
|
||||
level.solderingPen.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.solderingPen;
|
||||
|
||||
this.room.level.roomdisplay.dq.setHotCursorSelected(hot);
|
||||
|
||||
return true;
|
||||
}
|
||||
level.player = level.solderingPen;
|
||||
if (level.remote != null) {
|
||||
if (level.remote.carriedBy != null) {
|
||||
level.remote.carriedBy = level.player;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||
if (level.remote == null) {
|
||||
return false;
|
||||
}
|
||||
if (level.remote.carriedBy == null) { // Summon Remote
|
||||
level.remote.x = 28;
|
||||
level.remote.y = -20;
|
||||
level.remote.carriedBy = level.player;
|
||||
level.remote.room = level.player.room;
|
||||
level.electricity = true;
|
||||
}
|
||||
else { // Hide Remote
|
||||
level.remote.carriedBy = null;
|
||||
level.remote.room = null;
|
||||
level.electricity = false;
|
||||
}
|
||||
// if (carrying != null)
|
||||
// Drops();
|
||||
// level.remote.x = x;
|
||||
// level.remote.y = y;
|
||||
// level.remote.room = room;
|
||||
// room = null;
|
||||
// if (level.currentViewer == level.player)
|
||||
// level.currentViewer=level.remote;
|
||||
// level.player = level.remote;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_P) {
|
||||
|
||||
@Override
|
||||
public boolean handlePaintbrush() {
|
||||
if (level.paintbrush == null) {
|
||||
return false;
|
||||
}
|
||||
@ -166,8 +115,15 @@ public class LabCursor extends Item {
|
||||
level.currentViewer = level.paintbrush;
|
||||
}
|
||||
level.player = level.paintbrush;
|
||||
handleRemote();
|
||||
|
||||
level.roomdisplay.dq.selectPaintBrush();
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_T) {
|
||||
|
||||
@Override
|
||||
public boolean handleToolbox() {
|
||||
if (level.toolbox == null) {
|
||||
return false;
|
||||
}
|
||||
@ -187,235 +143,13 @@ public class LabCursor extends Item {
|
||||
else {
|
||||
((ToolBox) level.toolbox).Toggle();
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_SLASH) {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof GenericChip) {
|
||||
((GenericChip) carrying).ShowText(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (level.helpCam == null) {
|
||||
return false;
|
||||
}
|
||||
level.player = level.helpCam;
|
||||
level.currentViewer = level.helpCam;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
if (carriedBy == null) {
|
||||
MoveRight(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
if (carriedBy == null) {
|
||||
MoveLeft(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
if (carriedBy == null) {
|
||||
MoveUp(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
if (carriedBy == null) {
|
||||
MoveDown(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
if (carrying != null) {
|
||||
Drops();
|
||||
}
|
||||
else {
|
||||
Item item = level.FindNearestItem(level.gameCursor);
|
||||
if (item != null) {
|
||||
if (item.CanBePickedUp(level.gameCursor)) {
|
||||
PicksUp(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_CLOSE_BRACKET) {
|
||||
if (carrying != null) {
|
||||
if (carrying.isDevice()) {
|
||||
((Device) carrying).rotate(1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_OPEN_BRACKET) {
|
||||
if (carrying != null) {
|
||||
if (carrying.isDevice()) {
|
||||
((Device) carrying).rotate(-1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_E) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (Overlaps(item)) {
|
||||
if (!item.OverWall()) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_X) {
|
||||
if (room != null && room.portalItem != null) {
|
||||
Dimension d = room.portalItem.GetXY();
|
||||
int newX = d.width
|
||||
+ room.portalItem.getWidth() / 2
|
||||
- width / 2;
|
||||
int newY = d.height
|
||||
+ room.portalItem.getHeight() / 4 * 2
|
||||
- height / 2;
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(room.portalItem.room);
|
||||
level.currentViewer = level.player;
|
||||
}
|
||||
} else if (e.getKeyCode() == KeyEvent.VK_F) {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof Device) {
|
||||
((Device) carrying).flip();
|
||||
}
|
||||
}
|
||||
} else if (e.getKeyCode() == KeyEvent.VK_M) {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
long freemem = runtime.freeMemory();
|
||||
long totalmem = runtime.totalMemory();
|
||||
System.out.println("Total Memory = " + totalmem
|
||||
+ ", (" + totalmem / 1024 + "K), ("
|
||||
+ totalmem / 1024 / 1024 + "M)");
|
||||
System.out.println("Free Memory = " + freemem
|
||||
+ ", (" + freemem / 1024 + "K), ("
|
||||
+ freemem / 1024 / 1024 + "M)");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean KeyDown(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
if (carriedBy == null) {
|
||||
MoveRight(e.isControlDown());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
if (carriedBy == null) {
|
||||
MoveLeft(e.isControlDown());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
if (carriedBy == null) {
|
||||
MoveUp(e.isControlDown());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
if (carriedBy == null) {
|
||||
MoveDown(e.isControlDown());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void MoveUp(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.UpEnterOverlap(this)) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 320; // 10 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveUp(nudge);
|
||||
}
|
||||
|
||||
public void MoveDown(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.DownEnterOverlap(this)) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 0; // 0 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveDown(nudge);
|
||||
}
|
||||
|
||||
public void MoveLeft(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.LeftEnterOverlap(this)) {
|
||||
int newX = 532; // 19 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveLeft(nudge);
|
||||
}
|
||||
|
||||
public void MoveRight(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.RightEnterOverlap(this)) {
|
||||
int newX = 0; // 0 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveRight(nudge);
|
||||
}
|
||||
|
||||
}
|
@ -9,10 +9,9 @@ import com.droidquest.materials.RobotBlocker;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class PaintBrush extends Item {
|
||||
public class PaintBrush extends Player {
|
||||
// The Paintbrush works just like the original, except it allows
|
||||
// differnt color paints for differnt materials. Pressing 'P' as the
|
||||
// Paintbrush switches the Material Settings.
|
||||
@ -34,6 +33,11 @@ public class PaintBrush extends Item {
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCheatMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void GenerateIcons() {
|
||||
icons = new ImageIcon[5];
|
||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
@ -119,99 +123,37 @@ public class PaintBrush extends Item {
|
||||
|
||||
}
|
||||
|
||||
public boolean KeyUp(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_C) {
|
||||
level.gameCursor.x = x;
|
||||
level.gameCursor.y = y;
|
||||
level.gameCursor.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.gameCursor;
|
||||
@Override
|
||||
public boolean handleHelp() {
|
||||
handleGameCursor();
|
||||
return super.handleHelp();
|
||||
}
|
||||
level.player = level.gameCursor;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_S) {
|
||||
if (level.solderingPen == null) {
|
||||
|
||||
@Override
|
||||
public boolean handleLoadSmallChip() {
|
||||
return false;
|
||||
}
|
||||
level.solderingPen.x = x;
|
||||
level.solderingPen.y = y;
|
||||
level.solderingPen.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.solderingPen;
|
||||
}
|
||||
level.player = level.solderingPen;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||
if (level.remote == null) {
|
||||
return false;
|
||||
}
|
||||
level.remote.x = x;
|
||||
level.remote.y = y;
|
||||
level.remote.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.remote;
|
||||
}
|
||||
level.player = level.remote;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_SLASH) {
|
||||
if (level.helpCam == null) {
|
||||
return false;
|
||||
}
|
||||
level.player = level.helpCam;
|
||||
level.currentViewer = level.helpCam;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
if (e.isShiftDown()) {
|
||||
SetRoom(room.rightRoom);
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveRight(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
if (e.isShiftDown()) {
|
||||
SetRoom(room.leftRoom);
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveLeft(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
if (e.isShiftDown()) {
|
||||
SetRoom(room.upRoom);
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveUp(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
if (e.isShiftDown()) {
|
||||
SetRoom(room.downRoom);
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
MoveDown(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_P) {
|
||||
|
||||
@Override
|
||||
public boolean handlePaintbrush() {
|
||||
paintIndex++;
|
||||
if (paintIndex == 5) {
|
||||
paintIndex = 0;
|
||||
}
|
||||
matIndex = level.materials.indexOf(paintMats[paintIndex]);
|
||||
currentIcon = icons[paintIndex].getImage();
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
|
||||
@Override
|
||||
public boolean handleToolbox() {
|
||||
// Paintbrush doesn't handle toolbox
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePickupDrop() {
|
||||
// Paintbrush uses space for painting instead of pickup/drop
|
||||
if (!room.editable) {
|
||||
return false;
|
||||
}
|
||||
@ -223,11 +165,55 @@ public class PaintBrush extends Item {
|
||||
else {
|
||||
room.SetMaterial(bigX, bigY, emptyIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleEnterRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void MoveUp(boolean nudge) {
|
||||
@Override
|
||||
public boolean handleExitRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFlipDevice() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRotateDevice(int direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handleGameCursor() {
|
||||
level.gameCursor.x = x;
|
||||
level.gameCursor.y = y;
|
||||
level.gameCursor.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.gameCursor;
|
||||
}
|
||||
level.player = level.gameCursor;
|
||||
|
||||
handleRemote();
|
||||
|
||||
level.roomdisplay.dq.selectCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean handleRepeatSpace() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void moveUp(boolean nudge) {
|
||||
int dist = 32;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
@ -245,7 +231,7 @@ public class PaintBrush extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveDown(boolean nudge) {
|
||||
public void moveDown(boolean nudge) {
|
||||
int dist = 32;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
@ -263,7 +249,7 @@ public class PaintBrush extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveLeft(boolean nudge) {
|
||||
public void moveLeft(boolean nudge) {
|
||||
int dist = 28;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
@ -281,7 +267,7 @@ public class PaintBrush extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveRight(boolean nudge) {
|
||||
public void moveRight(boolean nudge) {
|
||||
int dist = 28;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
|
562
src/com/droidquest/avatars/Player.java
Normal file
562
src/com/droidquest/avatars/Player.java
Normal file
@ -0,0 +1,562 @@
|
||||
package com.droidquest.avatars;
|
||||
|
||||
import com.droidquest.devices.Device;
|
||||
import com.droidquest.devices.GenericChip;
|
||||
import com.droidquest.devices.SmallChip;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.ToolBox;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* Parent class to handle common Player functions.
|
||||
*/
|
||||
public class Player extends Item implements Avatar {
|
||||
|
||||
private int keyRepeatRate = 5;
|
||||
|
||||
|
||||
protected boolean handleSaveSmallChip() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleRemote() {
|
||||
if (level.remote != null) {
|
||||
if (level.remote.carriedBy != null) {
|
||||
level.remote.carriedBy = level.player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handleSolderPen() {
|
||||
if (level.solderingPen == null) {
|
||||
return false;
|
||||
}
|
||||
if (carrying != null) {
|
||||
if (handleSaveSmallChip()) {
|
||||
// Actually a save small chip command,
|
||||
// skip solder pen
|
||||
return true;
|
||||
}
|
||||
Drops();
|
||||
}
|
||||
level.solderingPen.x = x;
|
||||
level.solderingPen.y = y;
|
||||
level.solderingPen.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.solderingPen;
|
||||
}
|
||||
level.player = level.solderingPen;
|
||||
|
||||
handleRemote();
|
||||
|
||||
level.roomdisplay.dq.selectSolderpen();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleRadio() {
|
||||
if (level.remote == null) {
|
||||
return false;
|
||||
}
|
||||
if (level.remote.carriedBy == null) { // Summon Remote
|
||||
level.remote.x = 28;
|
||||
level.remote.y = -20;
|
||||
level.remote.carriedBy = level.player;
|
||||
level.remote.room = level.player.room;
|
||||
level.electricity = true;
|
||||
|
||||
level.roomdisplay.dq.setRadioSelected(true);
|
||||
}
|
||||
else { // Hide Remote
|
||||
level.remote.carriedBy = null;
|
||||
level.remote.room = null;
|
||||
level.electricity = false;
|
||||
|
||||
level.roomdisplay.dq.setRadioSelected(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleHelp() {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof GenericChip) {
|
||||
((GenericChip) carrying).ShowText(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (level.helpCam == null) {
|
||||
return false;
|
||||
}
|
||||
level.player = level.helpCam;
|
||||
level.currentViewer = level.helpCam;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleToolbox() {
|
||||
if (level.toolbox == null) {
|
||||
if (carrying != null) {
|
||||
Drops();
|
||||
}
|
||||
level.toolbox = new ToolBox(x, y + 8, room);
|
||||
level.items.addElement(level.toolbox);
|
||||
((ToolBox) level.toolbox).Toggle();
|
||||
PicksUp(level.toolbox);
|
||||
}
|
||||
if (level.toolbox.room != room) {
|
||||
// Summon Toolbox
|
||||
if (carrying != null) {
|
||||
return false;
|
||||
}
|
||||
if (((ToolBox) level.toolbox).open) {
|
||||
((ToolBox) level.toolbox).Toggle();
|
||||
}
|
||||
level.toolbox.room = room;
|
||||
level.toolbox.x = x + 28;
|
||||
level.toolbox.y = y + 6;
|
||||
PicksUp(level.toolbox);
|
||||
}
|
||||
else {
|
||||
((ToolBox) level.toolbox).Toggle();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean handleLoadSmallChip() {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof SmallChip) {
|
||||
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Load Chip", FileDialog.LOAD);
|
||||
fd.setDirectory("chips");
|
||||
fd.show();
|
||||
System.out.println("Dialog returned with "
|
||||
+ fd.getDirectory()
|
||||
+ fd.getFile());
|
||||
if (fd.getFile() != null) {
|
||||
((SmallChip) carrying).Empty();
|
||||
((SmallChip) carrying).LoadChip(fd.getDirectory() + fd.getFile());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean handleTrain() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PicksUp(Item item) {
|
||||
super.PicksUp(item);
|
||||
if (carrying instanceof SmallChip) {
|
||||
level.roomdisplay.dq.setLoadChipEnabled(true);
|
||||
}
|
||||
else {
|
||||
level.roomdisplay.dq.setLoadChipEnabled(false);
|
||||
|
||||
if (carrying.isDevice()) {
|
||||
level.roomdisplay.dq.setRotateEnabled(true);
|
||||
level.roomdisplay.dq.setFlipDeviceEnabled(true);
|
||||
}
|
||||
else {
|
||||
level.roomdisplay.dq.setRotateEnabled(false);
|
||||
level.roomdisplay.dq.setFlipDeviceEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Drops() {
|
||||
super.Drops();
|
||||
level.roomdisplay.dq.setRotateEnabled(false);
|
||||
level.roomdisplay.dq.setLoadChipEnabled(false);
|
||||
level.roomdisplay.dq.setFlipDeviceEnabled(false);
|
||||
}
|
||||
|
||||
public boolean handlePickupDrop() {
|
||||
if (handleTrain()) {
|
||||
return false;
|
||||
}
|
||||
if (carrying != null) {
|
||||
Drops();
|
||||
}
|
||||
else {
|
||||
Item item = level.FindNearestItem(level.gameCursor);
|
||||
if (item != null) {
|
||||
if (item.CanBePickedUp(level.gameCursor)) {
|
||||
PicksUp(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
setOutline(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Default implementation doesn't do anything,
|
||||
// needed by GameCursor to set outline
|
||||
protected void setOutline(boolean outline) {
|
||||
}
|
||||
|
||||
public boolean handleRotateDevice(int direction) {
|
||||
if (carrying != null) {
|
||||
if (carrying.isDevice()) {
|
||||
((Device) carrying).rotate(direction);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleEnterRoom() {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (Overlaps(item)) {
|
||||
if (!item.OverWall()) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean handleExitRoom() {
|
||||
if (room != null && room.portalItem != null) {
|
||||
Dimension d = room.portalItem.GetXY();
|
||||
int newX = d.width
|
||||
+ room.portalItem.getWidth() / 2
|
||||
- width / 2;
|
||||
int newY = d.height
|
||||
+ room.portalItem.getHeight() / 4 * 2
|
||||
- height / 2;
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(room.portalItem.room);
|
||||
level.currentViewer = level.player;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean handleFlipDevice() {
|
||||
if (carrying != null) {
|
||||
if (carrying instanceof Device) {
|
||||
((Device) carrying).flip();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean handleMemory() {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
long freemem = runtime.freeMemory();
|
||||
long totalmem = runtime.totalMemory();
|
||||
System.out.println("Total Memory = " + totalmem
|
||||
+ ", (" + totalmem / 1024 + "K), ("
|
||||
+ totalmem / 1024 / 1024 + "M)");
|
||||
System.out.println("Free Memory = " + freemem
|
||||
+ ", (" + freemem / 1024 + "K), ("
|
||||
+ freemem / 1024 / 1024 + "M)");
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isCheatMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean handleMoveDown(boolean isShiftDown, boolean isControlDown) {
|
||||
if (isCheatMode()) {
|
||||
if (isShiftDown && room != null) {
|
||||
SetRoom(room.downRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
moveDown(isControlDown);
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleMoveUp(boolean isShiftDown, boolean isControlDown) {
|
||||
if (isCheatMode()) {
|
||||
if (isShiftDown && room != null) {
|
||||
SetRoom(room.upRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
moveUp(isControlDown);
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleMoveLeft(boolean isShiftDown, boolean isControlDown) {
|
||||
if (isCheatMode()) {
|
||||
if (isShiftDown && room != null) {
|
||||
SetRoom(room.leftRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
moveLeft(isControlDown);
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleMoveRight(boolean isShiftDown, boolean isControlDown) {
|
||||
if (isCheatMode()) {
|
||||
if (isShiftDown && room != null) {
|
||||
SetRoom(room.rightRoom);
|
||||
}
|
||||
}
|
||||
if (carriedBy == null) {
|
||||
moveRight(isControlDown);
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean handleHotCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean handlePaintbrush() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Default assume that we are already a game cursor
|
||||
public boolean handleGameCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean KeyUp(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_L && handleLoadSmallChip()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_C && handleGameCursor()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_H && handleHotCursor()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_S && handleSolderPen()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_R && handleRadio()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_P && handlePaintbrush()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_T && handleToolbox()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_SLASH && handleHelp()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_RIGHT && handleMoveRight(e.isShiftDown(), e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_LEFT && handleMoveLeft(e.isShiftDown(), e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP && handleMoveUp(e.isShiftDown(), e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_DOWN && handleMoveDown(e.isShiftDown(), e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_SPACE && handlePickupDrop()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_CLOSE_BRACKET && handleRotateDevice(1)) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_OPEN_BRACKET && handleRotateDevice(-1)) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_E && handleEnterRoom()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_X && handleExitRoom()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_F && handleFlipDevice()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_M && handleMemory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean handleRepeatRight(boolean isControlDown) {
|
||||
repeating++;
|
||||
if (repeating > getKeyRepeatRate()) {
|
||||
if (carriedBy == null) {
|
||||
moveRight(isControlDown);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
protected boolean handleRepeatLeft(boolean isControlDown) {
|
||||
repeating++;
|
||||
if (repeating > getKeyRepeatRate()) {
|
||||
if (carriedBy == null) {
|
||||
moveLeft(isControlDown);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean handleRepeatUp(boolean isControlDown) {
|
||||
repeating++;
|
||||
if (repeating > getKeyRepeatRate()) {
|
||||
if (carriedBy == null) {
|
||||
moveUp(isControlDown);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean handleRepeatDown(boolean isControlDown) {
|
||||
repeating++;
|
||||
if (repeating > getKeyRepeatRate()) {
|
||||
if (carriedBy == null) {
|
||||
moveDown(isControlDown);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
protected boolean handleRepeatSpace() {
|
||||
if (level.player == level.gameCursor) {
|
||||
setOutline(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean KeyDown(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
if (handleRepeatRight(e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
if (handleRepeatLeft(e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
if (handleRepeatUp(e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
if (handleRepeatDown(e.isControlDown())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
if (handleRepeatSpace()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public int getKeyRepeatRate() {
|
||||
return keyRepeatRate;
|
||||
}
|
||||
|
||||
public void setKeyRepeatRate(int keyRepeatRate) {
|
||||
this.keyRepeatRate = keyRepeatRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveRight(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.RightEnterOverlap(this)) {
|
||||
int newX = 0; // 0 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.moveRight(nudge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveLeft(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.LeftEnterOverlap(this)) {
|
||||
int newX = 532; // 19 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.moveLeft(nudge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveDown(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.DownEnterOverlap(this)) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 0; // 0 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.moveDown(nudge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveUp(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (item.UpEnterOverlap(this)) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 320; // 10 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.moveUp(nudge);
|
||||
}
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class Remote extends Item {
|
||||
public class Remote extends Item implements Avatar {
|
||||
public Remote() {
|
||||
width = 4;
|
||||
height = 20;
|
||||
@ -98,28 +98,28 @@ public class Remote extends Item {
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
if (carriedBy == null) {
|
||||
MoveRight(e.isControlDown());
|
||||
moveRight(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
if (carriedBy == null) {
|
||||
MoveLeft(e.isControlDown());
|
||||
moveLeft(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
if (carriedBy == null) {
|
||||
MoveUp(e.isControlDown());
|
||||
moveUp(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
if (carriedBy == null) {
|
||||
MoveDown(e.isControlDown());
|
||||
moveDown(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
@ -134,7 +134,7 @@ public class Remote extends Item {
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveRight(e.isControlDown());
|
||||
moveRight(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -142,7 +142,7 @@ public class Remote extends Item {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveLeft(e.isControlDown());
|
||||
moveLeft(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -150,7 +150,7 @@ public class Remote extends Item {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveUp(e.isControlDown());
|
||||
moveUp(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -158,7 +158,7 @@ public class Remote extends Item {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveDown(e.isControlDown());
|
||||
moveDown(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -166,7 +166,7 @@ public class Remote extends Item {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void MoveUp(boolean nudge) {
|
||||
public void moveUp(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
@ -179,10 +179,10 @@ public class Remote extends Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveUp(nudge);
|
||||
super.moveUp(nudge);
|
||||
}
|
||||
|
||||
public void MoveDown(boolean nudge) {
|
||||
public void moveDown(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
@ -195,10 +195,10 @@ public class Remote extends Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveDown(nudge);
|
||||
super.moveDown(nudge);
|
||||
}
|
||||
|
||||
public void MoveLeft(boolean nudge) {
|
||||
public void moveLeft(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
@ -211,10 +211,10 @@ public class Remote extends Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveLeft(nudge);
|
||||
super.moveLeft(nudge);
|
||||
}
|
||||
|
||||
public void MoveRight(boolean nudge) {
|
||||
public void moveRight(boolean nudge) {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
@ -227,7 +227,66 @@ public class Remote extends Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveRight(nudge);
|
||||
super.moveRight(nudge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleGameCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSolderPen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleToolbox() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRadio() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRotateDevice(int direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHotCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePaintbrush() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleLoadSmallChip() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHelp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleEnterRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleExitRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFlipDevice() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class SolderingPen extends Device {
|
||||
public class SolderingPen extends Device implements Avatar {
|
||||
private boolean hot;
|
||||
private Port currentPort = null; // Port that Soldering pen is currently over
|
||||
|
||||
@ -140,7 +140,7 @@ public class SolderingPen extends Device {
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveUp(boolean nudge) {
|
||||
public void moveUp(boolean nudge) {
|
||||
Room tempRoom = room;
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
@ -154,7 +154,7 @@ public class SolderingPen extends Device {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveUp(nudge);
|
||||
super.moveUp(nudge);
|
||||
if (tempRoom != room && ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
@ -162,7 +162,7 @@ public class SolderingPen extends Device {
|
||||
CheckPort();
|
||||
}
|
||||
|
||||
public void MoveDown(boolean nudge) {
|
||||
public void moveDown(boolean nudge) {
|
||||
Room tempRoom = room;
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
@ -176,14 +176,14 @@ public class SolderingPen extends Device {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveDown(nudge);
|
||||
super.moveDown(nudge);
|
||||
if (tempRoom != room && ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
CheckPort();
|
||||
}
|
||||
|
||||
public void MoveLeft(boolean nudge) {
|
||||
public void moveLeft(boolean nudge) {
|
||||
Room tempRoom = room;
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
@ -197,14 +197,14 @@ public class SolderingPen extends Device {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveLeft(nudge);
|
||||
super.moveLeft(nudge);
|
||||
if (tempRoom != room && ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
CheckPort();
|
||||
}
|
||||
|
||||
public void MoveRight(boolean nudge) {
|
||||
public void moveRight(boolean nudge) {
|
||||
Room tempRoom = room;
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
@ -218,7 +218,7 @@ public class SolderingPen extends Device {
|
||||
}
|
||||
}
|
||||
}
|
||||
super.MoveRight(nudge);
|
||||
super.moveRight(nudge);
|
||||
if (tempRoom != room && ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
@ -296,89 +296,42 @@ public class SolderingPen extends Device {
|
||||
}
|
||||
|
||||
public boolean KeyUp(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_C) {
|
||||
if (ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
level.gameCursor.x = x;
|
||||
level.gameCursor.y = y;
|
||||
level.gameCursor.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.gameCursor;
|
||||
}
|
||||
level.player = level.gameCursor;
|
||||
if (level.remote != null) {
|
||||
if (level.remote.carriedBy != null) {
|
||||
level.remote.carriedBy = level.player;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||
if (level.remote == null) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_C && handleGameCursor()) {
|
||||
return false;
|
||||
}
|
||||
if (level.remote.carriedBy == null) { // Summon Remote
|
||||
level.remote.x = 28;
|
||||
level.remote.y = -20;
|
||||
level.remote.carriedBy = level.player;
|
||||
level.remote.room = level.player.room;
|
||||
level.electricity = true;
|
||||
}
|
||||
else { // Hide Remote
|
||||
level.remote.carriedBy = null;
|
||||
level.remote.room = null;
|
||||
level.electricity = false;
|
||||
}
|
||||
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_P) {
|
||||
if (level.paintbrush == null) {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_R && handleRadio()) {
|
||||
return false;
|
||||
}
|
||||
if (ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
level.paintbrush.x = x;
|
||||
level.paintbrush.y = y;
|
||||
level.paintbrush.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.paintbrush;
|
||||
}
|
||||
level.player = level.paintbrush;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_SLASH) {
|
||||
if (level.helpCam == null) {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_P && handlePaintbrush()) {
|
||||
return false;
|
||||
}
|
||||
level.player = level.helpCam;
|
||||
level.currentViewer = level.helpCam;
|
||||
else if (e.getKeyCode() == KeyEvent.VK_SLASH && handleHelp()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
if (carriedBy == null) {
|
||||
MoveRight(e.isControlDown());
|
||||
moveRight(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
if (carriedBy == null) {
|
||||
MoveLeft(e.isControlDown());
|
||||
moveLeft(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
if (carriedBy == null) {
|
||||
MoveUp(e.isControlDown());
|
||||
moveUp(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
if (carriedBy == null) {
|
||||
MoveDown(e.isControlDown());
|
||||
moveDown(e.isControlDown());
|
||||
}
|
||||
repeating = 0;
|
||||
return true;
|
||||
@ -386,34 +339,14 @@ public class SolderingPen extends Device {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
WirePort();
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_F) {
|
||||
if (hot) {
|
||||
if (ports[0].myWire != null) // If SP is wired
|
||||
{
|
||||
// Flip wire attached to SP
|
||||
Port tempPort = ports[0].myWire.fromPort;
|
||||
ports[0].myWire.fromPort = ports[0].myWire.toPort;
|
||||
ports[0].myWire.toPort = tempPort;
|
||||
}
|
||||
else if (ports[0].myWire == null) // If SP is not wired
|
||||
{
|
||||
// Flip wire attached to CurrentPort
|
||||
if (currentPort.myWire != null) {
|
||||
Port tempPort = currentPort.myWire.fromPort;
|
||||
currentPort.myWire.fromPort = currentPort.myWire.toPort;
|
||||
currentPort.myWire.toPort = tempPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ports[0].myWire != null) // If SP is wired
|
||||
{
|
||||
// Flip wire attached to SP
|
||||
Port tempPort = ports[0].myWire.fromPort;
|
||||
ports[0].myWire.fromPort = ports[0].myWire.toPort;
|
||||
ports[0].myWire.toPort = tempPort;
|
||||
else if (e.getKeyCode() == KeyEvent.VK_F && handleFlipDevice()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_E && handleEnterRoom()) {
|
||||
return false;
|
||||
}
|
||||
else if (e.getKeyCode() == KeyEvent.VK_X && handleExitRoom()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -422,7 +355,7 @@ public class SolderingPen extends Device {
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveRight(e.isControlDown());
|
||||
moveRight(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -430,7 +363,7 @@ public class SolderingPen extends Device {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveLeft(e.isControlDown());
|
||||
moveLeft(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -438,7 +371,7 @@ public class SolderingPen extends Device {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveUp(e.isControlDown());
|
||||
moveUp(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -446,7 +379,7 @@ public class SolderingPen extends Device {
|
||||
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
repeating++;
|
||||
if (repeating > 10) {
|
||||
MoveDown(e.isControlDown());
|
||||
moveDown(e.isControlDown());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -500,4 +433,191 @@ public class SolderingPen extends Device {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleGameCursor() {
|
||||
if (ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
level.gameCursor.x = x;
|
||||
level.gameCursor.y = y;
|
||||
level.gameCursor.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.gameCursor;
|
||||
}
|
||||
level.player = level.gameCursor;
|
||||
if (level.remote != null) {
|
||||
if (level.remote.carriedBy != null) {
|
||||
level.remote.carriedBy = level.player;
|
||||
}
|
||||
}
|
||||
|
||||
level.roomdisplay.dq.selectCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSolderPen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleToolbox() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRadio() {
|
||||
if (level.remote == null) {
|
||||
return false;
|
||||
}
|
||||
if (level.remote.carriedBy == null) { // Summon Remote
|
||||
level.remote.x = 28;
|
||||
level.remote.y = -20;
|
||||
level.remote.carriedBy = level.player;
|
||||
level.remote.room = level.player.room;
|
||||
level.electricity = true;
|
||||
|
||||
level.roomdisplay.dq.setRadioSelected(true);
|
||||
}
|
||||
else { // Hide Remote
|
||||
level.remote.carriedBy = null;
|
||||
level.remote.room = null;
|
||||
level.electricity = false;
|
||||
|
||||
level.roomdisplay.dq.setRadioSelected(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRotateDevice(int direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHotCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleRemote() {
|
||||
if (level.remote != null) {
|
||||
if (level.remote.carriedBy != null) {
|
||||
level.remote.carriedBy = level.player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePaintbrush() {
|
||||
if (level.paintbrush == null) {
|
||||
return false;
|
||||
}
|
||||
if (ports[0].myWire != null) {
|
||||
ports[0].myWire.Remove();
|
||||
}
|
||||
level.paintbrush.x = x;
|
||||
level.paintbrush.y = y;
|
||||
level.paintbrush.room = room;
|
||||
room = null;
|
||||
if (level.currentViewer == level.player) {
|
||||
level.currentViewer = level.paintbrush;
|
||||
}
|
||||
level.player = level.paintbrush;
|
||||
|
||||
level.roomdisplay.dq.selectPaintBrush();
|
||||
|
||||
handleRemote();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleLoadSmallChip() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHelp() {
|
||||
if (level.helpCam == null) {
|
||||
return false;
|
||||
}
|
||||
// First switch to game cursor
|
||||
handleGameCursor();
|
||||
|
||||
level.player = level.helpCam;
|
||||
level.currentViewer = level.helpCam;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleEnterRoom() {
|
||||
Item item = level.FindNearestItem(this);
|
||||
if (item != null) {
|
||||
if (item.InternalRoom != null) {
|
||||
if (Overlaps(item)) {
|
||||
if (!item.OverWall()) {
|
||||
int newX = 280; // 10 * 28
|
||||
int newY = 176; // 5.5 * 32
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(item.InternalRoom);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleExitRoom() {
|
||||
if (room != null && room.portalItem != null) {
|
||||
Dimension d = room.portalItem.GetXY();
|
||||
int newX = d.width
|
||||
+ room.portalItem.getWidth() / 2
|
||||
- width / 2;
|
||||
int newY = d.height
|
||||
+ room.portalItem.getHeight() / 4 * 2
|
||||
- height / 2;
|
||||
x = newX;
|
||||
y = newY;
|
||||
SetRoom(room.portalItem.room);
|
||||
level.currentViewer = level.player;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFlipDevice() {
|
||||
if (hot) {
|
||||
if (ports[0].myWire != null) // If SP is wired
|
||||
{
|
||||
// Flip wire attached to SP
|
||||
Port tempPort = ports[0].myWire.fromPort;
|
||||
ports[0].myWire.fromPort = ports[0].myWire.toPort;
|
||||
ports[0].myWire.toPort = tempPort;
|
||||
}
|
||||
else if (ports[0].myWire == null) // If SP is not wired
|
||||
{
|
||||
// Flip wire attached to CurrentPort
|
||||
if (currentPort.myWire != null) {
|
||||
Port tempPort = currentPort.myWire.fromPort;
|
||||
currentPort.myWire.fromPort = currentPort.myWire.toPort;
|
||||
currentPort.myWire.toPort = tempPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ports[0].myWire != null) // If SP is wired
|
||||
{
|
||||
// Flip wire attached to SP
|
||||
Port tempPort = ports[0].myWire.fromPort;
|
||||
ports[0].myWire.fromPort = ports[0].myWire.toPort;
|
||||
ports[0].myWire.toPort = tempPort;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,9 @@ public class Device extends Item {
|
||||
}
|
||||
|
||||
public void flip() {
|
||||
// Just rotate twice to flip
|
||||
rotate(1);
|
||||
rotate(1);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
|
@ -253,12 +253,12 @@ public class AmpireBot extends Item {
|
||||
behaviorState = 2;
|
||||
}
|
||||
else {
|
||||
MoveDown(8);
|
||||
moveDown(8);
|
||||
if (x < 280) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
if (x > 280) {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -267,12 +267,12 @@ public class AmpireBot extends Item {
|
||||
behaviorState = 3;
|
||||
}
|
||||
else {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
if (y < 192) {
|
||||
MoveDown(8);
|
||||
moveDown(8);
|
||||
}
|
||||
if (y > 192) {
|
||||
MoveUp(8);
|
||||
moveUp(8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -281,12 +281,12 @@ public class AmpireBot extends Item {
|
||||
behaviorState = 4;
|
||||
}
|
||||
else {
|
||||
MoveUp(8);
|
||||
moveUp(8);
|
||||
if (x < 280) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
if (x > 280) {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -295,12 +295,12 @@ public class AmpireBot extends Item {
|
||||
behaviorState = 5;
|
||||
}
|
||||
else {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
if (y < 192) {
|
||||
MoveDown(8);
|
||||
moveDown(8);
|
||||
}
|
||||
if (y > 192) {
|
||||
MoveUp(8);
|
||||
moveUp(8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -309,12 +309,12 @@ public class AmpireBot extends Item {
|
||||
behaviorState = 2;
|
||||
}
|
||||
else {
|
||||
MoveDown(8);
|
||||
moveDown(8);
|
||||
if (x < 280) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
if (x > 280) {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -328,16 +328,16 @@ public class AmpireBot extends Item {
|
||||
}
|
||||
Dimension d = target.GetXY();
|
||||
if (d.width < x) {
|
||||
MoveLeft(false);
|
||||
moveLeft(false);
|
||||
}
|
||||
if (d.width > x) {
|
||||
MoveRight(false);
|
||||
moveRight(false);
|
||||
}
|
||||
if (d.height < y) {
|
||||
MoveUp(false);
|
||||
moveUp(false);
|
||||
}
|
||||
if (d.height > y) {
|
||||
MoveDown(false);
|
||||
moveDown(false);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
|
@ -95,14 +95,14 @@ class ChipDecompiler extends Thread {
|
||||
for (int c = 0; c < 8; c++) {
|
||||
if (oldgate.portSignals[c].externalSignal != null) {
|
||||
int sigIndex = gate.mySignals.indexOf(oldgate.portSignals[c].externalSignal);
|
||||
newgate.portSignals[c].externalSignal = (Signal) smallchip.signals.elementAt(sigIndex);
|
||||
newgate.portSignals[c].externalSignal = smallchip.signals.elementAt(sigIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int b = 0; b < 8; b++) {
|
||||
if (gate.portSignals[b].internalSignal != null) {
|
||||
int sigIndex = gate.mySignals.indexOf(gate.portSignals[b].internalSignal);
|
||||
smallchip.portSignals[b].internalSignal = (Signal) smallchip.signals.elementAt(sigIndex);
|
||||
smallchip.portSignals[b].internalSignal = smallchip.signals.elementAt(sigIndex);
|
||||
}
|
||||
smallchip.portSignals[b].type = gate.portSignals[b].type;
|
||||
smallchip.ports[b].type = gate.portSignals[b].type;
|
||||
|
@ -71,7 +71,7 @@ public class GateKeeper extends Item {
|
||||
if (diff > 2) {
|
||||
diff = 2;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != goToY) {
|
||||
int diff = Math.abs(goToY - y);
|
||||
@ -79,7 +79,7 @@ public class GateKeeper extends Item {
|
||||
if (diff > 2) {
|
||||
diff = 2;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -290,16 +290,16 @@ public class GenericRobot extends Item {
|
||||
// Do Thrusting
|
||||
if (charge > 0 && level.electricity && (carriedBy == null) && thrusterPower) {
|
||||
if (topThruster) {
|
||||
MoveDown(8);
|
||||
moveDown(8);
|
||||
}
|
||||
if (rightThruster) {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
if (bottomThruster) {
|
||||
MoveUp(8);
|
||||
moveUp(8);
|
||||
}
|
||||
if (leftThruster) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,15 +461,7 @@ public class GenericRobot extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
// g.setColor(Color.magenta);
|
||||
// g.drawRect(orgX+leftPortal.x, orgY+leftPortal.y,
|
||||
// leftPortal.width+28, leftPortal.height+32);
|
||||
// g.drawRect(orgX+rightPortal.x, orgY+rightPortal.y,
|
||||
// rightPortal.width+28, rightPortal.height+32);
|
||||
// g.drawRect(orgX+upPortal.x, orgY+upPortal.y,
|
||||
// upPortal.width+28, upPortal.height+32);
|
||||
// g.drawRect(orgX+downPortal.x, orgY+downPortal.y,
|
||||
// downPortal.width+28, downPortal.height+32);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -164,16 +164,16 @@ public class Ghost extends Item {
|
||||
|
||||
switch (animationState) {
|
||||
case 0: // Right
|
||||
MoveRight(4);
|
||||
moveRight(4);
|
||||
break;
|
||||
case 1: // Down
|
||||
MoveDown(4);
|
||||
moveDown(4);
|
||||
break;
|
||||
case 2: // Left
|
||||
MoveLeft(4);
|
||||
moveLeft(4);
|
||||
break;
|
||||
case 3: // Up
|
||||
MoveUp(4);
|
||||
moveUp(4);
|
||||
break;
|
||||
}
|
||||
currentIcon = icons[animationState].getImage();
|
||||
|
@ -54,7 +54,7 @@ public class Handle extends Item {
|
||||
if (e.getKeyCode() == e.VK_RIGHT) {
|
||||
if (x < 15 * 28) {
|
||||
room.SetMaterial(x / 28 - 12, 4, 0);
|
||||
MoveRight(28);
|
||||
moveRight(28);
|
||||
room.SetMaterial(x / 28 - 1, 4, 8);
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class Handle extends Item {
|
||||
if (x > 13 * 28) {
|
||||
room.SetMaterial(x / 28 - 13, 4, 8);
|
||||
room.SetMaterial(x / 28 - 1, 4, 0);
|
||||
MoveLeft(28);
|
||||
moveLeft(28);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ public class Item implements Serializable, Cloneable {
|
||||
|
||||
}
|
||||
|
||||
protected void MoveUp(int dist) {
|
||||
protected void moveUp(int dist) {
|
||||
int bigXl = x / 28;
|
||||
int bigXr = (x + getWidth() - 1) / 28;
|
||||
int bigY = (y - dist) / 32;
|
||||
@ -295,7 +295,7 @@ public class Item implements Serializable, Cloneable {
|
||||
x = d.width + (room.portalItem.width - width) / 2;
|
||||
y = d.height + (room.portalItem.height - height) / 2;
|
||||
SetRoom(room.portalItem.room);
|
||||
MoveUp(dist);
|
||||
moveUp(dist);
|
||||
}
|
||||
else { // stop at top
|
||||
y += 384;
|
||||
@ -305,7 +305,7 @@ public class Item implements Serializable, Cloneable {
|
||||
ItemEffectsMaterials();
|
||||
}
|
||||
|
||||
protected void MoveDown(int dist) {
|
||||
protected void moveDown(int dist) {
|
||||
int bigXl = x / 28;
|
||||
int bigXr = (x + getWidth() - 1) / 28;
|
||||
int bigY = (y + getHeight() - 1 + dist) / 32;
|
||||
@ -328,7 +328,7 @@ public class Item implements Serializable, Cloneable {
|
||||
x = d.width + (room.portalItem.width - width) / 2;
|
||||
y = d.height + (room.portalItem.height - height) / 2;
|
||||
SetRoom(room.portalItem.room);
|
||||
MoveDown(dist);
|
||||
moveDown(dist);
|
||||
}
|
||||
else { // stop at bottom
|
||||
y -= 384;
|
||||
@ -338,7 +338,7 @@ public class Item implements Serializable, Cloneable {
|
||||
ItemEffectsMaterials();
|
||||
}
|
||||
|
||||
protected void MoveLeft(int dist) {
|
||||
protected void moveLeft(int dist) {
|
||||
int bigX = (x - dist) / 28;
|
||||
int bigYt = y / 32;
|
||||
int bigYb = (y + getHeight() - 1) / 32;
|
||||
@ -360,7 +360,7 @@ public class Item implements Serializable, Cloneable {
|
||||
x = d.width + (room.portalItem.width - width) / 2;
|
||||
y = d.height + (room.portalItem.height - height) / 2;
|
||||
SetRoom(room.portalItem.room);
|
||||
MoveLeft(dist);
|
||||
moveLeft(dist);
|
||||
}
|
||||
else { // stop at Left
|
||||
x += 560;
|
||||
@ -370,7 +370,7 @@ public class Item implements Serializable, Cloneable {
|
||||
ItemEffectsMaterials();
|
||||
}
|
||||
|
||||
protected void MoveRight(int dist) {
|
||||
protected void moveRight(int dist) {
|
||||
int bigX = (x + getWidth() - 1 + dist) / 28;
|
||||
int bigYt = y / 32;
|
||||
int bigYb = (y + getHeight() - 1) / 32;
|
||||
@ -394,7 +394,7 @@ public class Item implements Serializable, Cloneable {
|
||||
x = d.width + (room.portalItem.width - width) / 2;
|
||||
y = d.height + (room.portalItem.height - height) / 2;
|
||||
SetRoom(room.portalItem.room);
|
||||
MoveRight(dist);
|
||||
moveRight(dist);
|
||||
}
|
||||
else { // stop at Right
|
||||
x -= 560;
|
||||
@ -404,36 +404,36 @@ public class Item implements Serializable, Cloneable {
|
||||
ItemEffectsMaterials();
|
||||
}
|
||||
|
||||
protected void MoveUp(boolean nudge) {
|
||||
protected void moveUp(boolean nudge) {
|
||||
int dist = 32;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
}
|
||||
MoveUp(dist);
|
||||
moveUp(dist);
|
||||
}
|
||||
|
||||
protected void MoveDown(boolean nudge) {
|
||||
protected void moveDown(boolean nudge) {
|
||||
int dist = 32;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
}
|
||||
MoveDown(dist);
|
||||
moveDown(dist);
|
||||
}
|
||||
|
||||
protected void MoveLeft(boolean nudge) {
|
||||
protected void moveLeft(boolean nudge) {
|
||||
int dist = 28;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
}
|
||||
MoveLeft(dist);
|
||||
moveLeft(dist);
|
||||
}
|
||||
|
||||
protected void MoveRight(boolean nudge) {
|
||||
protected void moveRight(boolean nudge) {
|
||||
int dist = 28;
|
||||
if (nudge) {
|
||||
dist = 2;
|
||||
}
|
||||
MoveRight(dist);
|
||||
moveRight(dist);
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
@ -459,30 +459,30 @@ public class Item implements Serializable, Cloneable {
|
||||
dy = 32;
|
||||
}
|
||||
if (dx > 0) {
|
||||
MoveRight(dx);
|
||||
moveRight(dx);
|
||||
}
|
||||
if (dx < 0) {
|
||||
MoveLeft(-dx);
|
||||
moveLeft(-dx);
|
||||
}
|
||||
if (dy > 0) {
|
||||
MoveDown(dy);
|
||||
moveDown(dy);
|
||||
}
|
||||
if (dy < 0) {
|
||||
MoveUp(-dy);
|
||||
moveUp(-dy);
|
||||
}
|
||||
}
|
||||
if (automove == 2) {
|
||||
if (autoX > 0) {
|
||||
MoveRight(autoX);
|
||||
moveRight(autoX);
|
||||
}
|
||||
if (autoX < 0) {
|
||||
MoveLeft(-autoX);
|
||||
moveLeft(-autoX);
|
||||
}
|
||||
if (autoY > 0) {
|
||||
MoveDown(autoY);
|
||||
moveDown(autoY);
|
||||
}
|
||||
if (autoY < 0) {
|
||||
MoveUp(-autoY);
|
||||
moveUp(-autoY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class Sentry extends Item {
|
||||
if (diff > 8) {
|
||||
diff = 8;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != goToY) {
|
||||
int diff = Math.abs(goToY - y);
|
||||
@ -296,7 +296,7 @@ public class Sentry extends Item {
|
||||
if (diff > 8) {
|
||||
diff = 8;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,7 +314,7 @@ public class Sentry extends Item {
|
||||
if (diff > 50) {
|
||||
diff /= 2;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != level.player.y) {
|
||||
int diff = Math.abs(level.player.y - y);
|
||||
@ -322,7 +322,7 @@ public class Sentry extends Item {
|
||||
if (diff > 50) {
|
||||
diff /= 2;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
if (x == level.player.x && y == level.player.y) {
|
||||
PicksUp(level.player);
|
||||
@ -343,7 +343,7 @@ public class Sentry extends Item {
|
||||
if (diff > 8) {
|
||||
diff = 8;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != carryToY) {
|
||||
int diff = Math.abs(carryToY - y);
|
||||
@ -351,7 +351,7 @@ public class Sentry extends Item {
|
||||
if (diff > 8) {
|
||||
diff = 8;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,7 +389,7 @@ public class Sentry extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveUp(int dist) {
|
||||
public void moveUp(int dist) {
|
||||
int newY = y - dist;
|
||||
if (newY < 0) {
|
||||
newY = 0;
|
||||
@ -397,7 +397,7 @@ public class Sentry extends Item {
|
||||
y = newY;
|
||||
}
|
||||
|
||||
public void MoveDown(int dist) {
|
||||
public void moveDown(int dist) {
|
||||
int newY = y + dist;
|
||||
if (newY > 383) {
|
||||
newY = 383;
|
||||
@ -405,7 +405,7 @@ public class Sentry extends Item {
|
||||
y = newY;
|
||||
}
|
||||
|
||||
public void MoveLeft(int dist) {
|
||||
public void moveLeft(int dist) {
|
||||
int newX = x - dist;
|
||||
if (newX < 0) {
|
||||
newX = 0;
|
||||
@ -413,7 +413,7 @@ public class Sentry extends Item {
|
||||
x = newX;
|
||||
}
|
||||
|
||||
public void MoveRight(int dist) {
|
||||
public void moveRight(int dist) {
|
||||
int newX = x + dist;
|
||||
if (newX > 579) {
|
||||
newX = 579;
|
||||
|
@ -56,30 +56,30 @@ public class Sentry3 extends Sentry {
|
||||
switch (behavior) {
|
||||
case 0:
|
||||
if (y < 256) {
|
||||
MoveDown(8);
|
||||
moveDown(8);
|
||||
}
|
||||
else {
|
||||
behavior = 1;
|
||||
}
|
||||
if (x < 56) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
if (x > 56) {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (y > 64) {
|
||||
MoveUp(8);
|
||||
moveUp(8);
|
||||
}
|
||||
else {
|
||||
behavior = 0;
|
||||
}
|
||||
if (x < 56) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
if (x > 56) {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@ -102,16 +102,16 @@ public class Sentry3 extends Sentry {
|
||||
dy = 50;
|
||||
}
|
||||
if (dx < 0) {
|
||||
MoveLeft(-dx);
|
||||
moveLeft(-dx);
|
||||
}
|
||||
if (dx > 0) {
|
||||
MoveRight(dx);
|
||||
moveRight(dx);
|
||||
}
|
||||
if (dy < 0) {
|
||||
MoveUp(-dy);
|
||||
moveUp(-dy);
|
||||
}
|
||||
if (dy > 0) {
|
||||
MoveDown(dy);
|
||||
moveDown(dy);
|
||||
}
|
||||
if (dx == 0 && dy == 0) {
|
||||
PicksUp(level.player);
|
||||
@ -126,16 +126,16 @@ public class Sentry3 extends Sentry {
|
||||
}
|
||||
else {
|
||||
if (y < 312) {
|
||||
MoveDown(8);
|
||||
moveDown(8);
|
||||
}
|
||||
else if (y < 320) {
|
||||
MoveDown(320 - y);
|
||||
moveDown(320 - y);
|
||||
}
|
||||
if (x < carryToX) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
if (x > carryToX) {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -166,14 +166,14 @@ public class SentryT1 extends Item {
|
||||
switch (behavior) {
|
||||
case 0:
|
||||
oldX = x;
|
||||
MoveLeft(4);
|
||||
moveLeft(4);
|
||||
if (oldX == x) {
|
||||
behavior = 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
oldX = x;
|
||||
MoveRight(4);
|
||||
moveRight(4);
|
||||
if (oldX == x) {
|
||||
behavior = 0;
|
||||
}
|
||||
|
@ -43,30 +43,30 @@ public class SentryT2 extends Sentry {
|
||||
switch (behavior) {
|
||||
case 0:
|
||||
if (y < 256) {
|
||||
MoveDown(4);
|
||||
moveDown(4);
|
||||
}
|
||||
else {
|
||||
behavior = 1;
|
||||
}
|
||||
if (x < 56) {
|
||||
MoveRight(4);
|
||||
moveRight(4);
|
||||
}
|
||||
if (x > 56) {
|
||||
MoveLeft(4);
|
||||
moveLeft(4);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (y > 64) {
|
||||
MoveUp(4);
|
||||
moveUp(4);
|
||||
}
|
||||
else {
|
||||
behavior = 0;
|
||||
}
|
||||
if (x < 56) {
|
||||
MoveRight(4);
|
||||
moveRight(4);
|
||||
}
|
||||
if (x > 56) {
|
||||
MoveLeft(4);
|
||||
moveLeft(4);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@ -89,16 +89,16 @@ public class SentryT2 extends Sentry {
|
||||
dy = 50;
|
||||
}
|
||||
if (dx < 0) {
|
||||
MoveLeft(-dx);
|
||||
moveLeft(-dx);
|
||||
}
|
||||
if (dx > 0) {
|
||||
MoveRight(dx);
|
||||
moveRight(dx);
|
||||
}
|
||||
if (dy < 0) {
|
||||
MoveUp(-dy);
|
||||
moveUp(-dy);
|
||||
}
|
||||
if (dy > 0) {
|
||||
MoveDown(dy);
|
||||
moveDown(dy);
|
||||
}
|
||||
if (dx == 0 && dy == 0) {
|
||||
PicksUp(level.player);
|
||||
@ -113,13 +113,13 @@ public class SentryT2 extends Sentry {
|
||||
}
|
||||
else {
|
||||
if (x > 56) {
|
||||
MoveLeft(4);
|
||||
moveLeft(4);
|
||||
}
|
||||
if (y < 20) {
|
||||
MoveDown(4);
|
||||
moveDown(4);
|
||||
}
|
||||
if (y > 30) {
|
||||
MoveUp(4);
|
||||
moveUp(4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -32,7 +32,7 @@ public class SkyGuard extends Item {
|
||||
|
||||
if (speed > 0) {
|
||||
if (speed + x < 420) {
|
||||
MoveRight(speed);
|
||||
moveRight(speed);
|
||||
currentIcon = icons[animationState].getImage();
|
||||
}
|
||||
else {
|
||||
@ -42,7 +42,7 @@ public class SkyGuard extends Item {
|
||||
}
|
||||
else if (speed < 0) {
|
||||
if (speed + x > 112) {
|
||||
MoveLeft(-speed);
|
||||
moveLeft(-speed);
|
||||
currentIcon = icons[3 + animationState].getImage();
|
||||
}
|
||||
else {
|
||||
|
@ -30,14 +30,14 @@ public class SkywayFlyer extends Item {
|
||||
currentIcon = icons[0].getImage();
|
||||
}
|
||||
|
||||
public void MoveUp(int dist) {
|
||||
public void moveUp(int dist) {
|
||||
y = y - dist;
|
||||
if (y < 32) {
|
||||
y = 320;
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveDown(int dist) {
|
||||
public void moveDown(int dist) {
|
||||
y = y + dist;
|
||||
if (y > 320) {
|
||||
y = 32;
|
||||
@ -52,10 +52,10 @@ public class SkywayFlyer extends Item {
|
||||
currentIcon = icons[animationState].getImage();
|
||||
|
||||
if (speed < 0) {
|
||||
MoveUp(-speed);
|
||||
moveUp(-speed);
|
||||
}
|
||||
else {
|
||||
MoveDown(speed);
|
||||
moveDown(speed);
|
||||
}
|
||||
|
||||
if (Overlaps(level.player)) {
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.droidquest.items;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.avatars.Avatar;
|
||||
import com.droidquest.decorations.TextBox;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class SpyCam extends Item {
|
||||
public class SpyCam extends Item implements Avatar {
|
||||
public SpyCam(Room r) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
@ -21,23 +22,23 @@ public class SpyCam extends Item {
|
||||
}
|
||||
|
||||
public boolean KeyUp(KeyEvent e) {
|
||||
if (e.getKeyCode() == e.VK_RIGHT) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
SetRoom(room.rightRoom);
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == e.VK_LEFT) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
SetRoom(room.leftRoom);
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == e.VK_UP) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
SetRoom(room.upRoom);
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == e.VK_DOWN) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
SetRoom(room.downRoom);
|
||||
return true;
|
||||
}
|
||||
if (e.getKeyCode() == e.VK_SPACE) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||
level.player = level.gameCursor;
|
||||
level.currentViewer = level.player;
|
||||
for (int a = 5; a < 60; a++) {
|
||||
@ -50,4 +51,63 @@ public class SpyCam extends Item {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleGameCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSolderPen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleToolbox() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRadio() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRotateDevice(int direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHotCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePaintbrush() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleLoadSmallChip() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHelp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleEnterRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleExitRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFlipDevice() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -174,16 +174,16 @@ public class StormCloud extends Item {
|
||||
}
|
||||
|
||||
if (xDirection > 0) {
|
||||
MoveRight(xDirection);
|
||||
moveRight(xDirection);
|
||||
}
|
||||
if (xDirection < 0) {
|
||||
MoveLeft(-xDirection);
|
||||
moveLeft(-xDirection);
|
||||
}
|
||||
if (yDirection > 0) {
|
||||
MoveDown(yDirection);
|
||||
moveDown(yDirection);
|
||||
}
|
||||
if (yDirection < 0) {
|
||||
MoveUp(-yDirection);
|
||||
moveUp(-yDirection);
|
||||
}
|
||||
|
||||
if (brobot != null) {
|
||||
@ -239,7 +239,7 @@ public class StormCloud extends Item {
|
||||
|
||||
}
|
||||
|
||||
public void MoveRight(int dist) {
|
||||
public void moveRight(int dist) {
|
||||
int newX = x + dist;
|
||||
if (newX > 559 - 4 * 28 / 2) {
|
||||
xDirection = -(level.random.nextInt(maxspeed) + 1);
|
||||
@ -248,7 +248,7 @@ public class StormCloud extends Item {
|
||||
x = newX;
|
||||
}
|
||||
|
||||
public void MoveLeft(int dist) {
|
||||
public void moveLeft(int dist) {
|
||||
int newX = x - dist;
|
||||
if (newX < 0) {
|
||||
xDirection = level.random.nextInt(maxspeed) + 1;
|
||||
@ -257,7 +257,7 @@ public class StormCloud extends Item {
|
||||
x = newX;
|
||||
}
|
||||
|
||||
public void MoveUp(int dist) {
|
||||
public void moveUp(int dist) {
|
||||
y -= dist;
|
||||
if (y < 0) {
|
||||
room = room.upRoom;
|
||||
@ -265,7 +265,7 @@ public class StormCloud extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveDown(int dist) {
|
||||
public void moveDown(int dist) {
|
||||
y += dist;
|
||||
if (y > 383) {
|
||||
room = room.downRoom;
|
||||
|
@ -175,7 +175,7 @@ public class Sweeper extends Item {
|
||||
currentIcon = icons[1].getImage();
|
||||
}
|
||||
else {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -190,7 +190,7 @@ public class Sweeper extends Item {
|
||||
currentIcon = icons[2].getImage();
|
||||
}
|
||||
else {
|
||||
MoveLeft(8);
|
||||
moveLeft(8);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.droidquest.items;
|
||||
|
||||
import com.droidquest.avatars.Avatar;
|
||||
import com.droidquest.materials.Material;
|
||||
|
||||
import javax.swing.*;
|
||||
@ -7,7 +8,7 @@ import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class Train extends Item {
|
||||
public class Train extends Item implements Avatar {
|
||||
public Train() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
@ -85,10 +86,69 @@ public class Train extends Item {
|
||||
public void Animate() {
|
||||
if (room != null) {
|
||||
if (carrying != null) {
|
||||
MoveRight(8);
|
||||
moveRight(8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean handleGameCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSolderPen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleToolbox() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRadio() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRotateDevice(int direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHotCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePaintbrush() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleLoadSmallChip() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleHelp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleEnterRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleExitRoom() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleFlipDevice() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -89,14 +89,14 @@ public class TrashCollector extends Item {
|
||||
switch (behavior) {
|
||||
case 0: // Move Left to Room 31
|
||||
if (room != gotoRoom) {
|
||||
MoveLeft(4);
|
||||
moveLeft(4);
|
||||
if (y != 176) {
|
||||
int diff = Math.abs(176 - y);
|
||||
int dir = diff / (176 - y);
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -110,7 +110,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != gotoY) {
|
||||
int diff = Math.abs(gotoY - y);
|
||||
@ -118,20 +118,20 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: // Move Up to Room 5
|
||||
if (room != gotoRoom) {
|
||||
MoveUp(4);
|
||||
moveUp(4);
|
||||
if (x != 266) {
|
||||
int diff = Math.abs(266 - y);
|
||||
int dir = diff / (266 - y);
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -145,7 +145,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != gotoY) {
|
||||
int diff = Math.abs(gotoY - y);
|
||||
@ -153,20 +153,20 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2: // Move Right to Room 11
|
||||
if (room != gotoRoom) {
|
||||
MoveRight(4);
|
||||
moveRight(4);
|
||||
if (y != 176) {
|
||||
int diff = Math.abs(176 - y);
|
||||
int dir = diff / (176 - y);
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -180,7 +180,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != gotoY) {
|
||||
int diff = Math.abs(gotoY - y);
|
||||
@ -188,20 +188,20 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3: // Move Down to Room 17
|
||||
if (room != gotoRoom) {
|
||||
MoveDown(4);
|
||||
moveDown(4);
|
||||
if (x != 266) {
|
||||
int diff = Math.abs(266 - y);
|
||||
int dir = diff / (266 - y);
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -215,7 +215,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != gotoY) {
|
||||
int diff = Math.abs(gotoY - y);
|
||||
@ -223,20 +223,20 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4: // Move Left to Room 19
|
||||
if (room != gotoRoom) {
|
||||
MoveLeft(4);
|
||||
moveLeft(4);
|
||||
if (y != 176) {
|
||||
int diff = Math.abs(176 - y);
|
||||
int dir = diff / (176 - y);
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -263,7 +263,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != gotoY) {
|
||||
int diff = Math.abs(gotoY - y);
|
||||
@ -271,20 +271,20 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5: // Move Up to Room 58
|
||||
if (room != gotoRoom) {
|
||||
MoveUp(4);
|
||||
moveUp(4);
|
||||
if (x != 266) {
|
||||
int diff = Math.abs(266 - y);
|
||||
int dir = diff / (266 - y);
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -305,7 +305,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != gotoY) {
|
||||
int diff = Math.abs(gotoY - y);
|
||||
@ -313,20 +313,20 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6: // Move Down to Room 19
|
||||
if (room != gotoRoom) {
|
||||
MoveDown(4);
|
||||
moveDown(4);
|
||||
if (x != 266) {
|
||||
int diff = Math.abs(266 - y);
|
||||
int dir = diff / (266 - y);
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -340,7 +340,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != gotoY) {
|
||||
int diff = Math.abs(gotoY - y);
|
||||
@ -348,7 +348,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 4) {
|
||||
diff = 4;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -365,7 +365,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 8) {
|
||||
diff = 8;
|
||||
}
|
||||
MoveRight(diff * dir);
|
||||
moveRight(diff * dir);
|
||||
}
|
||||
if (y != target.y) {
|
||||
int diff = Math.abs(target.y - y);
|
||||
@ -373,7 +373,7 @@ public class TrashCollector extends Item {
|
||||
if (diff > 8) {
|
||||
diff = 8;
|
||||
}
|
||||
MoveDown(diff * dir);
|
||||
moveDown(diff * dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class Turbine extends Item {
|
||||
public void Animate() {
|
||||
boolean flag = false;
|
||||
for (int a = 0; a < level.sparks.size(); a++) {
|
||||
Spark spark = (Spark) level.sparks.elementAt(a);
|
||||
Spark spark = level.sparks.elementAt(a);
|
||||
if (spark.room == room) {
|
||||
if (spark.y >= y && spark.y <= y + height) {
|
||||
if (spark.x >= x && spark.x <= x + width) {
|
||||
|
@ -87,13 +87,13 @@ public class VendingHandle extends Item {
|
||||
int tempX = d.width;
|
||||
int tempY = d.height;
|
||||
if (tempY != startY) {
|
||||
carriedBy.MoveDown(startY - tempY);
|
||||
carriedBy.moveDown(startY - tempY);
|
||||
}
|
||||
if (tempX < startX) {
|
||||
carriedBy.MoveRight(startX - tempX);
|
||||
carriedBy.moveRight(startX - tempX);
|
||||
}
|
||||
if (tempX > (startX + maxPull)) {
|
||||
carriedBy.MoveLeft(tempX - (startX + maxPull));
|
||||
carriedBy.moveLeft(tempX - (startX + maxPull));
|
||||
}
|
||||
|
||||
d = GetXY();
|
||||
|
@ -75,13 +75,13 @@ public class WallHandle extends Item {
|
||||
int tempX = d.width;
|
||||
int tempY = d.height;
|
||||
if (tempY != startY) {
|
||||
carriedBy.MoveDown(startY - tempY);
|
||||
carriedBy.moveDown(startY - tempY);
|
||||
}
|
||||
if (tempX < startX) {
|
||||
carriedBy.MoveRight(startX - tempX);
|
||||
carriedBy.moveRight(startX - tempX);
|
||||
}
|
||||
if (tempX > (startX + maxPull)) {
|
||||
carriedBy.MoveLeft(tempX - (startX + maxPull));
|
||||
carriedBy.moveLeft(tempX - (startX + maxPull));
|
||||
}
|
||||
|
||||
d = GetXY();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.avatars.GameCursor;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
|
@ -2,7 +2,6 @@ package com.droidquest.materials;
|
||||
|
||||
import com.droidquest.avatars.GameCursor;
|
||||
import com.droidquest.decorations.Graphix;
|
||||
import com.droidquest.decorations.TextBox;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Magnet;
|
||||
|
Loading…
Reference in New Issue
Block a user