Merge pull request #6 from cognitivegears/master
Refactored and cleaned up code. Modernized some constructs.
This commit is contained in:
@@ -2,68 +2,50 @@ package com.droidquest;
|
|||||||
|
|
||||||
//This is the source code for DroidQuest 2.7. Copyright 2003 by Thomas Foote.
|
//This is the source code for DroidQuest 2.7. Copyright 2003 by Thomas Foote.
|
||||||
|
|
||||||
import java.io.*;
|
import com.droidquest.avatars.Avatar;
|
||||||
import java.awt.*;
|
import com.droidquest.avatars.LabCursor;
|
||||||
import java.awt.event.*;
|
import com.droidquest.levels.MainMenu;
|
||||||
import java.awt.image.*;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import com.droidquest.avatars.GameCursor;
|
import java.awt.event.*;
|
||||||
import com.droidquest.chipstuff.Port;
|
|
||||||
import com.droidquest.decorations.Arrow;
|
|
||||||
import com.droidquest.decorations.Graphix;
|
|
||||||
import com.droidquest.decorations.Spark;
|
|
||||||
import com.droidquest.decorations.TextBox;
|
|
||||||
import com.droidquest.devices.ANDGate;
|
|
||||||
import com.droidquest.devices.Device;
|
|
||||||
import com.droidquest.devices.FlipFlop;
|
|
||||||
import com.droidquest.devices.NOTGate;
|
|
||||||
import com.droidquest.devices.Node;
|
|
||||||
import com.droidquest.devices.ORGate;
|
|
||||||
import com.droidquest.devices.PortDevice;
|
|
||||||
import com.droidquest.devices.XORGate;
|
|
||||||
import com.droidquest.items.Item;
|
|
||||||
import com.droidquest.items.ToolBox;
|
|
||||||
import com.droidquest.levels.Level;
|
|
||||||
import com.droidquest.levels.MainMenu;
|
|
||||||
import com.droidquest.materials.Material;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.lang.Integer;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.applet.*;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
|
|
||||||
public class DQ extends JFrame implements ActionListener
|
public class DQ extends JFrame implements ActionListener {
|
||||||
{
|
private RoomDisplay myRoom;
|
||||||
RoomDisplay myRoom;
|
|
||||||
|
|
||||||
public DQ ()
|
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
|
// Constructor
|
||||||
super("DroidQuest");
|
super("DroidQuest");
|
||||||
setSize(560 + 8, 384 + 27 + 24);
|
setSize(560 + 8, 384 + 27 + 24);
|
||||||
addWindowListener( new WindowAdapter()
|
addWindowListener(new WindowAdapter() {
|
||||||
{
|
public void windowClosing(WindowEvent e) {
|
||||||
public void windowClosing(WindowEvent e)
|
setVisible(false);
|
||||||
{ setVisible(false); dispose(); System.exit(0); }
|
dispose();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setIconImage(new ImageIcon("images/helper0.gif").getImage());
|
setIconImage(new ImageIcon("images/helper0.gif").getImage());
|
||||||
|
|
||||||
Container contentPane = getContentPane();
|
Container contentPane = getContentPane();
|
||||||
myRoom = new RoomDisplay();
|
myRoom = new RoomDisplay(this);
|
||||||
myRoom.dq=this;
|
|
||||||
|
|
||||||
addFocusListener(new FocusAdapter()
|
addFocusListener(new FocusAdapter() {
|
||||||
{
|
public void focusGained(FocusEvent e) {
|
||||||
public void focusGained(FocusEvent e)
|
|
||||||
{
|
|
||||||
myRoom.requestFocus();
|
myRoom.requestFocus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -73,6 +55,9 @@ public class DQ extends JFrame implements ActionListener
|
|||||||
|
|
||||||
JMenuBar menuBar;
|
JMenuBar menuBar;
|
||||||
JMenu fileMenu;
|
JMenu fileMenu;
|
||||||
|
JMenu avatarMenu;
|
||||||
|
JMenu controlMenu;
|
||||||
|
JMenu helpMenu;
|
||||||
JMenuItem menuItemSave;
|
JMenuItem menuItemSave;
|
||||||
JMenuItem menuItemMain;
|
JMenuItem menuItemMain;
|
||||||
JCheckBoxMenuItem menuItemSound;
|
JCheckBoxMenuItem menuItemSound;
|
||||||
@@ -98,15 +83,99 @@ public class DQ extends JFrame implements ActionListener
|
|||||||
menuItemSound.addActionListener(this);
|
menuItemSound.addActionListener(this);
|
||||||
menuItemExit.addActionListener(this);
|
menuItemExit.addActionListener(this);
|
||||||
|
|
||||||
try
|
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);
|
System.setErr(System.out);
|
||||||
}
|
}
|
||||||
catch (SecurityException e) {}
|
catch (SecurityException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args) {
|
||||||
{
|
|
||||||
DQ dq = new DQ();
|
DQ dq = new DQ();
|
||||||
GraphicsConfiguration gc = dq.getGraphicsConfiguration();
|
GraphicsConfiguration gc = dq.getGraphicsConfiguration();
|
||||||
Rectangle bounds = gc.getBounds();
|
Rectangle bounds = gc.getBounds();
|
||||||
@@ -116,54 +185,229 @@ public class DQ extends JFrame implements ActionListener
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e)
|
public void setHotCursorSelected(boolean selected) {
|
||||||
{
|
if (null != this.menuToggleHot) {
|
||||||
if (e.getActionCommand() == "Save Level")
|
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);
|
FileDialog fd = new FileDialog(this, "Save Level", FileDialog.SAVE);
|
||||||
fd.setDirectory("ROlevels");
|
fd.setDirectory("ROlevels");
|
||||||
fd.show();
|
fd.show();
|
||||||
System.out.println("Dialog returned with "
|
System.out.println("Dialog returned with "
|
||||||
+ fd.getDirectory()
|
+ fd.getDirectory()
|
||||||
+ fd.getFile());
|
+ fd.getFile());
|
||||||
if (fd.getFile() != null)
|
if (fd.getFile() != null) {
|
||||||
myRoom.SaveLevel(fd.getDirectory() + fd.getFile());
|
myRoom.SaveLevel(fd.getDirectory() + fd.getFile());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (e.getActionCommand() == "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?",
|
int n = JOptionPane.showConfirmDialog(this, "Do you want to quit this level?",
|
||||||
"return to Main Menu", JOptionPane.YES_NO_OPTION);
|
"return to Main Menu", JOptionPane.YES_NO_OPTION);
|
||||||
if (n==0)
|
if (n == 0) {
|
||||||
{
|
|
||||||
myRoom.level.Empty();
|
myRoom.level.Empty();
|
||||||
myRoom.level = new MainMenu(myRoom);
|
myRoom.level = new MainMenu(myRoom);
|
||||||
myRoom.level.Init();
|
myRoom.level.Init();
|
||||||
|
setHotCursorEnabled(false);
|
||||||
|
setHotCursorSelected(false);
|
||||||
|
setRotateEnabled(false);
|
||||||
|
setLoadChipEnabled(false);
|
||||||
|
setPaintbrushEnabled(false);
|
||||||
|
setFlipDeviceEnabled(false);
|
||||||
|
setToolboxEnabled(false);
|
||||||
|
setSolderPenEnabled(false);
|
||||||
|
setRadioSelected(false);
|
||||||
|
setRadioEnabled(false);
|
||||||
|
selectCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getActionCommand() == "Sound")
|
if (e.getActionCommand().equals("Sound")) {
|
||||||
{
|
|
||||||
myRoom.useSounds = ((JCheckBoxMenuItem) e.getSource()).getState();
|
myRoom.useSounds = ((JCheckBoxMenuItem) e.getSource()).getState();
|
||||||
if (myRoom.useSounds==false)
|
if (!myRoom.useSounds) {
|
||||||
{
|
|
||||||
Set<String> keys = myRoom.level.sounds.keySet();
|
Set<String> keys = myRoom.level.sounds.keySet();
|
||||||
Iterator<String> iterator = keys.iterator();
|
for (String soundFile : keys) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
String soundFile = iterator.next();
|
|
||||||
SoundClip soundClip = myRoom.level.sounds.get(soundFile);
|
SoundClip soundClip = myRoom.level.sounds.get(soundFile);
|
||||||
soundClip.audioClip.stop();
|
soundClip.audioClip.stop();
|
||||||
}
|
}
|
||||||
// for (int a=0; a<myRoom.level.sounds.size(); a++)
|
|
||||||
// {
|
|
||||||
// SoundClip sc = (SoundClip) myRoom.level.sounds.elementAt(a);
|
|
||||||
// sc.audioClip.stop();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getActionCommand() == "Exit")
|
if (e.getActionCommand().equals("Exit")) {
|
||||||
{ setVisible(false); dispose(); System.exit(0); }
|
setVisible(false);
|
||||||
|
dispose();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +416,6 @@ public class DQ extends JFrame implements ActionListener
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Updating Tutorial levels to 2.0
|
//Updating Tutorial levels to 2.0
|
||||||
//
|
//
|
||||||
//ROTUT1 : Robot Anatomy
|
//ROTUT1 : Robot Anatomy
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
package com.droidquest;
|
package com.droidquest;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.FontMetrics;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import com.droidquest.decorations.Arrow;
|
import com.droidquest.decorations.Arrow;
|
||||||
import com.droidquest.decorations.Graphix;
|
import com.droidquest.decorations.Graphix;
|
||||||
import com.droidquest.decorations.TextBox;
|
import com.droidquest.decorations.TextBox;
|
||||||
@@ -16,8 +7,14 @@ import com.droidquest.items.Item;
|
|||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
public class Room implements Serializable, Cloneable
|
import java.awt.*;
|
||||||
{
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class Room implements Serializable, Cloneable {
|
||||||
public transient static Level level;
|
public transient static Level level;
|
||||||
public transient Room upRoom;
|
public transient Room upRoom;
|
||||||
public transient Room downRoom;
|
public transient Room downRoom;
|
||||||
@@ -40,14 +37,13 @@ public int[][] RoomArray = { // Array of image references
|
|||||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
public transient Material[][] MaterialArray = new Material[12][20];
|
public transient Material[][] MaterialArray = new Material[12][20];
|
||||||
public Vector textBoxes = new Vector();
|
public Vector<TextBox> textBoxes = new Vector<TextBox>();
|
||||||
public Vector wires = new Vector();
|
public Vector<Wire> wires = new Vector<Wire>();
|
||||||
public Vector graphix = new Vector();
|
public Vector<Graphix> graphix = new Vector<Graphix>();
|
||||||
public Vector arrows = new Vector();
|
public Vector<Arrow> arrows = new Vector<Arrow>();
|
||||||
public boolean editable;
|
public boolean editable;
|
||||||
|
|
||||||
public Room()
|
public Room() {
|
||||||
{
|
|
||||||
upRoom = this;
|
upRoom = this;
|
||||||
downRoom = this;
|
downRoom = this;
|
||||||
rightRoom = this;
|
rightRoom = this;
|
||||||
@@ -55,20 +51,19 @@ public Room()
|
|||||||
editable = false;
|
editable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
s.writeInt(level.rooms.indexOf(upRoom));
|
s.writeInt(level.rooms.indexOf(upRoom));
|
||||||
s.writeInt(level.rooms.indexOf(downRoom));
|
s.writeInt(level.rooms.indexOf(downRoom));
|
||||||
s.writeInt(level.rooms.indexOf(rightRoom));
|
s.writeInt(level.rooms.indexOf(rightRoom));
|
||||||
s.writeInt(level.rooms.indexOf(leftRoom));
|
s.writeInt(level.rooms.indexOf(leftRoom));
|
||||||
s.writeInt(level.items.indexOf(portalItem));
|
s.writeInt(level.items.indexOf(portalItem));
|
||||||
s.writeInt(wires.size());
|
s.writeInt(wires.size());
|
||||||
for (int a=0; a<wires.size(); a++)
|
for (int a = 0; a < wires.size(); a++) {
|
||||||
((Wire)wires.elementAt(a)).writeRef(s);
|
wires.elementAt(a).writeRef(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
upRoom = level.FindRoom(s.readInt());
|
upRoom = level.FindRoom(s.readInt());
|
||||||
downRoom = level.FindRoom(s.readInt());
|
downRoom = level.FindRoom(s.readInt());
|
||||||
rightRoom = level.FindRoom(s.readInt());
|
rightRoom = level.FindRoom(s.readInt());
|
||||||
@@ -76,76 +71,66 @@ public void readRef(ObjectInputStream s) throws IOException
|
|||||||
portalItem = level.FindItem(s.readInt());
|
portalItem = level.FindItem(s.readInt());
|
||||||
|
|
||||||
int numWires = s.readInt();
|
int numWires = s.readInt();
|
||||||
wires = new Vector();
|
wires = new Vector<Wire>();
|
||||||
for (int a=0; a<numWires; a++)
|
for (int a = 0; a < numWires; a++) {
|
||||||
{
|
|
||||||
Wire wire = new Wire();
|
Wire wire = new Wire();
|
||||||
wires.addElement(wire);
|
wires.addElement(wire);
|
||||||
wire.readRef(s, level);
|
wire.readRef(s, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<graphix.size(); a++)
|
for (int a = 0; a < graphix.size(); a++) {
|
||||||
{
|
graphix.elementAt(a).GenerateIcons();
|
||||||
((Graphix)graphix.elementAt(a)).GenerateIcons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateArray();
|
GenerateArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateArray()
|
public void GenerateArray() {
|
||||||
{
|
|
||||||
MaterialArray = new Material[12][20];
|
MaterialArray = new Material[12][20];
|
||||||
for (int y=0; y<12; y++)
|
for (int y = 0; y < 12; y++) {
|
||||||
for (int x=0; x<20; x++)
|
for (int x = 0; x < 20; x++) {
|
||||||
MaterialArray[y][x] = (Material) level.materials.elementAt(RoomArray[y][x]);
|
MaterialArray[y][x] = level.materials.elementAt(RoomArray[y][x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMaterial(int X, int Y, int index)
|
public void SetMaterial(int X, int Y, int index) {
|
||||||
{
|
Material mat = level.materials.elementAt(index);
|
||||||
Material mat = (Material) level.materials.elementAt(index);
|
if (mat != null) {
|
||||||
if (mat != null)
|
|
||||||
{
|
|
||||||
RoomArray[Y][X] = index;
|
RoomArray[Y][X] = index;
|
||||||
MaterialArray[Y][X] = mat;
|
MaterialArray[Y][X] = mat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMaterial(int X, int Y, Material mat)
|
public void SetMaterial(int X, int Y, Material mat) {
|
||||||
{
|
|
||||||
int index = level.materials.indexOf(mat);
|
int index = level.materials.indexOf(mat);
|
||||||
RoomArray[Y][X] = index;
|
RoomArray[Y][X] = index;
|
||||||
MaterialArray[Y][X] = mat;
|
MaterialArray[Y][X] = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMaterialFill(int X1, int Y1, int X2, int Y2, int index)
|
public void SetMaterialFill(int X1, int Y1, int X2, int Y2, int index) {
|
||||||
{
|
Material mat = level.materials.elementAt(index);
|
||||||
Material mat = (Material) level.materials.elementAt(index);
|
if (mat != null) {
|
||||||
if (mat != null)
|
for (int Y = Y1; Y <= Y2; Y++) {
|
||||||
{
|
for (int X = X1; X <= X2; X++) {
|
||||||
for (int Y=Y1; Y<=Y2; Y++)
|
|
||||||
for(int X=X1; X<=X2; X++)
|
|
||||||
{
|
|
||||||
RoomArray[Y][X] = index;
|
RoomArray[Y][X] = index;
|
||||||
MaterialArray[Y][X] = mat;
|
MaterialArray[Y][X] = mat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetMaterialOutline(int X1, int Y1, int X2, int Y2, int index)
|
public void SetMaterialOutline(int X1, int Y1, int X2, int Y2, int index) {
|
||||||
{
|
Material mat = level.materials.elementAt(index);
|
||||||
Material mat = (Material) level.materials.elementAt(index);
|
if (mat != null) {
|
||||||
if (mat != null)
|
for (int Y = Y1; Y <= Y2; Y++) {
|
||||||
{
|
|
||||||
for (int Y=Y1; Y<=Y2; Y++)
|
|
||||||
{
|
|
||||||
RoomArray[Y][X1] = index;
|
RoomArray[Y][X1] = index;
|
||||||
MaterialArray[Y][X1] = mat;
|
MaterialArray[Y][X1] = mat;
|
||||||
RoomArray[Y][X2] = index;
|
RoomArray[Y][X2] = index;
|
||||||
MaterialArray[Y][X2] = mat;
|
MaterialArray[Y][X2] = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int X=X1; X<=X2; X++)
|
for (int X = X1; X <= X2; X++) {
|
||||||
{
|
|
||||||
RoomArray[Y1][X] = index;
|
RoomArray[Y1][X] = index;
|
||||||
MaterialArray[Y1][X] = mat;
|
MaterialArray[Y1][X] = mat;
|
||||||
RoomArray[Y2][X] = index;
|
RoomArray[Y2][X] = index;
|
||||||
@@ -154,46 +139,39 @@ public void SetMaterialOutline(int X1, int Y1, int X2, int Y2, int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetMaterialFromRoom(int roomIndex)
|
public void SetMaterialFromRoom(int roomIndex) {
|
||||||
{
|
Room r = level.rooms.elementAt(roomIndex);
|
||||||
Room r = (Room) level.rooms.elementAt(roomIndex);
|
for (int Y = 0; Y < 12; Y++) {
|
||||||
for (int Y=0; Y<12; Y++)
|
for (int X = 0; X < 20; X++) {
|
||||||
for (int X=0; X<20; X++)
|
|
||||||
{
|
|
||||||
RoomArray[Y][X] = r.RoomArray[Y][X];
|
RoomArray[Y][X] = r.RoomArray[Y][X];
|
||||||
MaterialArray[Y][X] = r.MaterialArray[Y][X];
|
MaterialArray[Y][X] = r.MaterialArray[Y][X];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AddTextBox(String t, int X, int Y, int W)
|
public void AddTextBox(String t, int X, int Y, int W) {
|
||||||
{
|
|
||||||
TextBox newText = new TextBox(t, X, Y, W);
|
TextBox newText = new TextBox(t, X, Y, W);
|
||||||
textBoxes.addElement(newText);
|
textBoxes.addElement(newText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddArrow(int X, int Y, int dir, int len, Color col)
|
public void AddArrow(int X, int Y, int dir, int len, Color col) {
|
||||||
{
|
|
||||||
Arrow newArrow = new Arrow(X, Y, dir, len, col);
|
Arrow newArrow = new Arrow(X, Y, dir, len, col);
|
||||||
arrows.addElement(newArrow);
|
arrows.addElement(newArrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddGraphix(String t, int X, int Y)
|
public void AddGraphix(String t, int X, int Y) {
|
||||||
{
|
|
||||||
Graphix newGraphix = new Graphix(t, X, Y);
|
Graphix newGraphix = new Graphix(t, X, Y);
|
||||||
graphix.addElement(newGraphix);
|
graphix.addElement(newGraphix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddGraphix(String[] t, int X, int Y)
|
public void AddGraphix(String[] t, int X, int Y) {
|
||||||
{
|
|
||||||
Graphix newGraphix = new Graphix(t, X, Y);
|
Graphix newGraphix = new Graphix(t, X, Y);
|
||||||
graphix.addElement(newGraphix);
|
graphix.addElement(newGraphix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawTextBoxes(Graphics g, RoomDisplay rd)
|
public void DrawTextBoxes(Graphics g, RoomDisplay rd) {
|
||||||
{
|
for (int a = 0; a < textBoxes.size(); a++) {
|
||||||
for (int a=0; a<textBoxes.size(); a++)
|
TextBox textBox = textBoxes.elementAt(a);
|
||||||
{
|
|
||||||
TextBox textBox = (TextBox) textBoxes.elementAt(a);
|
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.setFont(rd.smallFont);
|
g.setFont(rd.smallFont);
|
||||||
|
|
||||||
@@ -205,35 +183,31 @@ public void DrawTextBoxes(Graphics g, RoomDisplay rd)
|
|||||||
int indexFrom = 0;
|
int indexFrom = 0;
|
||||||
int indexTo;
|
int indexTo;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
// Get the next word in the string
|
// Get the next word in the string
|
||||||
if (indexFrom >= textBox.textString.lastIndexOf(" "))
|
if (indexFrom >= textBox.textString.lastIndexOf(" ")) {
|
||||||
{indexTo = textBox.textString.length();}
|
indexTo = textBox.textString.length();
|
||||||
else
|
}
|
||||||
{indexTo = textBox.textString.indexOf(" ",indexFrom+1);}
|
else {
|
||||||
|
indexTo = textBox.textString.indexOf(" ", indexFrom + 1);
|
||||||
|
}
|
||||||
nextWord = textBox.textString.substring(indexFrom, indexTo);
|
nextWord = textBox.textString.substring(indexFrom, indexTo);
|
||||||
if (nextWord.startsWith(" "))
|
if (nextWord.startsWith(" ")) {
|
||||||
{
|
|
||||||
nextWord = nextWord.substring(1, nextWord.length());
|
nextWord = nextWord.substring(1, nextWord.length());
|
||||||
}
|
}
|
||||||
if (!nextWord.endsWith(" "))
|
if (!nextWord.endsWith(" ")) {
|
||||||
{
|
|
||||||
nextWord = nextWord + " ";
|
nextWord = nextWord + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextWord.startsWith("{BIG}"))
|
if (nextWord.startsWith("{BIG}")) {
|
||||||
{
|
|
||||||
g.setFont(rd.bigFont);
|
g.setFont(rd.bigFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (nextWord.startsWith("{SML}"))
|
else if (nextWord.startsWith("{SML}")) {
|
||||||
{
|
|
||||||
g.setFont(rd.smallFont);
|
g.setFont(rd.smallFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (nextWord.startsWith("{BSP}"))
|
else if (nextWord.startsWith("{BSP}")) {
|
||||||
{
|
|
||||||
FontMetrics fm = g.getFontMetrics();
|
FontMetrics fm = g.getFontMetrics();
|
||||||
advX = fm.stringWidth(" ");
|
advX = fm.stringWidth(" ");
|
||||||
cursX -= advX;
|
cursX -= advX;
|
||||||
@@ -242,8 +216,7 @@ public void DrawTextBoxes(Graphics g, RoomDisplay rd)
|
|||||||
// if (nextWord fits "{rrr,ggg,bbb} "
|
// if (nextWord fits "{rrr,ggg,bbb} "
|
||||||
else if (nextWord.startsWith("{")
|
else if (nextWord.startsWith("{")
|
||||||
&& nextWord.endsWith("} ")
|
&& nextWord.endsWith("} ")
|
||||||
&& nextWord.length()==14)
|
&& nextWord.length() == 14) {
|
||||||
{
|
|
||||||
// extract rrr,ggg,bbb
|
// extract rrr,ggg,bbb
|
||||||
Integer rr = new Integer(nextWord.substring(1, 4));
|
Integer rr = new Integer(nextWord.substring(1, 4));
|
||||||
Integer gg = new Integer(nextWord.substring(5, 8));
|
Integer gg = new Integer(nextWord.substring(5, 8));
|
||||||
@@ -252,22 +225,20 @@ public void DrawTextBoxes(Graphics g, RoomDisplay rd)
|
|||||||
gg.intValue(),
|
gg.intValue(),
|
||||||
bb.intValue()));
|
bb.intValue()));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
FontMetrics fm = g.getFontMetrics();
|
FontMetrics fm = g.getFontMetrics();
|
||||||
if (fm.getAscent() > advY)
|
if (fm.getAscent() > advY) {
|
||||||
{advY = fm.getAscent() ;}
|
advY = fm.getAscent();
|
||||||
|
}
|
||||||
advX = fm.stringWidth(nextWord);
|
advX = fm.stringWidth(nextWord);
|
||||||
if (cursX+advX > textBox.width + textBox.x)
|
if (cursX + advX > textBox.width + textBox.x) {
|
||||||
{
|
|
||||||
cursX = textBox.x;
|
cursX = textBox.x;
|
||||||
cursY += advY;
|
cursY += advY;
|
||||||
advY = fm.getAscent();
|
advY = fm.getAscent();
|
||||||
}
|
}
|
||||||
g.drawString(nextWord, cursX, cursY);
|
g.drawString(nextWord, cursX, cursY);
|
||||||
cursX += advX;
|
cursX += advX;
|
||||||
if (cursX+advX > textBox.width + textBox.x)
|
if (cursX + advX > textBox.width + textBox.x) {
|
||||||
{
|
|
||||||
cursX = textBox.x;
|
cursX = textBox.x;
|
||||||
cursY += advY;
|
cursY += advY;
|
||||||
advY = fm.getAscent();
|
advY = fm.getAscent();
|
||||||
@@ -279,61 +250,56 @@ public void DrawTextBoxes(Graphics g, RoomDisplay rd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawGraphix(Graphics g, RoomDisplay rd)
|
public void DrawGraphix(Graphics g, RoomDisplay rd) {
|
||||||
{
|
for (int a = 0; a < graphix.size(); a++) {
|
||||||
for (int a = 0; a< graphix.size(); a++)
|
Graphix grx = graphix.elementAt(a);
|
||||||
{
|
|
||||||
Graphix grx = (Graphix) graphix.elementAt(a);
|
|
||||||
grx.Draw(g, rd);
|
grx.Draw(g, rd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawArrows(Graphics g)
|
public void DrawArrows(Graphics g) {
|
||||||
{
|
for (int a = 0; a < arrows.size(); a++) {
|
||||||
for (int a = 0; a< arrows.size(); a++)
|
arrows.elementAt(a).Draw(g);
|
||||||
((Arrow) arrows.elementAt(a)).Draw(g);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room getUpRoom(Item item)
|
public Room getUpRoom(Item item) {
|
||||||
{
|
|
||||||
return upRoom;
|
return upRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room getDownRoom(Item item)
|
public Room getDownRoom(Item item) {
|
||||||
{
|
|
||||||
return downRoom;
|
return downRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room getLeftRoom(Item item)
|
public Room getLeftRoom(Item item) {
|
||||||
{
|
|
||||||
return leftRoom;
|
return leftRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room getRightRoom(Item item)
|
public Room getRightRoom(Item item) {
|
||||||
{
|
|
||||||
return rightRoom;
|
return rightRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Wire FindWire(int wireIndex)
|
public Wire FindWire(int wireIndex) {
|
||||||
{
|
if (wireIndex == -1) {
|
||||||
if (wireIndex==-1) return null;
|
return null;
|
||||||
if (wireIndex>=wires.size()) return null;
|
}
|
||||||
return (Wire) wires.elementAt(wireIndex);
|
if (wireIndex >= wires.size()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return wires.elementAt(wireIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone()
|
public Object clone() {
|
||||||
{
|
|
||||||
Object newObject = null;
|
Object newObject = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
newObject = super.clone();
|
newObject = super.clone();
|
||||||
}
|
}
|
||||||
catch (CloneNotSupportedException e) {}
|
catch (CloneNotSupportedException e) {
|
||||||
|
}
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
upRoom = null;
|
upRoom = null;
|
||||||
downRoom = null;
|
downRoom = null;
|
||||||
rightRoom = null;
|
rightRoom = null;
|
||||||
@@ -341,9 +307,8 @@ public void Erase()
|
|||||||
portalItem = null;
|
portalItem = null;
|
||||||
arrows.clear();
|
arrows.clear();
|
||||||
graphix.clear();
|
graphix.clear();
|
||||||
for (int a=0; a< wires.size(); a++)
|
for (int a = 0; a < wires.size(); a++) {
|
||||||
{
|
Wire wire = wires.elementAt(a);
|
||||||
Wire wire = (Wire) wires.elementAt(a);
|
|
||||||
wire.fromPort = null;
|
wire.fromPort = null;
|
||||||
wire.toPort = null;
|
wire.toPort = null;
|
||||||
wire.inPort = null;
|
wire.inPort = null;
|
||||||
|
|||||||
@@ -1,33 +1,5 @@
|
|||||||
package com.droidquest;
|
package com.droidquest;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.geom.AffineTransform;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.Timer;
|
|
||||||
|
|
||||||
import com.droidquest.avatars.LabCursor;
|
import com.droidquest.avatars.LabCursor;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.decorations.Graphix;
|
import com.droidquest.decorations.Graphix;
|
||||||
@@ -38,47 +10,44 @@ import com.droidquest.levels.Level;
|
|||||||
import com.droidquest.levels.MainMenu;
|
import com.droidquest.levels.MainMenu;
|
||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
public class RoomDisplay extends JPanel
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public DQ dq;
|
import java.awt.event.*;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
public class RoomDisplay extends JPanel {
|
||||||
|
public final DQ dq;
|
||||||
Level level;
|
Level level;
|
||||||
public Timer timer;
|
public Timer timer;
|
||||||
int timerspeed=128;
|
private int timerspeed = 128;
|
||||||
public boolean useSounds = true;
|
public boolean useSounds = true;
|
||||||
AffineTransform at = new AffineTransform();
|
private AffineTransform at = new AffineTransform();
|
||||||
|
|
||||||
public Font bigFont;
|
public Font bigFont;
|
||||||
public Font smallFont;
|
public Font smallFont;
|
||||||
private int repeating=0; // Used for repeating keys
|
|
||||||
|
|
||||||
//public boolean isFocusTraversable()
|
public boolean isFocusable() {
|
||||||
// {
|
|
||||||
// Necessary to get the keyboard focus to work with
|
|
||||||
// the ScrenDisplay class.
|
|
||||||
// return(true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public boolean isFocusable()
|
|
||||||
{
|
|
||||||
// Necessary to get the keyboard focus to work with
|
// Necessary to get the keyboard focus to work with
|
||||||
// the ScrenDisplay class.
|
// the ScrenDisplay class.
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoomDisplay()
|
public RoomDisplay(final DQ dq) {
|
||||||
{
|
this.dq = dq;
|
||||||
setSize(new Dimension(560, 384));
|
setSize(new Dimension(560, 384));
|
||||||
level = new MainMenu(this);
|
level = new MainMenu(this);
|
||||||
level.Init();
|
level.Init();
|
||||||
smallFont = new Font("Courier", Font.BOLD, 20);
|
smallFont = new Font("Courier", Font.BOLD, 20);
|
||||||
bigFont = new Font("Courier", Font.BOLD, 45);
|
bigFont = new Font("Courier", Font.BOLD, 45);
|
||||||
// setFocusable(true);
|
|
||||||
requestFocus();
|
requestFocus();
|
||||||
|
|
||||||
// Resizing Fuctions
|
// Resizing Fuctions
|
||||||
addComponentListener(new ComponentAdapter() {
|
addComponentListener(new ComponentAdapter() {
|
||||||
public void componentResized(ComponentEvent e)
|
public void componentResized(ComponentEvent e) {
|
||||||
{
|
|
||||||
Dimension d = new Dimension();
|
Dimension d = new Dimension();
|
||||||
getSize(d);
|
getSize(d);
|
||||||
double w = d.width / 560.0;
|
double w = d.width / 560.0;
|
||||||
@@ -91,22 +60,24 @@ public class RoomDisplay extends JPanel
|
|||||||
addKeyListener(new KeyAdapter() {
|
addKeyListener(new KeyAdapter() {
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
// Event Handler for KeyReleased here
|
// Event Handler for KeyReleased here
|
||||||
if (level.player.KeyUp(e))
|
if (level.player.KeyUp(e)) {
|
||||||
repaint();
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
if (e.getKeyCode() == e.VK_Q)
|
if (e.getKeyCode() == e.VK_Q) {
|
||||||
{
|
if (timerspeed > 1) {
|
||||||
if (timerspeed>1)
|
|
||||||
timerspeed /= 2;
|
timerspeed /= 2;
|
||||||
|
}
|
||||||
timer.setDelay(timerspeed);
|
timer.setDelay(timerspeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getKeyCode() == e.VK_W)
|
if (e.getKeyCode() == e.VK_W) {
|
||||||
{
|
if (timerspeed < 128) {
|
||||||
if (timerspeed<128)
|
|
||||||
timerspeed *= 2;
|
timerspeed *= 2;
|
||||||
if ( (timerspeed>=128) && (level.player instanceof LabCursor) )
|
}
|
||||||
|
if ((timerspeed >= 128) && (level.player instanceof LabCursor)) {
|
||||||
timerspeed *= 2;
|
timerspeed *= 2;
|
||||||
|
}
|
||||||
timer.setDelay(timerspeed);
|
timer.setDelay(timerspeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,9 +87,9 @@ public class RoomDisplay extends JPanel
|
|||||||
// Key Pressed Functions
|
// Key Pressed Functions
|
||||||
addKeyListener(new KeyAdapter() {
|
addKeyListener(new KeyAdapter() {
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
if (level.player.KeyDown(e))
|
if (level.player.KeyDown(e)) {
|
||||||
repaint();
|
repaint();
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -135,56 +106,35 @@ public class RoomDisplay extends JPanel
|
|||||||
});
|
});
|
||||||
|
|
||||||
timer = new Timer(timerspeed, new ActionListener() {
|
timer = new Timer(timerspeed, new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e) {
|
||||||
{
|
if (level.portal != null) {
|
||||||
if (level.portal != null)
|
|
||||||
{
|
|
||||||
String filename = level.portal.levelName;
|
String filename = level.portal.levelName;
|
||||||
boolean bringStuff = level.portal.bringStuff;
|
boolean bringStuff = level.portal.bringStuff;
|
||||||
boolean initLevel = level.portal.initLevel;
|
boolean initLevel = level.portal.initLevel;
|
||||||
int x = level.player.x + level.player.getWidth()/2;
|
|
||||||
int y = level.player.y + level.player.getHeight()/2;
|
|
||||||
Graphics g = getGraphics();
|
|
||||||
level.PlaySound(level.currentViewer.room, Level.TELEPORTSOUND);
|
level.PlaySound(level.currentViewer.room, Level.TELEPORTSOUND);
|
||||||
boolean tempsound = level.roomdisplay.useSounds;
|
boolean tempsound = level.roomdisplay.useSounds;
|
||||||
level.roomdisplay.useSounds = false;
|
level.roomdisplay.useSounds = false;
|
||||||
// for (int a=0; a<560; a+=2)
|
if (bringStuff) {
|
||||||
// {
|
|
||||||
// int c = 255*a/560;
|
|
||||||
// g.setColor(new Color(c,255-c,0));
|
|
||||||
// g.drawRect(x-a-1,y-a-1,a*2+2,a*2+2);
|
|
||||||
// g.setColor(Color.black);
|
|
||||||
// g.drawRect(x-a,y-a,a*2,a*2);
|
|
||||||
// long timeout = System.currentTimeMillis() + 1;
|
|
||||||
// do {} while (System.currentTimeMillis() < timeout);
|
|
||||||
// }
|
|
||||||
// g.setColor(Color.black);
|
|
||||||
// for (int a=0; a<560; a++)
|
|
||||||
// {
|
|
||||||
// g.drawRect(x-a,y-a,a*2,a*2);
|
|
||||||
// long timeout = System.currentTimeMillis() + 1;
|
|
||||||
// do {} while (System.currentTimeMillis() < timeout);
|
|
||||||
// }
|
|
||||||
if (bringStuff)
|
|
||||||
{
|
|
||||||
System.out.println("Saving carried items.");
|
System.out.println("Saving carried items.");
|
||||||
level.WriteInventory();
|
level.WriteInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInputStream f;
|
FileInputStream f;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
f = new FileInputStream(filename);
|
f = new FileInputStream(filename);
|
||||||
try {f.close();} catch (IOException ie){}
|
try {
|
||||||
|
f.close();
|
||||||
}
|
}
|
||||||
catch(FileNotFoundException ie)
|
catch (IOException ie) {
|
||||||
{
|
}
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException ie) {
|
||||||
// filename does not exist
|
// filename does not exist
|
||||||
RoomDisplay rd = level.roomdisplay;
|
RoomDisplay rd = level.roomdisplay;
|
||||||
String classname = "com.droidquest.levels." + filename.substring(0, filename.length() - 4);
|
String classname = "com.droidquest.levels." + filename.substring(0, filename.length() - 4);
|
||||||
Constructor constructor = null;
|
Constructor constructor = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Class newlevel = Class.forName(classname);
|
Class newlevel = Class.forName(classname);
|
||||||
Class[] arglist = {Class.forName("com.droidquest.RoomDisplay")};
|
Class[] arglist = {Class.forName("com.droidquest.RoomDisplay")};
|
||||||
constructor = newlevel.getConstructor(arglist);
|
constructor = newlevel.getConstructor(arglist);
|
||||||
@@ -195,36 +145,31 @@ public class RoomDisplay extends JPanel
|
|||||||
}
|
}
|
||||||
catch (NoSuchMethodException ne) {
|
catch (NoSuchMethodException ne) {
|
||||||
ne.printStackTrace();
|
ne.printStackTrace();
|
||||||
};
|
}
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Object[] args = {rd};
|
Object[] args = {rd};
|
||||||
level = (Level) constructor.newInstance(args);
|
level = (Level) constructor.newInstance(args);
|
||||||
rd.SaveLevel();
|
rd.SaveLevel();
|
||||||
}
|
}
|
||||||
catch(InstantiationException ie2)
|
catch (InstantiationException ie2) {
|
||||||
{
|
|
||||||
System.out.println("Instantiation");
|
System.out.println("Instantiation");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
catch(IllegalAccessException ie2)
|
catch (IllegalAccessException ie2) {
|
||||||
{
|
|
||||||
System.out.println("Illegal Access");
|
System.out.println("Illegal Access");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
catch(IllegalArgumentException ie2)
|
catch (IllegalArgumentException ie2) {
|
||||||
{
|
|
||||||
System.out.println("Illegal Argument");
|
System.out.println("Illegal Argument");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
catch(InvocationTargetException ie2)
|
catch (InvocationTargetException ie2) {
|
||||||
{
|
|
||||||
System.out.println("Invocation Target");
|
System.out.println("Invocation Target");
|
||||||
Throwable t = ie2.getTargetException();
|
Throwable t = ie2.getTargetException();
|
||||||
ie2.printStackTrace();
|
ie2.printStackTrace();
|
||||||
System.out.println(t.getClass());
|
System.out.println(t.getClass());
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
// {
|
// {
|
||||||
// look for a class that matches the name "filename" without the ".lvl"
|
// look for a class that matches the name "filename" without the ".lvl"
|
||||||
@@ -233,66 +178,81 @@ public class RoomDisplay extends JPanel
|
|||||||
|
|
||||||
System.out.println("Loading level " + filename);
|
System.out.println("Loading level " + filename);
|
||||||
LoadLevel(filename);
|
LoadLevel(filename);
|
||||||
if (initLevel)
|
if (initLevel) {
|
||||||
{
|
|
||||||
System.out.println("Initializing Level");
|
System.out.println("Initializing Level");
|
||||||
level.Init();
|
level.Init();
|
||||||
}
|
}
|
||||||
if (bringStuff)
|
if (bringStuff) {
|
||||||
{
|
|
||||||
System.out.println("Loading carried items.");
|
System.out.println("Loading carried items.");
|
||||||
level.LoadInventory();
|
level.LoadInventory();
|
||||||
}
|
}
|
||||||
x = level.player.x + level.player.getWidth()/2;
|
|
||||||
y = level.player.y + level.player.getHeight()/2;
|
|
||||||
|
|
||||||
// for (int a=560; a>0; a-=2)
|
|
||||||
// {
|
|
||||||
// int c = 255*a/560;
|
|
||||||
// g.setColor(new Color(255-c,c,0));
|
|
||||||
// g.drawRect(x-a-1,y-a-1,a*2+2,a*2+2);
|
|
||||||
// g.setColor(Color.black);
|
|
||||||
// g.drawRect(x-a,y-a,a*2,a*2);
|
|
||||||
// long timeout = System.currentTimeMillis() + 1;
|
|
||||||
// do {} while (System.currentTimeMillis() < timeout);
|
|
||||||
// }
|
|
||||||
// g.setColor(Color.black);
|
|
||||||
// for (int a=560; a>0; a--)
|
|
||||||
// {
|
|
||||||
// g.drawRect(x-a,y-a,a*2,a*2);
|
|
||||||
// long timeout = System.currentTimeMillis() + 1;
|
|
||||||
// do {} while (System.currentTimeMillis() < timeout);
|
|
||||||
// }
|
|
||||||
level.roomdisplay.useSounds = tempsound;
|
level.roomdisplay.useSounds = tempsound;
|
||||||
level.PlaySound(level.currentViewer.room, Level.TRANSPORTSOUND);
|
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();
|
Electricity();
|
||||||
for (int a = 0; a < level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
item.Animate();
|
item.Animate();
|
||||||
if (item.room == level.currentViewer.room)
|
if (item.room == level.currentViewer.room) {
|
||||||
item.Decorate();
|
item.Decorate();
|
||||||
}
|
}
|
||||||
for (int a=0; a<level.materials.size(); a++)
|
}
|
||||||
((Material) level.materials.elementAt(a)).Animate();
|
for (int a = 0; a < level.materials.size(); a++) {
|
||||||
for (int a=0; a<level.rooms.size(); a++)
|
level.materials.elementAt(a).Animate();
|
||||||
{
|
}
|
||||||
Room room = (Room) level.rooms.elementAt(a);
|
for (int a = 0; a < level.rooms.size(); a++) {
|
||||||
for (int b=0; b<room.graphix.size(); b++)
|
Room room = level.rooms.elementAt(a);
|
||||||
{
|
for (int b = 0; b < room.graphix.size(); b++) {
|
||||||
Graphix graphix = (Graphix) room.graphix.elementAt(b);
|
Graphix graphix = room.graphix.elementAt(b);
|
||||||
graphix.Animate();
|
graphix.Animate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
for (int a = 0; a< level.sparks.size(); a++)
|
for (int a = 0; a < level.sparks.size(); a++) {
|
||||||
{
|
Spark spark = level.sparks.elementAt(a);
|
||||||
Spark spark = (Spark)level.sparks.elementAt(a);
|
|
||||||
spark.Age();
|
spark.Age();
|
||||||
if (spark.age>6)
|
if (spark.age > 6) {
|
||||||
{
|
|
||||||
level.sparks.removeElement(spark);
|
level.sparks.removeElement(spark);
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
@@ -302,44 +262,44 @@ public class RoomDisplay extends JPanel
|
|||||||
|
|
||||||
Image tempImage = new BufferedImage(200, 200, BufferedImage.TYPE_4BYTE_ABGR);
|
Image tempImage = new BufferedImage(200, 200, BufferedImage.TYPE_4BYTE_ABGR);
|
||||||
Graphics g = tempImage.getGraphics();
|
Graphics g = tempImage.getGraphics();
|
||||||
Image tempIcon;
|
|
||||||
ImageIcon tempImageIcon;
|
ImageIcon tempImageIcon;
|
||||||
|
|
||||||
for (int a = 0; a<level.materials.size(); a++)
|
for (int a = 0; a < level.materials.size(); a++) {
|
||||||
{
|
Material mat = level.materials.elementAt(a);
|
||||||
Material mat = (Material) level.materials.elementAt(a);
|
|
||||||
tempImageIcon = mat.icon;
|
tempImageIcon = mat.icon;
|
||||||
if (tempImageIcon != null)
|
if (tempImageIcon != null) {
|
||||||
g.drawImage(tempImageIcon.getImage(), 0, 0, this);
|
g.drawImage(tempImageIcon.getImage(), 0, 0, this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int a = 0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item itm = level.items.elementAt(a);
|
||||||
Item itm = (Item) level.items.elementAt(a);
|
for (int b = 0; b < itm.icons.length; b++) {
|
||||||
for (int b=0; b<itm.icons.length; b++)
|
|
||||||
{
|
|
||||||
tempImageIcon = itm.icons[b];
|
tempImageIcon = itm.icons[b];
|
||||||
if (tempImageIcon != null)
|
if (tempImageIcon != null) {
|
||||||
g.drawImage(tempImageIcon.getImage(), 0, 0, this);
|
g.drawImage(tempImageIcon.getImage(), 0, 0, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
timer.start();
|
timer.start();
|
||||||
level.PlaySound(level.player.room, Level.STARTMUSICSOUND);
|
level.PlaySound(level.player.room, Level.STARTMUSICSOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintComponent(Graphics g)
|
public void paintComponent(Graphics g) {
|
||||||
{
|
|
||||||
super.paintComponents(g); // Paint background
|
super.paintComponents(g); // Paint background
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
g2.setTransform(at);
|
g2.setTransform(at);
|
||||||
|
|
||||||
// Paint Materials
|
// Paint Materials
|
||||||
if (level.currentViewer.room.MaterialArray==null)
|
if (level.currentViewer.room.MaterialArray == null) {
|
||||||
level.currentViewer.room.GenerateArray();
|
level.currentViewer.room.GenerateArray();
|
||||||
for (int y=0; y<12; y++)
|
}
|
||||||
for (int x=0;x<20;x++)
|
for (int y = 0; y < 12; y++) {
|
||||||
|
for (int x = 0; x < 20; x++) {
|
||||||
level.currentViewer.room.MaterialArray[y][x].Draw(g2, this, x, y);
|
level.currentViewer.room.MaterialArray[y][x].Draw(g2, this, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Paint Texts
|
// Paint Texts
|
||||||
level.currentViewer.room.DrawTextBoxes(g2, this);
|
level.currentViewer.room.DrawTextBoxes(g2, this);
|
||||||
@@ -351,21 +311,24 @@ public class RoomDisplay extends JPanel
|
|||||||
level.currentViewer.room.DrawArrows(g2);
|
level.currentViewer.room.DrawArrows(g2);
|
||||||
|
|
||||||
// Paint Items
|
// Paint Items
|
||||||
for (int a = 0; a < level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
if (level.currentViewer.room == ((Item) level.items.elementAt(a)).room)
|
if (level.currentViewer.room == level.items.elementAt(a).room) {
|
||||||
((Item) level.items.elementAt(a)).Draw(g2,this);
|
level.items.elementAt(a).Draw(g2, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Paint Wires
|
// Paint Wires
|
||||||
for (int a = 0; a< level.currentViewer.room.wires.size(); a++)
|
for (int a = 0; a < level.currentViewer.room.wires.size(); a++) {
|
||||||
((Wire) level.currentViewer.room.wires.elementAt(a)).Draw(g2);
|
level.currentViewer.room.wires.elementAt(a).Draw(g2);
|
||||||
|
}
|
||||||
|
|
||||||
// Paint Sparks
|
// Paint Sparks
|
||||||
for (int a = 0; a< level.sparks.size(); a++)
|
for (int a = 0; a < level.sparks.size(); a++) {
|
||||||
{
|
Spark spark = level.sparks.elementAt(a);
|
||||||
Spark spark = (Spark)level.sparks.elementAt(a);
|
if (spark.room == level.currentViewer.room) {
|
||||||
if (spark.room == level.currentViewer.room)
|
|
||||||
spark.Draw(g2);
|
spark.Draw(g2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Repaint the Current Player on top of everything else
|
// Repaint the Current Player on top of everything else
|
||||||
// if (level.currentViewer.room == level.player.room)
|
// if (level.currentViewer.room == level.player.room)
|
||||||
@@ -376,49 +339,45 @@ public class RoomDisplay extends JPanel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Electricity()
|
void Electricity() {
|
||||||
{
|
if (!level.electricity) {
|
||||||
if (level.electricity == false)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.isDevice()) {
|
||||||
if (item.isDevice())
|
|
||||||
{
|
|
||||||
Device device = (Device) item;
|
Device device = (Device) item;
|
||||||
for (int b=0; b<device.ports.length; b++)
|
for (int b = 0; b < device.ports.length; b++) {
|
||||||
{
|
|
||||||
Wire wire = device.ports[b].myWire;
|
Wire wire = device.ports[b].myWire;
|
||||||
if (wire != null)
|
if (wire != null) {
|
||||||
{
|
if (wire.inPort != null && wire.outPort != null) {
|
||||||
if (wire.inPort != null && wire.outPort!=null)
|
|
||||||
{
|
|
||||||
wire.value = wire.outPort.value;
|
wire.value = wire.outPort.value;
|
||||||
wire.inPort.value = wire.value;
|
wire.inPort.value = wire.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (device.ports[b].type == Port.TYPE_INPUT)
|
else if (device.ports[b].type == Port.TYPE_INPUT) {
|
||||||
{
|
|
||||||
device.ports[b].value = false;
|
device.ports[b].value = false;
|
||||||
if (level.gameCursor instanceof LabCursor)
|
if (level.gameCursor instanceof LabCursor) {
|
||||||
if (device.room == level.gameCursor.room)
|
if (device.room == level.gameCursor.room) {
|
||||||
if (device.ports[b].x + device.x >= level.gameCursor.x
|
if (device.ports[b].x + device.x >= level.gameCursor.x
|
||||||
&& device.ports[b].x + device.x <= level.gameCursor.x + level.gameCursor.getWidth()
|
&& device.ports[b].x + device.x <= level.gameCursor.x + level.gameCursor.getWidth()
|
||||||
&& device.ports[b].y + device.y >= level.gameCursor.y
|
&& device.ports[b].y + device.y >= level.gameCursor.y
|
||||||
&& device.ports[b].y+device.y <= level.gameCursor.y + level.gameCursor.getHeight())
|
&& device.ports[b].y + device.y <= level.gameCursor.y + level.gameCursor.getHeight()) {
|
||||||
if (((LabCursor)level.gameCursor).hot)
|
if (((LabCursor) level.gameCursor).hot) {
|
||||||
device.ports[b].value = true;
|
device.ports[b].value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.isDevice()) {
|
||||||
if (item.isDevice())
|
|
||||||
{
|
|
||||||
Device device = (Device) item;
|
Device device = (Device) item;
|
||||||
device.Function();
|
device.Function();
|
||||||
}
|
}
|
||||||
@@ -427,43 +386,40 @@ public class RoomDisplay extends JPanel
|
|||||||
|
|
||||||
boolean nodeChanged;
|
boolean nodeChanged;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
nodeChanged = false;
|
nodeChanged = false;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.isDevice()) {
|
||||||
if (item.isDevice())
|
|
||||||
{
|
|
||||||
Device device = (Device) item;
|
Device device = (Device) item;
|
||||||
for (int b=0; b<device.ports.length; b++)
|
for (int b = 0; b < device.ports.length; b++) {
|
||||||
{
|
|
||||||
Wire wire = device.ports[b].myWire;
|
Wire wire = device.ports[b].myWire;
|
||||||
if (wire != null)
|
if (wire != null) {
|
||||||
{
|
if (wire.inPort != null && wire.outPort != null) {
|
||||||
if (wire.inPort != null && wire.outPort!=null)
|
|
||||||
{
|
|
||||||
wire.value = wire.outPort.value;
|
wire.value = wire.outPort.value;
|
||||||
wire.inPort.value = wire.value;
|
wire.inPort.value = wire.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (device.ports[b].type == Port.TYPE_INPUT)
|
else if (device.ports[b].type == Port.TYPE_INPUT) {
|
||||||
{
|
|
||||||
device.ports[b].value = false;
|
device.ports[b].value = false;
|
||||||
if (level.gameCursor instanceof LabCursor)
|
if (level.gameCursor instanceof LabCursor) {
|
||||||
if (device.room == level.gameCursor.room)
|
if (device.room == level.gameCursor.room) {
|
||||||
if (device.ports[b].x + device.x >= level.gameCursor.x
|
if (device.ports[b].x + device.x >= level.gameCursor.x
|
||||||
&& device.ports[b].x + device.x <= level.gameCursor.x + level.gameCursor.getWidth()
|
&& device.ports[b].x + device.x <= level.gameCursor.x + level.gameCursor.getWidth()
|
||||||
&& device.ports[b].y + device.y >= level.gameCursor.y
|
&& device.ports[b].y + device.y >= level.gameCursor.y
|
||||||
&& device.ports[b].y+device.y <= level.gameCursor.y + level.gameCursor.getHeight())
|
&& device.ports[b].y + device.y <= level.gameCursor.y + level.gameCursor.getHeight()) {
|
||||||
if (((LabCursor)level.gameCursor).hot)
|
if (((LabCursor) level.gameCursor).hot) {
|
||||||
device.ports[b].value = true;
|
device.ports[b].value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (device.isNode())
|
}
|
||||||
{
|
}
|
||||||
if (device.Function())
|
}
|
||||||
|
}
|
||||||
|
if (device.isNode()) {
|
||||||
|
if (device.Function()) {
|
||||||
nodeChanged = true;
|
nodeChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,23 +430,21 @@ public class RoomDisplay extends JPanel
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveLevel()
|
void SaveLevel() {
|
||||||
{
|
|
||||||
String temp = level.getClass().toString();
|
String temp = level.getClass().toString();
|
||||||
System.out.println("Class name is " + temp);
|
System.out.println("Class name is " + temp);
|
||||||
String[] path = temp.split("\\.");
|
String[] path = temp.split("\\.");
|
||||||
for (int a=0; a< path.length; a++)
|
for (int a = 0; a < path.length; a++) {
|
||||||
System.out.println(a + " = " + path[a]);
|
System.out.println(a + " = " + path[a]);
|
||||||
|
}
|
||||||
// String filename = temp.substring(6);
|
// String filename = temp.substring(6);
|
||||||
String filename = path[path.length - 1];
|
String filename = path[path.length - 1];
|
||||||
SaveLevel(filename + ".lvl");
|
SaveLevel(filename + ".lvl");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveLevel(String filename)
|
public void SaveLevel(String filename) {
|
||||||
{
|
|
||||||
System.out.println("Saving level " + filename);
|
System.out.println("Saving level " + filename);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
FileOutputStream out = new FileOutputStream(filename);
|
FileOutputStream out = new FileOutputStream(filename);
|
||||||
ObjectOutputStream s = new ObjectOutputStream(out);
|
ObjectOutputStream s = new ObjectOutputStream(out);
|
||||||
level.writeObject(s);
|
level.writeObject(s);
|
||||||
@@ -498,19 +452,16 @@ public class RoomDisplay extends JPanel
|
|||||||
s.close();
|
s.close();
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e) {
|
||||||
{
|
|
||||||
System.out.println("File Not Found");
|
System.out.println("File Not Found");
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e) {
|
||||||
{
|
|
||||||
System.out.println("IO Exception");
|
System.out.println("IO Exception");
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadLevel(String filename)
|
void LoadLevel(String filename) {
|
||||||
{
|
|
||||||
timer.stop();
|
timer.stop();
|
||||||
level.Empty();
|
level.Empty();
|
||||||
level = new Level(this);
|
level = new Level(this);
|
||||||
@@ -519,31 +470,26 @@ public class RoomDisplay extends JPanel
|
|||||||
Material.level = level;
|
Material.level = level;
|
||||||
|
|
||||||
// Add flags for loading Object inventories or running Init()
|
// Add flags for loading Object inventories or running Init()
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
FileInputStream in = new FileInputStream(filename);
|
FileInputStream in = new FileInputStream(filename);
|
||||||
ObjectInputStream s = new ObjectInputStream(in);
|
ObjectInputStream s = new ObjectInputStream(in);
|
||||||
level.readObject(s);
|
level.readObject(s);
|
||||||
s.close();
|
s.close();
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e) {
|
||||||
{
|
|
||||||
System.out.println("File Not Found");
|
System.out.println("File Not Found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e) {
|
||||||
{
|
|
||||||
System.out.println("IO Exception");
|
System.out.println("IO Exception");
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level.remote != null)
|
if (level.remote != null) {
|
||||||
{
|
if (level.electricity) {
|
||||||
if (level.electricity)
|
|
||||||
{
|
|
||||||
level.remote.x = 28;
|
level.remote.x = 28;
|
||||||
level.remote.y = -20;
|
level.remote.y = -20;
|
||||||
level.remote.carriedBy = level.player;
|
level.remote.carriedBy = level.player;
|
||||||
|
|||||||
@@ -5,23 +5,19 @@ import java.applet.AudioClip;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class SoundClip
|
public class SoundClip {
|
||||||
{
|
|
||||||
public AudioClip audioClip;
|
public AudioClip audioClip;
|
||||||
public String filename;
|
private String filename;
|
||||||
|
|
||||||
public SoundClip(String f)
|
public SoundClip(String f) {
|
||||||
{
|
|
||||||
filename = f;
|
filename = f;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
URL baseURL = new URL("file:" + System.getProperty("user.dir") + "/sounds/");
|
URL baseURL = new URL("file:" + System.getProperty("user.dir") + "/sounds/");
|
||||||
URL soundURL;
|
URL soundURL;
|
||||||
soundURL = new URL(baseURL, filename);
|
soundURL = new URL(baseURL, filename);
|
||||||
audioClip = Applet.newAudioClip(soundURL);
|
audioClip = Applet.newAudioClip(soundURL);
|
||||||
}
|
}
|
||||||
catch (MalformedURLException e)
|
catch (MalformedURLException e) {
|
||||||
{
|
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +1,49 @@
|
|||||||
package com.droidquest;
|
package com.droidquest;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.devices.Device;
|
import com.droidquest.devices.Device;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class Wire implements Serializable
|
import java.awt.*;
|
||||||
{
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Wire implements Serializable {
|
||||||
public transient Port fromPort; // Connected First
|
public transient Port fromPort; // Connected First
|
||||||
public transient Port toPort; // Connected 2nd
|
public transient Port toPort; // Connected 2nd
|
||||||
public transient Port inPort; // Connected to Input
|
public transient Port inPort; // Connected to Input
|
||||||
public transient Port outPort; // Connected to Output (Source of Value)
|
public transient Port outPort; // Connected to Output (Source of Value)
|
||||||
public boolean value;
|
public boolean value;
|
||||||
|
|
||||||
public Wire() {}
|
public Wire() {
|
||||||
|
}
|
||||||
|
|
||||||
public Wire(Port f, Port t)
|
public Wire(Port f, Port t) {
|
||||||
{
|
if (f.myDevice != null) {
|
||||||
if (f.myDevice!=null)
|
if (f.myDevice.room != null) {
|
||||||
{
|
if (f.myDevice.room.wires == null) {
|
||||||
if (f.myDevice.room!=null)
|
|
||||||
{
|
|
||||||
if (f.myDevice.room.wires==null)
|
|
||||||
System.out.println("f.myDevice.room.wires is null");
|
System.out.println("f.myDevice.room.wires is null");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
System.out.println("f.myDevice.room is null");
|
System.out.println("f.myDevice.room is null");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
System.out.println("f.myDevice is null");
|
System.out.println("f.myDevice is null");
|
||||||
|
}
|
||||||
|
|
||||||
f.myDevice.room.wires.addElement(this);
|
f.myDevice.room.wires.addElement(this);
|
||||||
f.myDevice.level.PlaySound(f.myDevice.room, Level.ATTACHSOUND);
|
f.myDevice.level.PlaySound(f.myDevice.room, Level.ATTACHSOUND);
|
||||||
|
|
||||||
if (f.type == Port.TYPE_INPUT)
|
if (f.type == Port.TYPE_INPUT) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
Remove();
|
Remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
fromPort = f;
|
fromPort = f;
|
||||||
toPort = t;
|
toPort = t;
|
||||||
f.myWire = this;
|
f.myWire = this;
|
||||||
@@ -57,8 +52,7 @@ public Wire(Port f, Port t)
|
|||||||
outPort = toPort;
|
outPort = toPort;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
fromPort = f;
|
fromPort = f;
|
||||||
toPort = t;
|
toPort = t;
|
||||||
f.myWire = this;
|
f.myWire = this;
|
||||||
@@ -69,10 +63,8 @@ public Wire(Port f, Port t)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (f.type == Port.TYPE_OUTPUT)
|
if (f.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
fromPort = f;
|
fromPort = f;
|
||||||
toPort = t;
|
toPort = t;
|
||||||
f.myWire = this;
|
f.myWire = this;
|
||||||
@@ -81,13 +73,11 @@ public Wire(Port f, Port t)
|
|||||||
inPort = toPort;
|
inPort = toPort;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Remove();
|
Remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
fromPort = f;
|
fromPort = f;
|
||||||
toPort = t;
|
toPort = t;
|
||||||
f.myWire = this;
|
f.myWire = this;
|
||||||
@@ -98,10 +88,8 @@ public Wire(Port f, Port t)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (f.type == Port.TYPE_UNDEFINED)
|
if (f.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
fromPort = f;
|
fromPort = f;
|
||||||
toPort = t;
|
toPort = t;
|
||||||
f.myWire = this;
|
f.myWire = this;
|
||||||
@@ -111,8 +99,7 @@ public Wire(Port f, Port t)
|
|||||||
f.type = Port.TYPE_OUTPUT;
|
f.type = Port.TYPE_OUTPUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
fromPort = f;
|
fromPort = f;
|
||||||
toPort = t;
|
toPort = t;
|
||||||
f.myWire = this;
|
f.myWire = this;
|
||||||
@@ -122,41 +109,49 @@ public Wire(Port f, Port t)
|
|||||||
f.type = Port.TYPE_INPUT;
|
f.type = Port.TYPE_INPUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
fromPort = f;
|
fromPort = f;
|
||||||
toPort = t;
|
toPort = t;
|
||||||
f.myWire = this;
|
f.myWire = this;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeRef(ObjectOutputStream s) throws IOException
|
void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
Level level = fromPort.myDevice.level;
|
Level level = fromPort.myDevice.level;
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
s.writeInt(level.items.indexOf(fromPort.myDevice)); // Index of fromport device
|
s.writeInt(level.items.indexOf(fromPort.myDevice)); // Index of fromport device
|
||||||
a=0; while (((Device)fromPort.myDevice).ports[a] != fromPort) a++;
|
a = 0;
|
||||||
|
while (((Device) fromPort.myDevice).ports[a] != fromPort) {
|
||||||
|
a++;
|
||||||
|
}
|
||||||
s.writeInt(a); // Index of fromport (as device.ports[?]
|
s.writeInt(a); // Index of fromport (as device.ports[?]
|
||||||
|
|
||||||
s.writeInt(level.items.indexOf(toPort.myDevice)); // Index of toPort device
|
s.writeInt(level.items.indexOf(toPort.myDevice)); // Index of toPort device
|
||||||
a=0; while (((Device)toPort.myDevice).ports[a] != toPort) a++;
|
a = 0;
|
||||||
|
while (((Device) toPort.myDevice).ports[a] != toPort) {
|
||||||
|
a++;
|
||||||
|
}
|
||||||
s.writeInt(a); // Index of toPort (as device.ports[?]
|
s.writeInt(a); // Index of toPort (as device.ports[?]
|
||||||
|
|
||||||
s.writeInt(level.items.indexOf(inPort.myDevice)); // Index of inPort device
|
s.writeInt(level.items.indexOf(inPort.myDevice)); // Index of inPort device
|
||||||
a=0; while (((Device)inPort.myDevice).ports[a] != inPort) a++;
|
a = 0;
|
||||||
|
while (((Device) inPort.myDevice).ports[a] != inPort) {
|
||||||
|
a++;
|
||||||
|
}
|
||||||
s.writeInt(a); // Index of inPort (as device.ports[?]
|
s.writeInt(a); // Index of inPort (as device.ports[?]
|
||||||
|
|
||||||
s.writeInt(level.items.indexOf(outPort.myDevice)); // Index of outPort device
|
s.writeInt(level.items.indexOf(outPort.myDevice)); // Index of outPort device
|
||||||
a=0; while (((Device)outPort.myDevice).ports[a] != outPort) a++;
|
a = 0;
|
||||||
|
while (((Device) outPort.myDevice).ports[a] != outPort) {
|
||||||
|
a++;
|
||||||
|
}
|
||||||
s.writeInt(a); // Index of outPort (as device.ports[?]
|
s.writeInt(a); // Index of outPort (as device.ports[?]
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void readRef(ObjectInputStream s, Level level) throws IOException
|
void readRef(ObjectInputStream s, Level level) throws IOException {
|
||||||
{
|
|
||||||
Device tempDevice;
|
Device tempDevice;
|
||||||
tempDevice = (Device) level.FindItem(s.readInt());
|
tempDevice = (Device) level.FindItem(s.readInt());
|
||||||
fromPort = tempDevice.ports[s.readInt()];
|
fromPort = tempDevice.ports[s.readInt()];
|
||||||
@@ -168,33 +163,27 @@ protected void readRef(ObjectInputStream s, Level level) throws IOException
|
|||||||
outPort = tempDevice.ports[s.readInt()];
|
outPort = tempDevice.ports[s.readInt()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectTo(Port t)
|
public void ConnectTo(Port t) {
|
||||||
{
|
|
||||||
fromPort.myDevice.level.PlaySound(fromPort.myDevice.room, Level.DETATCHSOUND);
|
fromPort.myDevice.level.PlaySound(fromPort.myDevice.room, Level.DETATCHSOUND);
|
||||||
|
|
||||||
if (toPort.myDevice == toPort.myDevice.level.solderingPen)
|
if (toPort.myDevice == toPort.myDevice.level.solderingPen) {
|
||||||
{
|
|
||||||
toPort.value = false;
|
toPort.value = false;
|
||||||
toPort.type = Port.TYPE_UNDEFINED;
|
toPort.type = Port.TYPE_UNDEFINED;
|
||||||
toPort.myWire = null;
|
toPort.myWire = null;
|
||||||
|
|
||||||
if (fromPort.type == Port.TYPE_INPUT)
|
if (fromPort.type == Port.TYPE_INPUT) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
Remove();
|
Remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
toPort = t;
|
toPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
inPort = fromPort;
|
inPort = fromPort;
|
||||||
outPort = toPort;
|
outPort = toPort;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
toPort = t;
|
toPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
inPort = fromPort;
|
inPort = fromPort;
|
||||||
@@ -203,23 +192,19 @@ public void ConnectTo(Port t)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fromPort.type == Port.TYPE_OUTPUT)
|
if (fromPort.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
toPort = t;
|
toPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
outPort = fromPort;
|
outPort = fromPort;
|
||||||
inPort = toPort;
|
inPort = toPort;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Remove();
|
Remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
toPort = t;
|
toPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
outPort = fromPort;
|
outPort = fromPort;
|
||||||
@@ -228,10 +213,8 @@ public void ConnectTo(Port t)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fromPort.type == Port.TYPE_UNDEFINED)
|
if (fromPort.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
toPort = t;
|
toPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
outPort = fromPort;
|
outPort = fromPort;
|
||||||
@@ -239,8 +222,7 @@ public void ConnectTo(Port t)
|
|||||||
fromPort.type = Port.TYPE_OUTPUT;
|
fromPort.type = Port.TYPE_OUTPUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
toPort = t;
|
toPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
inPort = fromPort;
|
inPort = fromPort;
|
||||||
@@ -248,37 +230,30 @@ public void ConnectTo(Port t)
|
|||||||
fromPort.type = Port.TYPE_INPUT;
|
fromPort.type = Port.TYPE_INPUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
toPort = t;
|
toPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
fromPort.value = false;
|
fromPort.value = false;
|
||||||
fromPort.type = Port.TYPE_UNDEFINED;
|
fromPort.type = Port.TYPE_UNDEFINED;
|
||||||
fromPort.myWire = null;
|
fromPort.myWire = null;
|
||||||
|
|
||||||
if (toPort.type == Port.TYPE_INPUT)
|
if (toPort.type == Port.TYPE_INPUT) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
Remove();
|
Remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
fromPort = t;
|
fromPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
inPort = toPort;
|
inPort = toPort;
|
||||||
outPort = fromPort;
|
outPort = fromPort;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
fromPort = t;
|
fromPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
inPort = toPort;
|
inPort = toPort;
|
||||||
@@ -287,23 +262,19 @@ public void ConnectTo(Port t)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toPort.type == Port.TYPE_OUTPUT)
|
if (toPort.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
fromPort = t;
|
fromPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
outPort = toPort;
|
outPort = toPort;
|
||||||
inPort = fromPort;
|
inPort = fromPort;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Remove();
|
Remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
fromPort = t;
|
fromPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
outPort = toPort;
|
outPort = toPort;
|
||||||
@@ -312,10 +283,8 @@ public void ConnectTo(Port t)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toPort.type == Port.TYPE_UNDEFINED)
|
if (toPort.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
if (t.type == Port.TYPE_INPUT) {
|
||||||
if (t.type == Port.TYPE_INPUT)
|
|
||||||
{
|
|
||||||
fromPort = t;
|
fromPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
outPort = toPort;
|
outPort = toPort;
|
||||||
@@ -323,8 +292,7 @@ public void ConnectTo(Port t)
|
|||||||
toPort.type = Port.TYPE_OUTPUT;
|
toPort.type = Port.TYPE_OUTPUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_OUTPUT)
|
if (t.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
fromPort = t;
|
fromPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
inPort = toPort;
|
inPort = toPort;
|
||||||
@@ -332,19 +300,16 @@ public void ConnectTo(Port t)
|
|||||||
toPort.type = Port.TYPE_INPUT;
|
toPort.type = Port.TYPE_INPUT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (t.type == Port.TYPE_UNDEFINED)
|
if (t.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
fromPort = t;
|
fromPort = t;
|
||||||
t.myWire = this;
|
t.myWire = this;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove()
|
public void Remove() {
|
||||||
{
|
|
||||||
Room room = fromPort.myDevice.room;
|
Room room = fromPort.myDevice.room;
|
||||||
|
|
||||||
room.level.PlaySound(room, Level.DETATCHSOUND);
|
room.level.PlaySound(room, Level.DETATCHSOUND);
|
||||||
@@ -359,17 +324,14 @@ public void Remove()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g)
|
public void Draw(Graphics g) {
|
||||||
{
|
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
value = false;
|
value = false;
|
||||||
if (fromPort.type == Port.TYPE_OUTPUT && fromPort.value)
|
if (fromPort.type == Port.TYPE_OUTPUT && fromPort.value) {
|
||||||
{
|
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
value = true;
|
value = true;
|
||||||
}
|
}
|
||||||
if (toPort.type == Port.TYPE_OUTPUT && toPort.value)
|
if (toPort.type == Port.TYPE_OUTPUT && toPort.value) {
|
||||||
{
|
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
value = true;
|
value = true;
|
||||||
}
|
}
|
||||||
@@ -382,8 +344,7 @@ public void Draw(Graphics g)
|
|||||||
y1 = d1.height + fromPort.y;
|
y1 = d1.height + fromPort.y;
|
||||||
x2 = d2.width + toPort.x;
|
x2 = d2.width + toPort.x;
|
||||||
y2 = d2.height + toPort.y;
|
y2 = d2.height + toPort.y;
|
||||||
switch((((Device)fromPort.myDevice).rotation + fromPort.rotation)%4)
|
switch ((((Device) fromPort.myDevice).rotation + fromPort.rotation) % 4) {
|
||||||
{
|
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
x1 += 1;
|
x1 += 1;
|
||||||
y1 += 1;
|
y1 += 1;
|
||||||
@@ -401,8 +362,7 @@ public void Draw(Graphics g)
|
|||||||
y1 -= 2;
|
y1 -= 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch((((Device)toPort.myDevice).rotation + toPort.rotation)%4)
|
switch ((((Device) toPort.myDevice).rotation + toPort.rotation) % 4) {
|
||||||
{
|
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
x2 += 1;
|
x2 += 1;
|
||||||
y2 += 1;
|
y2 += 1;
|
||||||
@@ -429,10 +389,13 @@ public void Draw(Graphics g)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Port otherPort(Port p)
|
public Port otherPort(Port p) {
|
||||||
{
|
if (fromPort == p) {
|
||||||
if (fromPort == p) return toPort;
|
return toPort;
|
||||||
if (toPort == p) return fromPort;
|
}
|
||||||
|
if (toPort == p) {
|
||||||
|
return fromPort;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,42 +1,31 @@
|
|||||||
package com.droidquest.avatars;
|
package com.droidquest.avatars;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FileDialog;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.RoomDisplay;
|
import com.droidquest.RoomDisplay;
|
||||||
import com.droidquest.devices.Device;
|
import com.droidquest.items.*;
|
||||||
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;
|
|
||||||
|
|
||||||
public class GameCursor extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class GameCursor extends Player {
|
||||||
private int walk = 0; // 0 or 1, used in animation
|
private int walk = 0; // 0 or 1, used in animation
|
||||||
public boolean outline; // Draw outline around GameCursor?
|
private boolean outline; // Draw outline around GameCursor?
|
||||||
|
|
||||||
public GameCursor(){}
|
public GameCursor() {
|
||||||
|
}
|
||||||
|
|
||||||
public GameCursor(int X, int Y, Room r)
|
public GameCursor(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
outline = false;
|
outline = false;
|
||||||
room = r;
|
room = r;
|
||||||
width=28; height=32;
|
width = 28;
|
||||||
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
// Executed once during initialization
|
// Executed once during initialization
|
||||||
icons = new ImageIcon[8];
|
icons = new ImageIcon[8];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -52,12 +41,10 @@ public class GameCursor extends Item
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// 0 = up, left leg up
|
// 0 = up, left leg up
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,12 +67,10 @@ public class GameCursor extends Item
|
|||||||
g.fillRect(16, 28, 8, 2);
|
g.fillRect(16, 28, 8, 2);
|
||||||
|
|
||||||
// 1 = up, right leg up
|
// 1 = up, right leg up
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,12 +93,10 @@ public class GameCursor extends Item
|
|||||||
g.fillRect(16, 26, 8, 2);
|
g.fillRect(16, 26, 8, 2);
|
||||||
|
|
||||||
// 2 = down, left(side) leg up
|
// 2 = down, left(side) leg up
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[2].getImage().getGraphics();
|
g = icons[2].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -139,12 +122,10 @@ public class GameCursor extends Item
|
|||||||
g.fillRect(16, 28, 8, 2);
|
g.fillRect(16, 28, 8, 2);
|
||||||
|
|
||||||
// 3 = down, right(side) leg up
|
// 3 = down, right(side) leg up
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[3].getImage().getGraphics();
|
g = icons[3].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -170,12 +151,10 @@ public class GameCursor extends Item
|
|||||||
g.fillRect(16, 26, 8, 2);
|
g.fillRect(16, 26, 8, 2);
|
||||||
|
|
||||||
// 4 = left, Stand
|
// 4 = left, Stand
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[4].getImage().getGraphics();
|
g = icons[4].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -196,12 +175,10 @@ public class GameCursor extends Item
|
|||||||
g.fillRect(12, 28, 8, 2);
|
g.fillRect(12, 28, 8, 2);
|
||||||
|
|
||||||
// 5 = left, walk
|
// 5 = left, walk
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[5].getImage().getGraphics();
|
g = icons[5].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -228,12 +205,10 @@ public class GameCursor extends Item
|
|||||||
g.fillRect(16, 28, 8, 2);
|
g.fillRect(16, 28, 8, 2);
|
||||||
|
|
||||||
// 6 = right, Stand
|
// 6 = right, Stand
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[6].getImage().getGraphics();
|
g = icons[6].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -254,12 +229,10 @@ public class GameCursor extends Item
|
|||||||
g.fillRect(8, 28, 8, 2);
|
g.fillRect(8, 28, 8, 2);
|
||||||
|
|
||||||
// 7 = right, walk
|
// 7 = right, walk
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[7].getImage().getGraphics();
|
g = icons[7].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
System.out.println("Could not get Graphics pointer to GameCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -288,486 +261,171 @@ public class GameCursor extends Item
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveUp(boolean nudge)
|
@Override
|
||||||
{
|
public void moveUp(boolean nudge) {
|
||||||
Item item = level.FindNearestItem(this);
|
super.moveUp(nudge);
|
||||||
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);
|
|
||||||
walk = 1 - walk;
|
walk = 1 - walk;
|
||||||
currentIcon = icons[0 + walk].getImage();
|
currentIcon = icons[0 + walk].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveDown(boolean nudge)
|
@Override
|
||||||
{
|
public void moveDown(boolean nudge) {
|
||||||
Item item = level.FindNearestItem(this);
|
super.moveDown(nudge);
|
||||||
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);
|
|
||||||
walk = 1 - walk;
|
walk = 1 - walk;
|
||||||
currentIcon = icons[2 + walk].getImage();
|
currentIcon = icons[2 + walk].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveLeft(boolean nudge)
|
@Override
|
||||||
{
|
public void moveLeft(boolean nudge) {
|
||||||
Item item = level.FindNearestItem(this);
|
super.moveLeft(nudge);
|
||||||
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);
|
|
||||||
walk = 1 - walk;
|
walk = 1 - walk;
|
||||||
currentIcon = icons[4 + walk].getImage();
|
currentIcon = icons[4 + walk].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveRight(boolean nudge)
|
@Override
|
||||||
{
|
public void moveRight(boolean nudge) {
|
||||||
Item item = level.FindNearestItem(this);
|
super.moveRight(nudge);
|
||||||
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);
|
|
||||||
walk = 1 - walk;
|
walk = 1 - walk;
|
||||||
currentIcon = icons[6 + walk].getImage();
|
currentIcon = icons[6 + walk].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g, RoomDisplay rd)
|
public void Draw(Graphics g, RoomDisplay rd) {
|
||||||
{
|
|
||||||
g.drawImage(currentIcon, x, y, rd);
|
g.drawImage(currentIcon, x, y, rd);
|
||||||
if (outline)
|
if (outline) {
|
||||||
{
|
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.drawRect(x, y, 28, 32);
|
g.drawRect(x, y, 28, 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
return !i.getClass().toString().endsWith("Robot");
|
||||||
if (i.getClass().toString().endsWith("Robot"))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
|
||||||
{
|
@Override
|
||||||
if (e.getKeyCode() == e.VK_L)
|
protected boolean handleTrain() {
|
||||||
{
|
|
||||||
if (carrying != null)
|
|
||||||
if (carrying.getClass().toString().endsWith("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() == e.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() == e.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() == e.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() == e.VK_SLASH)
|
|
||||||
{
|
|
||||||
if (carrying != null)
|
|
||||||
if (carrying.getClass().toString().endsWith("Chip"))
|
|
||||||
{
|
|
||||||
((GenericChip)carrying).ShowText(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (level.helpCam == null) return false;
|
|
||||||
level.player = level.helpCam;
|
|
||||||
level.currentViewer = level.helpCam;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
if (level.cheatmode)
|
|
||||||
if (e.isShiftDown())
|
|
||||||
SetRoom(room.rightRoom);
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
|
||||||
{
|
|
||||||
if (level.cheatmode)
|
|
||||||
if (e.isShiftDown())
|
|
||||||
SetRoom(room.leftRoom);
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveLeft(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
|
||||||
{
|
|
||||||
if (level.cheatmode)
|
|
||||||
if (e.isShiftDown())
|
|
||||||
SetRoom(room.upRoom);
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveUp(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
|
||||||
{
|
|
||||||
if (level.cheatmode)
|
|
||||||
if (e.isShiftDown())
|
|
||||||
SetRoom(room.downRoom);
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveDown(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_SPACE)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
Item item = level.FindNearestItem(level.gameCursor);
|
Item item = level.FindNearestItem(level.gameCursor);
|
||||||
if (item!=null)
|
if (item != null) {
|
||||||
if (item.getClass().toString().endsWith("Train"))
|
if (item instanceof Train) {
|
||||||
{
|
|
||||||
item.CanBePickedUp(this);
|
item.CanBePickedUp(this);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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() == e.VK_CLOSE_BRACKET)
|
|
||||||
{
|
|
||||||
if (carrying !=null)
|
|
||||||
if (carrying.isDevice())
|
|
||||||
((Device) carrying).rotate(1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_OPEN_BRACKET)
|
|
||||||
{
|
|
||||||
if (carrying !=null)
|
|
||||||
if (carrying.isDevice())
|
|
||||||
((Device) carrying).rotate(-1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_E)
|
|
||||||
{
|
|
||||||
boolean found=false;
|
|
||||||
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);
|
|
||||||
found=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_X)
|
|
||||||
{
|
|
||||||
if (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() == e.VK_F)
|
|
||||||
{
|
|
||||||
if (carrying != null)
|
|
||||||
if (carrying instanceof Device)
|
|
||||||
((Device)carrying).flip();
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.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() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>5)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>5)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveLeft(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>5)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveUp(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>5)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveDown(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_SPACE)
|
|
||||||
{
|
|
||||||
if (level.player == level.gameCursor)
|
|
||||||
outline = true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
@Override
|
||||||
{
|
protected void setOutline(boolean outline) {
|
||||||
if (automove==1 && room == null)
|
this.outline = outline;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isCheatMode() {
|
||||||
|
return level.cheatmode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Animate() {
|
||||||
|
if (automove == 1 && room == null) {
|
||||||
automove = 0;
|
automove = 0;
|
||||||
if (automove==1)
|
}
|
||||||
{
|
if (automove == 1) {
|
||||||
int dx = autoX - x;
|
int dx = autoX - x;
|
||||||
int dy = autoY - y;
|
int dy = autoY - y;
|
||||||
if (dx==0 && dy==0)
|
if (dx == 0 && dy == 0) {
|
||||||
{
|
|
||||||
automove = 0;
|
automove = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dx<-28) dx =-28;
|
if (dx < -28) {
|
||||||
if (dx>28) dx=28;
|
dx = -28;
|
||||||
if (dy<-32) dy=-32;
|
}
|
||||||
if (dy>32) dy=32;
|
if (dx > 28) {
|
||||||
|
dx = 28;
|
||||||
|
}
|
||||||
|
if (dy < -32) {
|
||||||
|
dy = -32;
|
||||||
|
}
|
||||||
|
if (dy > 32) {
|
||||||
|
dy = 32;
|
||||||
|
}
|
||||||
walk = 1 - walk;
|
walk = 1 - walk;
|
||||||
if (dx==0)
|
if (dx == 0) {
|
||||||
{
|
if (dy < 0) {
|
||||||
if (dy<0)
|
|
||||||
currentIcon = icons[0 + walk].getImage();
|
currentIcon = icons[0 + walk].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[2 + walk].getImage();
|
currentIcon = icons[2 + walk].getImage();
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
if (dx<0)
|
if (dx < 0) {
|
||||||
currentIcon = icons[4 + walk].getImage();
|
currentIcon = icons[4 + walk].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[6 + walk].getImage();
|
currentIcon = icons[6 + walk].getImage();
|
||||||
}
|
}
|
||||||
if (dx>0) MoveRight(dx);
|
|
||||||
if (dx<0) MoveLeft(-dx);
|
|
||||||
if (dy>0) MoveDown(dy);
|
|
||||||
if (dy<0) MoveUp(-dy);
|
|
||||||
}
|
}
|
||||||
if (automove==2)
|
if (dx > 0) {
|
||||||
{
|
moveRight(dx);
|
||||||
|
}
|
||||||
|
if (dx < 0) {
|
||||||
|
moveLeft(-dx);
|
||||||
|
}
|
||||||
|
if (dy > 0) {
|
||||||
|
moveDown(dy);
|
||||||
|
}
|
||||||
|
if (dy < 0) {
|
||||||
|
moveUp(-dy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (automove == 2) {
|
||||||
walk = 1 - walk;
|
walk = 1 - walk;
|
||||||
if (autoX>0)
|
if (autoX > 0) {
|
||||||
{
|
|
||||||
currentIcon = icons[6 + walk].getImage();
|
currentIcon = icons[6 + walk].getImage();
|
||||||
MoveRight(autoX);
|
moveRight(autoX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoX<0)
|
if (autoX < 0) {
|
||||||
{
|
|
||||||
currentIcon = icons[4 + walk].getImage();
|
currentIcon = icons[4 + walk].getImage();
|
||||||
MoveLeft(-autoX);
|
moveLeft(-autoX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoY>0)
|
if (autoY > 0) {
|
||||||
{
|
|
||||||
currentIcon = icons[2 + walk].getImage();
|
currentIcon = icons[2 + walk].getImage();
|
||||||
MoveDown(autoY);
|
moveDown(autoY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoY<0)
|
if (autoY < 0) {
|
||||||
{
|
|
||||||
currentIcon = icons[0 + walk].getImage();
|
currentIcon = icons[0 + walk].getImage();
|
||||||
MoveUp(-autoY);
|
moveUp(-autoY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericRobot PlayerInRobot(GenericRobot robot)
|
public GenericRobot PlayerInRobot(GenericRobot robot) {
|
||||||
{
|
if (robot == null) {
|
||||||
if (robot==null)
|
if (level.player.room.portalItem != null) {
|
||||||
{
|
if (level.player.room.portalItem instanceof GenericRobot) {
|
||||||
if (level.player.room.portalItem!=null)
|
|
||||||
{
|
|
||||||
if (level.player.room.portalItem.getClass().toString().endsWith("Robot"))
|
|
||||||
return (PlayerInRobot((GenericRobot) level.player.room.portalItem));
|
return (PlayerInRobot((GenericRobot) level.player.room.portalItem));
|
||||||
else return (null);
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
if (robot.room.portalItem != null)
|
else {
|
||||||
{
|
return (null);
|
||||||
if (robot.room.portalItem.getClass().toString().endsWith("Robot"))
|
}
|
||||||
|
}
|
||||||
|
else if (robot.room.portalItem != null) {
|
||||||
|
if (robot.room.portalItem instanceof GenericRobot) {
|
||||||
return (PlayerInRobot((GenericRobot) robot.room.portalItem));
|
return (PlayerInRobot((GenericRobot) robot.room.portalItem));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return robot;
|
return robot;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,100 @@
|
|||||||
package com.droidquest.avatars;
|
package com.droidquest.avatars;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
|
||||||
public class HelpCam extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public HelpCam(Room r)
|
import java.awt.event.KeyEvent;
|
||||||
{
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class HelpCam extends Item implements Avatar {
|
||||||
|
public HelpCam(Room r) {
|
||||||
charge = 0;
|
charge = 0;
|
||||||
x=28; y=32; width=0; height=0; room =r;
|
x = 28;
|
||||||
|
y = 32;
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
room = r;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(8, 8, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(8, 8, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
public boolean KeyUp(KeyEvent e) {
|
||||||
{
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||||
if (e.getKeyCode() == e.VK_ENTER)
|
|
||||||
{
|
|
||||||
level.player = level.gameCursor;
|
level.player = level.gameCursor;
|
||||||
level.currentViewer = level.gameCursor;
|
level.currentViewer = level.gameCursor;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g, JPanel jp)
|
public void Draw(Graphics g, JPanel jp) {
|
||||||
{
|
|
||||||
// Draws nothing
|
// Draws nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@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,440 +1,155 @@
|
|||||||
package com.droidquest.avatars;
|
package com.droidquest.avatars;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FileDialog;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.devices.Device;
|
|
||||||
import com.droidquest.devices.GenericChip;
|
|
||||||
import com.droidquest.devices.SmallChip;
|
import com.droidquest.devices.SmallChip;
|
||||||
|
import com.droidquest.items.GenericRobot;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
import com.droidquest.items.ToolBox;
|
import com.droidquest.items.ToolBox;
|
||||||
|
|
||||||
public class LabCursor extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class LabCursor extends Player {
|
||||||
public boolean hot;
|
public boolean hot;
|
||||||
|
|
||||||
public LabCursor(){}
|
|
||||||
|
|
||||||
public LabCursor(int X, int Y, Room r)
|
public LabCursor(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
hot = false;
|
hot = false;
|
||||||
room = r;
|
room = r;
|
||||||
width=28; height=32;
|
width = 28;
|
||||||
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
|
|
||||||
|
// Lab cursor has a longer key repeat rate than the game cursor
|
||||||
|
setKeyRepeatRate(10);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to LabCursor Image");
|
System.out.println("Could not get Graphics pointer to LabCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.fillRect(0, 0, width, height);
|
g.fillRect(0, 0, width, height);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to LabCursor Image");
|
System.out.println("Could not get Graphics pointer to LabCursor Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g2 = (Graphics2D) g;
|
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
g.fillRect(0, 0, width, height);
|
g.fillRect(0, 0, width, height);
|
||||||
if (hot)
|
if (hot) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
|
||||||
{
|
|
||||||
if (i.getClass().toString().endsWith("Robot"))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
return !(i instanceof GenericRobot);
|
||||||
if (e.getKeyCode() == e.VK_L)
|
|
||||||
{
|
|
||||||
if (carrying != null)
|
|
||||||
if (carrying.getClass().toString().endsWith("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() == e.VK_H)
|
@Override
|
||||||
{
|
protected boolean handleSaveSmallChip() {
|
||||||
hot = !hot;
|
if (carrying != null) {
|
||||||
if (hot)
|
if (carrying instanceof SmallChip) {
|
||||||
currentIcon = icons[1].getImage();
|
|
||||||
else
|
|
||||||
currentIcon = icons[0].getImage();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_S)
|
|
||||||
{
|
|
||||||
if (level.solderingPen == null) return false;
|
|
||||||
if (carrying != null)
|
|
||||||
if (carrying.getClass().toString().endsWith("SmallChip"))
|
|
||||||
{
|
|
||||||
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Save Chip", FileDialog.SAVE);
|
FileDialog fd = new FileDialog(level.roomdisplay.dq, "Save Chip", FileDialog.SAVE);
|
||||||
fd.setDirectory("chips");
|
fd.setDirectory("chips");
|
||||||
fd.show();
|
fd.show();
|
||||||
System.out.println("Dialog returned with "
|
System.out.println("Dialog returned with "
|
||||||
+ fd.getDirectory()
|
+ fd.getDirectory()
|
||||||
+ fd.getFile());
|
+ fd.getFile());
|
||||||
if (fd.getFile() != null)
|
if (fd.getFile() != null) {
|
||||||
((SmallChip) carrying).SaveChip(fd.getDirectory() + fd.getFile());
|
((SmallChip) carrying).SaveChip(fd.getDirectory() + fd.getFile());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (carrying != null)
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleHotCursor() {
|
||||||
|
hot = !hot;
|
||||||
|
if (hot) {
|
||||||
|
currentIcon = icons[1].getImage();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentIcon = icons[0].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.room.level.roomdisplay.dq.setHotCursorSelected(hot);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handlePaintbrush() {
|
||||||
|
if (level.paintbrush == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (carrying != null) {
|
||||||
Drops();
|
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() == e.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() == e.VK_P)
|
|
||||||
{
|
|
||||||
if (level.paintbrush == null) return false;
|
|
||||||
if (carrying != null)
|
|
||||||
Drops();
|
|
||||||
level.paintbrush.x = (x / 28) * 28;
|
level.paintbrush.x = (x / 28) * 28;
|
||||||
level.paintbrush.y = (y / 32) * 32;
|
level.paintbrush.y = (y / 32) * 32;
|
||||||
level.paintbrush.room = room;
|
level.paintbrush.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
if (level.currentViewer == level.player)
|
if (level.currentViewer == level.player) {
|
||||||
level.currentViewer = level.paintbrush;
|
level.currentViewer = level.paintbrush;
|
||||||
level.player = level.paintbrush;
|
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_T)
|
level.player = level.paintbrush;
|
||||||
{
|
handleRemote();
|
||||||
if (level.toolbox == null) return false;
|
|
||||||
if (level.toolbox.room != room)
|
level.roomdisplay.dq.selectPaintBrush();
|
||||||
{
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleToolbox() {
|
||||||
|
if (level.toolbox == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (level.toolbox.room != room) {
|
||||||
// Summon Toolbox
|
// Summon Toolbox
|
||||||
if (carrying != null) return false;
|
if (carrying != null) {
|
||||||
if (((ToolBox)level.toolbox).open) ((ToolBox)level.toolbox).Toggle();
|
return false;
|
||||||
|
}
|
||||||
|
if (((ToolBox) level.toolbox).open) {
|
||||||
|
((ToolBox) level.toolbox).Toggle();
|
||||||
|
}
|
||||||
level.toolbox.room = room;
|
level.toolbox.room = room;
|
||||||
level.toolbox.x = x + 28;
|
level.toolbox.x = x + 28;
|
||||||
level.toolbox.y = y + 6;
|
level.toolbox.y = y + 6;
|
||||||
PicksUp(level.toolbox);
|
PicksUp(level.toolbox);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
((ToolBox) level.toolbox).Toggle();
|
((ToolBox) level.toolbox).Toggle();
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_SLASH)
|
|
||||||
{
|
|
||||||
if (carrying != null)
|
|
||||||
if (carrying.getClass().toString().endsWith("Chip"))
|
|
||||||
{
|
|
||||||
((GenericChip)carrying).ShowText(true);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (level.helpCam == null) return false;
|
|
||||||
level.player = level.helpCam;
|
|
||||||
level.currentViewer = level.helpCam;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveLeft(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveUp(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveDown(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.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;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_CLOSE_BRACKET)
|
|
||||||
{
|
|
||||||
if (carrying !=null)
|
|
||||||
if (carrying.isDevice())
|
|
||||||
((Device) carrying).rotate(1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_OPEN_BRACKET)
|
|
||||||
{
|
|
||||||
if (carrying !=null)
|
|
||||||
if (carrying.isDevice())
|
|
||||||
((Device) carrying).rotate(-1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_E)
|
|
||||||
{
|
|
||||||
boolean found=false;
|
|
||||||
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);
|
|
||||||
found=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_X)
|
|
||||||
{
|
|
||||||
if (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() == e.VK_F)
|
|
||||||
{
|
|
||||||
if (carrying != null)
|
|
||||||
if (carrying instanceof Device)
|
|
||||||
((Device)carrying).flip();
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.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() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>10)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>10)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveLeft(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>10)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveUp(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,17 @@
|
|||||||
package com.droidquest.avatars;
|
package com.droidquest.avatars;
|
||||||
|
|
||||||
import java.awt.Color;
|
import com.droidquest.items.BlueRobot;
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.items.GenericRobot;
|
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
import com.droidquest.items.OrangeRobot;
|
||||||
|
import com.droidquest.items.WhiteRobot;
|
||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
import com.droidquest.materials.RobotBlocker;
|
import com.droidquest.materials.RobotBlocker;
|
||||||
|
|
||||||
public class PaintBrush extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class PaintBrush extends Player {
|
||||||
// The Paintbrush works just like the original, except it allows
|
// The Paintbrush works just like the original, except it allows
|
||||||
// differnt color paints for differnt materials. Pressing 'P' as the
|
// differnt color paints for differnt materials. Pressing 'P' as the
|
||||||
// Paintbrush switches the Material Settings.
|
// Paintbrush switches the Material Settings.
|
||||||
@@ -25,19 +22,23 @@ public class PaintBrush extends Item
|
|||||||
// Undetectable, blocks White White
|
// Undetectable, blocks White White
|
||||||
// Undetectable, blocks Blue Blue
|
// Undetectable, blocks Blue Blue
|
||||||
|
|
||||||
int emptyIndex=0;
|
private int emptyIndex = 0;
|
||||||
int paintIndex; // Which paintMats[] am I using?
|
private int paintIndex; // Which paintMats[] am I using?
|
||||||
transient Material[] paintMats;
|
private transient Material[] paintMats;
|
||||||
int matIndex; // index of chosen paintMax in level.materials
|
private int matIndex; // index of chosen paintMax in level.materials
|
||||||
|
|
||||||
public PaintBrush()
|
public PaintBrush() {
|
||||||
{
|
width = 28;
|
||||||
width=28; height=32;
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
@Override
|
||||||
{
|
protected boolean isCheatMode() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GenerateIcons() {
|
||||||
icons = new ImageIcon[5];
|
icons = new ImageIcon[5];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -47,31 +48,32 @@ public class PaintBrush extends Item
|
|||||||
Graphics g;
|
Graphics g;
|
||||||
Graphics2D g2;
|
Graphics2D g2;
|
||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
for (int a=0; a<5; a++)
|
for (int a = 0; a < 5; a++) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
g = icons[a].getImage().getGraphics();
|
g = icons[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to PaintBrush Image");
|
System.out.println("Could not get Graphics pointer to PaintBrush Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g2 = (Graphics2D) g;
|
g2 = (Graphics2D) g;
|
||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
switch(a)
|
switch (a) {
|
||||||
{
|
case 0:
|
||||||
case 0: g.setColor(new Color(192,0,0));
|
g.setColor(new Color(192, 0, 0));
|
||||||
break;
|
break;
|
||||||
case 1: g.setColor(new Color(0,192,0));
|
case 1:
|
||||||
|
g.setColor(new Color(0, 192, 0));
|
||||||
break;
|
break;
|
||||||
case 2: g.setColor(new Color(192,96,0));
|
case 2:
|
||||||
|
g.setColor(new Color(192, 96, 0));
|
||||||
break;
|
break;
|
||||||
case 3: g.setColor(new Color(192,192,192));
|
case 3:
|
||||||
|
g.setColor(new Color(192, 192, 192));
|
||||||
break;
|
break;
|
||||||
case 4: g.setColor(new Color(0,0,192));
|
case 4:
|
||||||
|
g.setColor(new Color(0, 0, 192));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,19 +92,30 @@ public class PaintBrush extends Item
|
|||||||
paintMats[0] = Material.FindSimiliar(new Material(Color.red, false, true));
|
paintMats[0] = Material.FindSimiliar(new Material(Color.red, false, true));
|
||||||
paintMats[1] = Material.FindSimiliar(new Material(Color.green, false, false));
|
paintMats[1] = Material.FindSimiliar(new Material(Color.green, false, false));
|
||||||
Item robot = null;
|
Item robot = null;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
|
||||||
if (((Item)level.items.elementAt(a)).getClass().toString().endsWith("OrangeRobot"))
|
for(Item item : level.items) {
|
||||||
robot = (GenericRobot) level.items.elementAt(a);
|
if(item instanceof OrangeRobot) {
|
||||||
if (robot==null)
|
robot = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (robot == null) {
|
||||||
System.out.println("Create paintbrush AFTER creating robots.");
|
System.out.println("Create paintbrush AFTER creating robots.");
|
||||||
|
}
|
||||||
paintMats[2] = Material.FindSimiliar(new RobotBlocker(robot, new Color(255, 128, 0)));
|
paintMats[2] = Material.FindSimiliar(new RobotBlocker(robot, new Color(255, 128, 0)));
|
||||||
for (int a=0; a<level.items.size(); a++)
|
|
||||||
if (((Item)level.items.elementAt(a)).getClass().toString().endsWith("WhiteRobot"))
|
for (Item item : level.items) {
|
||||||
robot = (GenericRobot) level.items.elementAt(a);
|
if(item instanceof WhiteRobot) {
|
||||||
|
robot = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
paintMats[3] = Material.FindSimiliar(new RobotBlocker(robot, Color.white));
|
paintMats[3] = Material.FindSimiliar(new RobotBlocker(robot, Color.white));
|
||||||
for (int a=0; a<level.items.size(); a++)
|
|
||||||
if (((Item)level.items.elementAt(a)).getClass().toString().endsWith("BlueRobot"))
|
for(Item item : level.items) {
|
||||||
robot = (GenericRobot) level.items.elementAt(a);
|
if(item instanceof BlueRobot) {
|
||||||
|
robot = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
paintMats[4] = Material.FindSimiliar(new RobotBlocker(robot, Color.blue));
|
paintMats[4] = Material.FindSimiliar(new RobotBlocker(robot, Color.blue));
|
||||||
|
|
||||||
paintIndex = 0;
|
paintIndex = 0;
|
||||||
@@ -110,168 +123,166 @@ public class PaintBrush extends Item
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
@Override
|
||||||
{
|
public boolean handleHelp() {
|
||||||
if (e.getKeyCode() == e.VK_C)
|
handleGameCursor();
|
||||||
{
|
return super.handleHelp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleLoadSmallChip() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handlePaintbrush() {
|
||||||
|
paintIndex++;
|
||||||
|
if (paintIndex == 5) {
|
||||||
|
paintIndex = 0;
|
||||||
|
}
|
||||||
|
matIndex = level.materials.indexOf(paintMats[paintIndex]);
|
||||||
|
currentIcon = icons[paintIndex].getImage();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
int bigX = (x + 14) / 28;
|
||||||
|
int bigY = (y + 16) / 32;
|
||||||
|
if (room.RoomArray[bigY][bigX] == emptyIndex) {
|
||||||
|
room.SetMaterial(bigX, bigY, matIndex);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
room.SetMaterial(bigX, bigY, emptyIndex);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleEnterRoom() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.x = x;
|
||||||
level.gameCursor.y = y;
|
level.gameCursor.y = y;
|
||||||
level.gameCursor.room = room;
|
level.gameCursor.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
if (level.currentViewer == level.player)
|
if (level.currentViewer == level.player) {
|
||||||
level.currentViewer = level.gameCursor;
|
level.currentViewer = level.gameCursor;
|
||||||
|
}
|
||||||
level.player = level.gameCursor;
|
level.player = level.gameCursor;
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_S)
|
handleRemote();
|
||||||
{
|
|
||||||
if (level.solderingPen == null) return false;
|
level.roomdisplay.dq.selectCursor();
|
||||||
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() == e.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() == e.VK_SLASH)
|
|
||||||
{
|
|
||||||
if (level.helpCam == null) return false;
|
|
||||||
level.player = level.helpCam;
|
|
||||||
level.currentViewer = level.helpCam;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
if (e.isShiftDown())
|
|
||||||
SetRoom(room.rightRoom);
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
|
||||||
{
|
|
||||||
if (e.isShiftDown())
|
@Override
|
||||||
SetRoom(room.leftRoom);
|
protected boolean handleRepeatSpace() {
|
||||||
if (carriedBy==null)
|
|
||||||
MoveLeft(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
|
||||||
{
|
|
||||||
if (e.isShiftDown())
|
|
||||||
SetRoom(room.upRoom);
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveUp(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
|
||||||
{
|
|
||||||
if (e.isShiftDown())
|
|
||||||
SetRoom(room.downRoom);
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveDown(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_P)
|
|
||||||
{
|
|
||||||
paintIndex++;
|
|
||||||
if (paintIndex==5) paintIndex=0;
|
|
||||||
matIndex = level.materials.indexOf(paintMats[paintIndex]);
|
|
||||||
currentIcon=icons[paintIndex].getImage();
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_SPACE)
|
|
||||||
{
|
|
||||||
if (!room.editable) return false;
|
|
||||||
int bigX=(x+14)/28;
|
|
||||||
int bigY=(y+16)/32;
|
|
||||||
if (room.RoomArray[bigY][bigX]==emptyIndex)
|
|
||||||
room.SetMaterial(bigX,bigY,matIndex);
|
|
||||||
else
|
|
||||||
room.SetMaterial(bigX,bigY,emptyIndex);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveUp(boolean nudge)
|
public void moveUp(boolean nudge) {
|
||||||
{
|
|
||||||
int dist = 32;
|
int dist = 32;
|
||||||
if (nudge) dist = 2;
|
if (nudge) {
|
||||||
|
dist = 2;
|
||||||
|
}
|
||||||
y = y - dist;
|
y = y - dist;
|
||||||
if (y<0)
|
if (y < 0) {
|
||||||
{
|
if (room.getUpRoom(this) != null) { // change Rooms
|
||||||
if (room.getUpRoom(this) != null)
|
|
||||||
{ // change Rooms
|
|
||||||
y = y + 384;
|
y = y + 384;
|
||||||
SetRoom(room.getUpRoom(this));
|
SetRoom(room.getUpRoom(this));
|
||||||
}
|
}
|
||||||
else // stop at top
|
else // stop at top
|
||||||
|
{
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveDown(boolean nudge)
|
public void moveDown(boolean nudge) {
|
||||||
{
|
|
||||||
int dist = 32;
|
int dist = 32;
|
||||||
if (nudge) dist = 2;
|
if (nudge) {
|
||||||
|
dist = 2;
|
||||||
|
}
|
||||||
y = y + dist;
|
y = y + dist;
|
||||||
if (y>383)
|
if (y > 383) {
|
||||||
{
|
if (room.getDownRoom(this) != null) { // change Rooms
|
||||||
if (room.getDownRoom(this) != null)
|
|
||||||
{ // change Rooms
|
|
||||||
y = y - 384;
|
y = y - 384;
|
||||||
SetRoom(room.getDownRoom(this));
|
SetRoom(room.getDownRoom(this));
|
||||||
}
|
}
|
||||||
else // stop at bottom
|
else // stop at bottom
|
||||||
|
{
|
||||||
y = 384 - 32;
|
y = 384 - 32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveLeft(boolean nudge)
|
public void moveLeft(boolean nudge) {
|
||||||
{
|
|
||||||
int dist = 28;
|
int dist = 28;
|
||||||
if (nudge) dist = 2;
|
if (nudge) {
|
||||||
|
dist = 2;
|
||||||
|
}
|
||||||
x = x - dist;
|
x = x - dist;
|
||||||
if (x<0)
|
if (x < 0) {
|
||||||
{
|
if (room.getLeftRoom(this) != null) { // change Rooms
|
||||||
if (room.getLeftRoom(this) != null)
|
|
||||||
{ // change Rooms
|
|
||||||
x = x + 560;
|
x = x + 560;
|
||||||
SetRoom(room.getLeftRoom(this));
|
SetRoom(room.getLeftRoom(this));
|
||||||
}
|
}
|
||||||
else // stop at left
|
else // stop at left
|
||||||
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveRight(boolean nudge)
|
public void moveRight(boolean nudge) {
|
||||||
{
|
|
||||||
int dist = 28;
|
int dist = 28;
|
||||||
if (nudge) dist = 2;
|
if (nudge) {
|
||||||
|
dist = 2;
|
||||||
|
}
|
||||||
x = x + dist;
|
x = x + dist;
|
||||||
if (x>559)
|
if (x > 559) {
|
||||||
{
|
if (room.getRightRoom(this) != null) { // change Rooms
|
||||||
if (room.getRightRoom(this) != null)
|
|
||||||
{ // change Rooms
|
|
||||||
x = x - 560;
|
x = x - 560;
|
||||||
SetRoom(room.getRightRoom(this));
|
SetRoom(room.getRightRoom(this));
|
||||||
}
|
}
|
||||||
else // stop at right
|
else // stop at right
|
||||||
|
{
|
||||||
x = 560 - 28;
|
x = 560 - 28;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,42 +1,30 @@
|
|||||||
package com.droidquest.avatars;
|
package com.droidquest.avatars;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
|
||||||
public class Remote extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public Remote()
|
import java.awt.event.KeyEvent;
|
||||||
{
|
import java.awt.image.BufferedImage;
|
||||||
// width=28; height=32;
|
|
||||||
width=4; height=20;
|
public class Remote extends Item implements Avatar {
|
||||||
|
public Remote() {
|
||||||
|
width = 4;
|
||||||
|
height = 20;
|
||||||
level.electricity = true;
|
level.electricity = true;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
// icons = new ImageIcon[2];
|
|
||||||
// icons[0]= new ImageIcon(new BufferedImage(width,height,BufferedImage.TYPE_4BYTE_ABGR));
|
|
||||||
// icons[1]= new ImageIcon(new BufferedImage(width,height,BufferedImage.TYPE_4BYTE_ABGR));
|
|
||||||
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
|
|
||||||
Graphics g;
|
Graphics g;
|
||||||
Graphics2D g2;
|
Graphics2D g2;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Remote Image");
|
System.out.println("Could not get Graphics pointer to Remote Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -47,186 +35,130 @@ public void GenerateIcons()
|
|||||||
g2.fillRect(2, 0, 2, 20);
|
g2.fillRect(2, 0, 2, 20);
|
||||||
g2.fillRect(0, 16, 4, 4);
|
g2.fillRect(0, 16, 4, 4);
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// g = icons[0].getImage().getGraphics();
|
|
||||||
// }
|
|
||||||
// catch (NullPointerException e)
|
|
||||||
// {
|
|
||||||
// System.out.println("Could not get Graphics pointer to Remote Image[0]");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// g2 = (Graphics2D) g;
|
|
||||||
// g2.setBackground(new Color(0,0,0,0));
|
|
||||||
// g2.clearRect(0,0,width,height);
|
|
||||||
// g2.setColor(Color.white);
|
|
||||||
// g2.fillRect(20,0,4,12);
|
|
||||||
// g2.fillRect(0,12,28,20);
|
|
||||||
// g2.setColor(Color.black);
|
|
||||||
// g2.fillRect(8,14,12,2);
|
|
||||||
// g2.fillRect(4,18,20,2);
|
|
||||||
// g2.fillRect(8,22,12,2);
|
|
||||||
// g2.fillRect(20,26,4,4);
|
|
||||||
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// g = icons[1].getImage().getGraphics();
|
|
||||||
// }
|
|
||||||
// catch (NullPointerException e)
|
|
||||||
// {
|
|
||||||
// System.out.println("Could not get Graphics pointer to Remote Image[1]");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// g2 = (Graphics2D) g;
|
|
||||||
// g2.setBackground(new Color(0,0,0,0));
|
|
||||||
// g2.clearRect(0,0,width,height);
|
|
||||||
// g2.setColor(new Color(255,128,0));
|
|
||||||
// g2.fillRect(20,0,4,12);
|
|
||||||
// g2.fillRect(0,12,28,20);
|
|
||||||
// g2.setColor(Color.black);
|
|
||||||
// g2.fillRect(8,14,12,2);
|
|
||||||
// g2.fillRect(4,18,20,2);
|
|
||||||
// g2.fillRect(8,22,12,2);
|
|
||||||
// g2.fillRect(20,26,4,4);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (carriedBy != null) {
|
||||||
if (carriedBy != null)
|
if (carriedBy.room != room) {
|
||||||
if (carriedBy.room != room)
|
|
||||||
room = carriedBy.room;
|
room = carriedBy.room;
|
||||||
|
}
|
||||||
|
}
|
||||||
super.Animate();
|
super.Animate();
|
||||||
// if (level.electricity)
|
|
||||||
// currentIcon = icons[1].getImage();
|
|
||||||
// else
|
|
||||||
// currentIcon = icons[0].getImage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
|
||||||
// if (i.getClass().toString().endsWith("Robot"))
|
|
||||||
return false;
|
return false;
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
public boolean KeyUp(KeyEvent e) {
|
||||||
{
|
if (e.getKeyCode() == KeyEvent.VK_S) {
|
||||||
if (e.getKeyCode() == e.VK_S)
|
if (level.solderingPen == null) {
|
||||||
{
|
return false;
|
||||||
if (level.solderingPen == null) return false;
|
}
|
||||||
level.solderingPen.x = x;
|
level.solderingPen.x = x;
|
||||||
level.solderingPen.y = y;
|
level.solderingPen.y = y;
|
||||||
level.solderingPen.room = room;
|
level.solderingPen.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
if (level.currentViewer == level.player)
|
if (level.currentViewer == level.player) {
|
||||||
level.currentViewer = level.solderingPen;
|
level.currentViewer = level.solderingPen;
|
||||||
|
}
|
||||||
level.player = level.solderingPen;
|
level.player = level.solderingPen;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_C)
|
else if (e.getKeyCode() == KeyEvent.VK_C) {
|
||||||
{
|
|
||||||
level.gameCursor.x = x;
|
level.gameCursor.x = x;
|
||||||
level.gameCursor.y = y;
|
level.gameCursor.y = y;
|
||||||
level.gameCursor.room = room;
|
level.gameCursor.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
if (level.currentViewer == level.player)
|
if (level.currentViewer == level.player) {
|
||||||
level.currentViewer = level.gameCursor;
|
level.currentViewer = level.gameCursor;
|
||||||
|
}
|
||||||
level.player = level.gameCursor;
|
level.player = level.gameCursor;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_P)
|
else if (e.getKeyCode() == KeyEvent.VK_P) {
|
||||||
{
|
if (level.paintbrush == null) {
|
||||||
if (level.paintbrush == null) return false;
|
return false;
|
||||||
|
}
|
||||||
level.paintbrush.x = x;
|
level.paintbrush.x = x;
|
||||||
level.paintbrush.y = y;
|
level.paintbrush.y = y;
|
||||||
level.paintbrush.room = room;
|
level.paintbrush.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
if (level.currentViewer == level.player)
|
if (level.currentViewer == level.player) {
|
||||||
level.currentViewer = level.paintbrush;
|
level.currentViewer = level.paintbrush;
|
||||||
|
}
|
||||||
level.player = level.paintbrush;
|
level.player = level.paintbrush;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_SLASH)
|
else if (e.getKeyCode() == KeyEvent.VK_SLASH) {
|
||||||
{
|
if (level.helpCam == null) {
|
||||||
if (level.helpCam == null) return false;
|
return false;
|
||||||
if (level.player != level.helpCam)
|
}
|
||||||
{
|
if (level.player != level.helpCam) {
|
||||||
level.player = level.helpCam;
|
level.player = level.helpCam;
|
||||||
level.currentViewer = level.helpCam;
|
level.currentViewer = level.helpCam;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||||
{
|
if (carriedBy == null) {
|
||||||
if (carriedBy==null)
|
moveRight(e.isControlDown());
|
||||||
MoveRight(e.isControlDown());
|
}
|
||||||
repeating = 0;
|
repeating = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||||
{
|
if (carriedBy == null) {
|
||||||
if (carriedBy==null)
|
moveLeft(e.isControlDown());
|
||||||
MoveLeft(e.isControlDown());
|
}
|
||||||
repeating = 0;
|
repeating = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||||
{
|
if (carriedBy == null) {
|
||||||
if (carriedBy==null)
|
moveUp(e.isControlDown());
|
||||||
MoveUp(e.isControlDown());
|
}
|
||||||
repeating = 0;
|
repeating = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||||
{
|
if (carriedBy == null) {
|
||||||
if (carriedBy==null)
|
moveDown(e.isControlDown());
|
||||||
MoveDown(e.isControlDown());
|
}
|
||||||
repeating = 0;
|
repeating = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_SPACE)
|
else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||||
{
|
|
||||||
level.electricity = !level.electricity;
|
level.electricity = !level.electricity;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyDown(KeyEvent e)
|
public boolean KeyDown(KeyEvent e) {
|
||||||
{
|
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
repeating++;
|
repeating++;
|
||||||
if (repeating>10)
|
if (repeating > 10) {
|
||||||
{
|
moveRight(e.isControlDown());
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||||
{
|
|
||||||
repeating++;
|
repeating++;
|
||||||
if (repeating>10)
|
if (repeating > 10) {
|
||||||
{
|
moveLeft(e.isControlDown());
|
||||||
MoveLeft(e.isControlDown());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||||
{
|
|
||||||
repeating++;
|
repeating++;
|
||||||
if (repeating>10)
|
if (repeating > 10) {
|
||||||
{
|
moveUp(e.isControlDown());
|
||||||
MoveUp(e.isControlDown());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||||
{
|
|
||||||
repeating++;
|
repeating++;
|
||||||
if (repeating>10)
|
if (repeating > 10) {
|
||||||
{
|
moveDown(e.isControlDown());
|
||||||
MoveDown(e.isControlDown());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -234,14 +166,11 @@ public boolean KeyDown(KeyEvent e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveUp(boolean nudge)
|
public void moveUp(boolean nudge) {
|
||||||
{
|
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.UpEnterOverlap(this)) {
|
||||||
if (item.UpEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 280; // 10 * 28
|
int newX = 280; // 10 * 28
|
||||||
int newY = 320; // 10 * 32
|
int newY = 320; // 10 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -249,17 +178,15 @@ public void MoveUp(boolean nudge)
|
|||||||
SetRoom(item.InternalRoom);
|
SetRoom(item.InternalRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.MoveUp( nudge);
|
}
|
||||||
|
super.moveUp(nudge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveDown(boolean nudge)
|
public void moveDown(boolean nudge) {
|
||||||
{
|
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.DownEnterOverlap(this)) {
|
||||||
if (item.DownEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 280; // 10 * 28
|
int newX = 280; // 10 * 28
|
||||||
int newY = 0; // 0 * 32
|
int newY = 0; // 0 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -267,17 +194,15 @@ public void MoveDown(boolean nudge)
|
|||||||
SetRoom(item.InternalRoom);
|
SetRoom(item.InternalRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.MoveDown( nudge);
|
}
|
||||||
|
super.moveDown(nudge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveLeft(boolean nudge)
|
public void moveLeft(boolean nudge) {
|
||||||
{
|
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.LeftEnterOverlap(this)) {
|
||||||
if (item.LeftEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 532; // 19 * 28
|
int newX = 532; // 19 * 28
|
||||||
int newY = 176; // 5.5 * 32
|
int newY = 176; // 5.5 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -285,18 +210,15 @@ public void MoveLeft(boolean nudge)
|
|||||||
SetRoom(item.InternalRoom);
|
SetRoom(item.InternalRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.MoveLeft( nudge);
|
}
|
||||||
|
super.moveLeft(nudge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveRight(boolean nudge)
|
public void moveRight(boolean nudge) {
|
||||||
{
|
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.RightEnterOverlap(this)) {
|
||||||
{
|
|
||||||
if (item.RightEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 0; // 0 * 28
|
int newX = 0; // 0 * 28
|
||||||
int newY = 176; // 5.5 * 32
|
int newY = 176; // 5.5 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -305,7 +227,66 @@ public void MoveRight(boolean nudge)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,25 @@
|
|||||||
package com.droidquest.avatars;
|
package com.droidquest.avatars;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.InputEvent;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.Wire;
|
import com.droidquest.Wire;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.devices.Device;
|
import com.droidquest.devices.Device;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
|
||||||
public class SolderingPen extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
boolean hot;
|
import java.awt.event.InputEvent;
|
||||||
Port currentPort=null; // Port that Soldering pen is currently over
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public SolderingPen()
|
public class SolderingPen extends Device implements Avatar {
|
||||||
{
|
private boolean hot;
|
||||||
width=22; height=26;
|
private Port currentPort = null; // Port that Soldering pen is currently over
|
||||||
|
|
||||||
|
public SolderingPen() {
|
||||||
|
width = 22;
|
||||||
|
height = 26;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
ports = new Port[1];
|
ports = new Port[1];
|
||||||
@@ -31,8 +27,7 @@ public SolderingPen()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
// Executed once during initialization
|
// Executed once during initialization
|
||||||
icons = new ImageIcon[3];
|
icons = new ImageIcon[3];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -40,12 +35,10 @@ public void GenerateIcons()
|
|||||||
icons[2] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[2] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
Graphics2D g2;
|
Graphics2D g2;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to SolderingPen Image");
|
System.out.println("Could not get Graphics pointer to SolderingPen Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -61,12 +54,10 @@ public void GenerateIcons()
|
|||||||
g2.fillRect(6, 14, 6, 4);
|
g2.fillRect(6, 14, 6, 4);
|
||||||
g2.fillRect(0, 18, 12, 8);
|
g2.fillRect(0, 18, 12, 8);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to SolderingPen Image");
|
System.out.println("Could not get Graphics pointer to SolderingPen Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -83,12 +74,10 @@ public void GenerateIcons()
|
|||||||
g2.setColor(new Color(255, 128, 0));
|
g2.setColor(new Color(255, 128, 0));
|
||||||
g2.fillRect(0, 18, 12, 8);
|
g2.fillRect(0, 18, 12, 8);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[2].getImage().getGraphics();
|
g = icons[2].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to SolderingPen Image");
|
System.out.println("Could not get Graphics pointer to SolderingPen Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,54 +97,55 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckPort()
|
void CheckPort() {
|
||||||
{
|
|
||||||
hot = false;
|
hot = false;
|
||||||
currentPort = null;
|
currentPort = null;
|
||||||
// Item item = level.FindNearestItem(this);
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
Item item = level.items.elementAt(a);
|
||||||
{
|
if (!item.isDevice() || !Overlaps(item) || item == this) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (!item.isDevice() || !Overlaps(item) || item==this)
|
|
||||||
item = null;
|
item = null;
|
||||||
if (item!=null)
|
}
|
||||||
{
|
if (item != null) {
|
||||||
Device device = (Device) item;
|
Device device = (Device) item;
|
||||||
for (int b=0; b<device.ports.length; b++)
|
for (int b = 0; b < device.ports.length; b++) {
|
||||||
{
|
hot = device.ports[b].x + device.x >= x;
|
||||||
hot = true;
|
if (device.ports[b].x + device.x > x + 9) {
|
||||||
if (device.ports[b].x + device.x < x) hot = false;
|
hot = false;
|
||||||
if (device.ports[b].x + device.x > x+9) hot = false;
|
}
|
||||||
if (device.ports[b].y + device.y < y+18) hot = false;
|
if (device.ports[b].y + device.y < y + 18) {
|
||||||
if (device.ports[b].y + device.y > y+25) hot = false;
|
hot = false;
|
||||||
if (hot)
|
}
|
||||||
{
|
if (device.ports[b].y + device.y > y + 25) {
|
||||||
|
hot = false;
|
||||||
|
}
|
||||||
|
if (hot) {
|
||||||
currentPort = device.ports[b];
|
currentPort = device.ports[b];
|
||||||
if (device.ports[b].myWire == null)
|
if (device.ports[b].myWire == null) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[2].getImage();
|
currentIcon = icons[2].getImage();
|
||||||
|
}
|
||||||
b = device.ports.length;
|
b = device.ports.length;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hot==false)
|
}
|
||||||
|
if (!hot) {
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveUp(boolean nudge)
|
public void moveUp(boolean nudge) {
|
||||||
{
|
|
||||||
Room tempRoom = room;
|
Room tempRoom = room;
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.UpEnterOverlap(this)) {
|
||||||
if (item.UpEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 280; // 10 * 28
|
int newX = 280; // 10 * 28
|
||||||
int newY = 320; // 10 * 32
|
int newY = 320; // 10 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -163,22 +153,21 @@ public void MoveUp(boolean nudge)
|
|||||||
SetRoom(item.InternalRoom);
|
SetRoom(item.InternalRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.MoveUp( nudge);
|
}
|
||||||
if (tempRoom != room && ports[0].myWire != null)
|
super.moveUp(nudge);
|
||||||
|
if (tempRoom != room && ports[0].myWire != null) {
|
||||||
ports[0].myWire.Remove();
|
ports[0].myWire.Remove();
|
||||||
|
}
|
||||||
// wiredPort=null;
|
// wiredPort=null;
|
||||||
CheckPort();
|
CheckPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveDown(boolean nudge)
|
public void moveDown(boolean nudge) {
|
||||||
{
|
|
||||||
Room tempRoom = room;
|
Room tempRoom = room;
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.DownEnterOverlap(this)) {
|
||||||
if (item.DownEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 280; // 10 * 28
|
int newX = 280; // 10 * 28
|
||||||
int newY = 0; // 0 * 32
|
int newY = 0; // 0 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -186,22 +175,20 @@ public void MoveDown(boolean nudge)
|
|||||||
SetRoom(item.InternalRoom);
|
SetRoom(item.InternalRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.MoveDown( nudge);
|
}
|
||||||
if (tempRoom != room && ports[0].myWire != null)
|
super.moveDown(nudge);
|
||||||
|
if (tempRoom != room && ports[0].myWire != null) {
|
||||||
ports[0].myWire.Remove();
|
ports[0].myWire.Remove();
|
||||||
// wiredPort=null;
|
}
|
||||||
CheckPort();
|
CheckPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveLeft(boolean nudge)
|
public void moveLeft(boolean nudge) {
|
||||||
{
|
|
||||||
Room tempRoom = room;
|
Room tempRoom = room;
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.LeftEnterOverlap(this)) {
|
||||||
if (item.LeftEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 532; // 19 * 28
|
int newX = 532; // 19 * 28
|
||||||
int newY = 176; // 5.5 * 32
|
int newY = 176; // 5.5 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -209,23 +196,20 @@ public void MoveLeft(boolean nudge)
|
|||||||
SetRoom(item.InternalRoom);
|
SetRoom(item.InternalRoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.MoveLeft( nudge);
|
}
|
||||||
if (tempRoom != room && ports[0].myWire != null)
|
super.moveLeft(nudge);
|
||||||
|
if (tempRoom != room && ports[0].myWire != null) {
|
||||||
ports[0].myWire.Remove();
|
ports[0].myWire.Remove();
|
||||||
// wiredPort=null;
|
}
|
||||||
CheckPort();
|
CheckPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveRight(boolean nudge)
|
public void moveRight(boolean nudge) {
|
||||||
{
|
|
||||||
Room tempRoom = room;
|
Room tempRoom = room;
|
||||||
Item item = level.FindNearestItem(this);
|
Item item = level.FindNearestItem(this);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.InternalRoom != null) {
|
||||||
if (item.InternalRoom != null)
|
if (item.RightEnterOverlap(this)) {
|
||||||
{
|
|
||||||
if (item.RightEnterOverlap(this))
|
|
||||||
{
|
|
||||||
int newX = 0; // 0 * 28
|
int newX = 0; // 0 * 28
|
||||||
int newY = 176; // 5.5 * 32
|
int newY = 176; // 5.5 * 32
|
||||||
x = newX;
|
x = newX;
|
||||||
@@ -234,29 +218,27 @@ public void MoveRight(boolean nudge)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.MoveRight( nudge);
|
super.moveRight(nudge);
|
||||||
if (tempRoom != room && ports[0].myWire != null)
|
if (tempRoom != room && ports[0].myWire != null) {
|
||||||
ports[0].myWire.Remove();
|
ports[0].myWire.Remove();
|
||||||
// wiredPort=null;
|
}
|
||||||
CheckPort();
|
CheckPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
Room tempRoom = room;
|
Room tempRoom = room;
|
||||||
super.Animate();
|
super.Animate();
|
||||||
if (tempRoom != room && ports[0].myWire != null)
|
if (tempRoom != room && ports[0].myWire != null) {
|
||||||
ports[0].myWire.Remove();
|
ports[0].myWire.Remove();
|
||||||
|
}
|
||||||
CheckPort();
|
CheckPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{return;}
|
}
|
||||||
|
|
||||||
public void WirePort()
|
void WirePort() {
|
||||||
{
|
if (hot) {
|
||||||
if (hot)
|
|
||||||
{
|
|
||||||
if (ports[0].myWire == null) // If SP is not wired
|
if (ports[0].myWire == null) // If SP is not wired
|
||||||
{
|
{
|
||||||
if (currentPort.myWire != null) // If currentPort is wired
|
if (currentPort.myWire != null) // If currentPort is wired
|
||||||
@@ -279,8 +261,9 @@ public void WirePort()
|
|||||||
// Remove wire at currentPort
|
// Remove wire at currentPort
|
||||||
currentPort.myWire.Remove();
|
currentPort.myWire.Remove();
|
||||||
// Remove wire attached to Pen
|
// Remove wire attached to Pen
|
||||||
if (ports[0].myWire != null)
|
if (ports[0].myWire != null) {
|
||||||
ports[0].myWire.Remove();
|
ports[0].myWire.Remove();
|
||||||
|
}
|
||||||
ports[0].value = false;
|
ports[0].value = false;
|
||||||
ports[0].type = Port.TYPE_UNDEFINED;
|
ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
}
|
}
|
||||||
@@ -300,124 +283,315 @@ public void WirePort()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function ()
|
public boolean Function() {
|
||||||
{
|
if (ports[0].myWire == null) {
|
||||||
if (ports[0].myWire == null)
|
|
||||||
{
|
|
||||||
ports[0].value = false;
|
ports[0].value = false;
|
||||||
ports[0].type = Port.TYPE_UNDEFINED;
|
ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
return !i.getClass().toString().endsWith("Robot");
|
||||||
if (i.getClass().toString().endsWith("Robot"))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
public boolean KeyUp(KeyEvent e) {
|
||||||
{
|
if (e.getKeyCode() == KeyEvent.VK_C && handleGameCursor()) {
|
||||||
if (e.getKeyCode() == e.VK_C)
|
return false;
|
||||||
{
|
}
|
||||||
if (ports[0].myWire != null)
|
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_SLASH && handleHelp()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
WirePort();
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean KeyDown(KeyEvent e) {
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||||
|
repeating++;
|
||||||
|
if (repeating > 10) {
|
||||||
|
moveRight(e.isControlDown());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||||
|
repeating++;
|
||||||
|
if (repeating > 10) {
|
||||||
|
moveLeft(e.isControlDown());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||||
|
repeating++;
|
||||||
|
if (repeating > 10) {
|
||||||
|
moveUp(e.isControlDown());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||||
|
repeating++;
|
||||||
|
if (repeating > 10) {
|
||||||
|
moveDown(e.isControlDown());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MouseClick(MouseEvent e) {
|
||||||
|
int button = 0;
|
||||||
|
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) {
|
||||||
|
button = 1;
|
||||||
|
}
|
||||||
|
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {
|
||||||
|
button = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button == 1) {
|
||||||
|
if (e.getClickCount() == 1) {
|
||||||
|
autoX = e.getX() - 2;
|
||||||
|
autoY = e.getY() - 20;
|
||||||
|
automove = 1;
|
||||||
|
}
|
||||||
|
else if (e.getClickCount() == 2) {
|
||||||
|
int dx = e.getX() - 2 - x;
|
||||||
|
int dy = e.getY() - 20 - y;
|
||||||
|
if (Math.abs(dx) > Math.abs(dy)) {
|
||||||
|
autoY = 0;
|
||||||
|
autoX = 28;
|
||||||
|
if (dx < 0) {
|
||||||
|
autoX = -28;
|
||||||
|
}
|
||||||
|
automove = 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
autoX = 0;
|
||||||
|
autoY = 32;
|
||||||
|
if (dy < 0) {
|
||||||
|
autoY = -32;
|
||||||
|
}
|
||||||
|
automove = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (button == 3) {
|
||||||
|
KeyEvent k = new KeyEvent(e.getComponent(), e.getID(),
|
||||||
|
e.getWhen(), 0,
|
||||||
|
KeyEvent.VK_SPACE, ' ');
|
||||||
|
KeyUp(k);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleGameCursor() {
|
||||||
|
if (ports[0].myWire != null) {
|
||||||
ports[0].myWire.Remove();
|
ports[0].myWire.Remove();
|
||||||
|
}
|
||||||
level.gameCursor.x = x;
|
level.gameCursor.x = x;
|
||||||
level.gameCursor.y = y;
|
level.gameCursor.y = y;
|
||||||
level.gameCursor.room = room;
|
level.gameCursor.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
if (level.currentViewer == level.player)
|
if (level.currentViewer == level.player) {
|
||||||
level.currentViewer = level.gameCursor;
|
level.currentViewer = level.gameCursor;
|
||||||
|
}
|
||||||
level.player = level.gameCursor;
|
level.player = level.gameCursor;
|
||||||
if (level.remote != null)
|
if (level.remote != null) {
|
||||||
if (level.remote.carriedBy != null)
|
if (level.remote.carriedBy != null) {
|
||||||
{
|
|
||||||
level.remote.carriedBy = level.player;
|
level.remote.carriedBy = level.player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_R)
|
|
||||||
{
|
level.roomdisplay.dq.selectCursor();
|
||||||
if (level.remote == null) return false;
|
return true;
|
||||||
if (level.remote.carriedBy == null)
|
}
|
||||||
{ // Summon Remote
|
|
||||||
|
@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.x = 28;
|
||||||
level.remote.y = -20;
|
level.remote.y = -20;
|
||||||
level.remote.carriedBy = level.player;
|
level.remote.carriedBy = level.player;
|
||||||
level.remote.room = level.player.room;
|
level.remote.room = level.player.room;
|
||||||
level.electricity = true;
|
level.electricity = true;
|
||||||
|
|
||||||
|
level.roomdisplay.dq.setRadioSelected(true);
|
||||||
}
|
}
|
||||||
else
|
else { // Hide Remote
|
||||||
{ // Hide Remote
|
|
||||||
level.remote.carriedBy = null;
|
level.remote.carriedBy = null;
|
||||||
level.remote.room = null;
|
level.remote.room = null;
|
||||||
level.electricity = false;
|
level.electricity = false;
|
||||||
|
|
||||||
|
level.roomdisplay.dq.setRadioSelected(false);
|
||||||
}
|
}
|
||||||
// if (ports[0].myWire != null)
|
return true;
|
||||||
// ports[0].myWire.Remove();
|
|
||||||
// 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() == e.VK_P)
|
|
||||||
{
|
@Override
|
||||||
if (level.paintbrush == null) return false;
|
public boolean handleRotateDevice(int direction) {
|
||||||
if (ports[0].myWire != null)
|
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();
|
ports[0].myWire.Remove();
|
||||||
|
}
|
||||||
level.paintbrush.x = x;
|
level.paintbrush.x = x;
|
||||||
level.paintbrush.y = y;
|
level.paintbrush.y = y;
|
||||||
level.paintbrush.room = room;
|
level.paintbrush.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
if (level.currentViewer == level.player)
|
if (level.currentViewer == level.player) {
|
||||||
level.currentViewer = level.paintbrush;
|
level.currentViewer = level.paintbrush;
|
||||||
level.player = level.paintbrush;
|
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_SLASH)
|
level.player = level.paintbrush;
|
||||||
{
|
|
||||||
if (level.helpCam == null) return false;
|
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.player = level.helpCam;
|
||||||
level.currentViewer = level.helpCam;
|
level.currentViewer = level.helpCam;
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
|
||||||
{
|
@Override
|
||||||
if (carriedBy==null)
|
public boolean handleEnterRoom() {
|
||||||
MoveLeft(e.isControlDown());
|
Item item = level.FindNearestItem(this);
|
||||||
repeating=0;
|
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 true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
}
|
||||||
{
|
}
|
||||||
if (carriedBy==null)
|
}
|
||||||
MoveUp(e.isControlDown());
|
return false;
|
||||||
repeating=0;
|
}
|
||||||
|
|
||||||
|
@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 true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
return false;
|
||||||
{
|
|
||||||
if (carriedBy==null)
|
|
||||||
MoveDown(e.isControlDown());
|
|
||||||
repeating=0;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_SPACE)
|
|
||||||
{
|
@Override
|
||||||
WirePort();
|
public boolean handleFlipDevice() {
|
||||||
}
|
if (hot) {
|
||||||
if (e.getKeyCode() == e.VK_F)
|
|
||||||
{
|
|
||||||
if (hot)
|
|
||||||
{
|
|
||||||
if (ports[0].myWire != null) // If SP is wired
|
if (ports[0].myWire != null) // If SP is wired
|
||||||
{
|
{
|
||||||
// Flip wire attached to SP
|
// Flip wire attached to SP
|
||||||
@@ -428,16 +602,14 @@ public boolean KeyUp(KeyEvent e)
|
|||||||
else if (ports[0].myWire == null) // If SP is not wired
|
else if (ports[0].myWire == null) // If SP is not wired
|
||||||
{
|
{
|
||||||
// Flip wire attached to CurrentPort
|
// Flip wire attached to CurrentPort
|
||||||
if (currentPort.myWire != null)
|
if (currentPort.myWire != null) {
|
||||||
{
|
|
||||||
Port tempPort = currentPort.myWire.fromPort;
|
Port tempPort = currentPort.myWire.fromPort;
|
||||||
currentPort.myWire.fromPort = currentPort.myWire.toPort;
|
currentPort.myWire.fromPort = currentPort.myWire.toPort;
|
||||||
currentPort.myWire.toPort = tempPort;
|
currentPort.myWire.toPort = tempPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if (ports[0].myWire != null) // If SP is wired
|
if (ports[0].myWire != null) // If SP is wired
|
||||||
{
|
{
|
||||||
// Flip wire attached to SP
|
// Flip wire attached to SP
|
||||||
@@ -446,98 +618,6 @@ public boolean KeyUp(KeyEvent e)
|
|||||||
ports[0].myWire.toPort = tempPort;
|
ports[0].myWire.toPort = tempPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean KeyDown(KeyEvent e)
|
|
||||||
{
|
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>10)
|
|
||||||
{
|
|
||||||
MoveRight(e.isControlDown());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>10)
|
|
||||||
{
|
|
||||||
MoveLeft(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>10)
|
|
||||||
{
|
|
||||||
MoveUp(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
|
||||||
{
|
|
||||||
repeating++;
|
|
||||||
if (repeating>10)
|
|
||||||
{
|
|
||||||
MoveDown(e.isControlDown());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MouseClick(MouseEvent e)
|
|
||||||
{
|
|
||||||
int button=0;
|
|
||||||
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK)
|
|
||||||
button = 1;
|
|
||||||
if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
|
|
||||||
button = 3;
|
|
||||||
|
|
||||||
if (button==1)
|
|
||||||
{
|
|
||||||
if (e.getClickCount()==1)
|
|
||||||
{
|
|
||||||
autoX = e.getX() - 2;
|
|
||||||
autoY = e.getY() - 20;
|
|
||||||
automove = 1;
|
|
||||||
}
|
|
||||||
else if (e.getClickCount()==2)
|
|
||||||
{
|
|
||||||
int dx = e.getX() - 2 - x;
|
|
||||||
int dy = e.getY() - 20 - y;
|
|
||||||
if (Math.abs(dx) > Math.abs(dy))
|
|
||||||
{
|
|
||||||
autoY=0; autoX=28;
|
|
||||||
if (dx<0) autoX=-28;
|
|
||||||
automove=2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
autoX=0; autoY=32;
|
|
||||||
if (dy<0) autoY=-32;
|
|
||||||
automove=2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (button==3)
|
|
||||||
{
|
|
||||||
KeyEvent k = new KeyEvent(e.getComponent(), e.getID(),
|
|
||||||
e.getWhen(), 0,
|
|
||||||
KeyEvent.VK_SPACE, ' ');
|
|
||||||
KeyUp(k);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,198 +7,181 @@ import com.droidquest.devices.PrototypeChip;
|
|||||||
import com.droidquest.devices.SmallChip;
|
import com.droidquest.devices.SmallChip;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
|
||||||
public class ChipCompiler extends Thread
|
public class ChipCompiler extends Thread {
|
||||||
{
|
|
||||||
public static int chipSpeed = 1;
|
public static int chipSpeed = 1;
|
||||||
|
|
||||||
public ChipCompiler(PrototypeChip pc, SmallChip sc)
|
public ChipCompiler(PrototypeChip pc, SmallChip sc) {
|
||||||
{
|
|
||||||
pc.grabbable = false;
|
pc.grabbable = false;
|
||||||
sc.grabbable = false;
|
sc.grabbable = false;
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
sc.Empty();
|
sc.Empty();
|
||||||
|
|
||||||
for (a=0; a<pc.InternalRoom.wires.size(); a++)
|
for (a = 0; a < pc.InternalRoom.wires.size(); a++) {
|
||||||
sc.signals.addElement(new Signal());
|
sc.signals.addElement(new Signal());
|
||||||
|
}
|
||||||
|
|
||||||
Signal dummy = new Signal();
|
Signal dummy = new Signal();
|
||||||
dummy.working = false;
|
dummy.working = false;
|
||||||
sc.signals.addElement(dummy);
|
sc.signals.addElement(dummy);
|
||||||
|
|
||||||
for (a=0; a<8; a++)
|
for (a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
Wire wire = pc.portdevices[a].ports[0].myWire;
|
Wire wire = pc.portdevices[a].ports[0].myWire;
|
||||||
int index = pc.InternalRoom.wires.indexOf(wire);
|
int index = pc.InternalRoom.wires.indexOf(wire);
|
||||||
if (index>=0)
|
if (index >= 0) {
|
||||||
{
|
sc.portSignals[a].internalSignal = sc.signals.elementAt(index);
|
||||||
Signal sig = (Signal) sc.signals.elementAt(index);
|
|
||||||
sc.portSignals[a].internalSignal= sig;
|
|
||||||
}
|
}
|
||||||
sc.ports[a].type = pc.ports[a].type;
|
sc.ports[a].type = pc.ports[a].type;
|
||||||
sc.portSignals[a].type = pc.ports[a].type;
|
sc.portSignals[a].type = pc.ports[a].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (a=0; a<pc.level.items.size(); a++)
|
for (a = 0; a < pc.level.items.size(); a++) {
|
||||||
{
|
Item item = pc.level.items.elementAt(a);
|
||||||
Item item = (Item) pc.level.items.elementAt(a);
|
if (item.room == pc.InternalRoom) {
|
||||||
if (item.room == pc.InternalRoom)
|
if (item.isDevice()) {
|
||||||
if (item.isDevice())
|
|
||||||
{
|
|
||||||
Device device = (Device) item;
|
Device device = (Device) item;
|
||||||
Gate gate = null;
|
Gate gate = null;
|
||||||
String type = item.getClass().toString();
|
|
||||||
if (device instanceof com.droidquest.devices.ANDGate)
|
if (device instanceof com.droidquest.devices.ANDGate) {
|
||||||
gate = new Gate("AND");
|
gate = new Gate("AND");
|
||||||
if (device instanceof com.droidquest.devices.ORGate)
|
}
|
||||||
|
if (device instanceof com.droidquest.devices.ORGate) {
|
||||||
gate = new Gate("OR");
|
gate = new Gate("OR");
|
||||||
if (device instanceof com.droidquest.devices.NOTGate)
|
}
|
||||||
|
if (device instanceof com.droidquest.devices.NOTGate) {
|
||||||
gate = new Gate("NOT");
|
gate = new Gate("NOT");
|
||||||
if (device instanceof com.droidquest.devices.XORGate)
|
}
|
||||||
|
if (device instanceof com.droidquest.devices.XORGate) {
|
||||||
gate = new Gate("XOR");
|
gate = new Gate("XOR");
|
||||||
if (device instanceof com.droidquest.devices.FlipFlop)
|
}
|
||||||
{
|
if (device instanceof com.droidquest.devices.FlipFlop) {
|
||||||
gate = new Gate("FF");
|
gate = new Gate("FF");
|
||||||
gate.state = ((FlipFlop) device).state;
|
gate.state = ((FlipFlop) device).state;
|
||||||
}
|
}
|
||||||
if (device instanceof com.droidquest.devices.Node)
|
if (device instanceof com.droidquest.devices.Node) {
|
||||||
gate = new Gate("NODE");
|
gate = new Gate("NODE");
|
||||||
if (device instanceof com.droidquest.devices.SmallChip)
|
|
||||||
gate = new Gate((SmallChip)device);
|
|
||||||
if (gate != null)
|
|
||||||
{
|
|
||||||
sc.gates.addElement(gate);
|
|
||||||
for (int p=0; p<device.ports.length; p++)
|
|
||||||
{
|
|
||||||
if (device.ports[p].myWire != null)
|
|
||||||
{
|
|
||||||
int index = pc.InternalRoom.wires.indexOf(device.ports[p].myWire);
|
|
||||||
Signal sig = (Signal) sc.signals.elementAt(index);
|
|
||||||
gate.portSignals[p].externalSignal= sig;
|
|
||||||
// System.out.println("Signal "
|
|
||||||
// + index
|
|
||||||
// + " attached to "
|
|
||||||
// + gate.type
|
|
||||||
// + " Gate["
|
|
||||||
// + p
|
|
||||||
// + "]");
|
|
||||||
}
|
}
|
||||||
else
|
if (device instanceof com.droidquest.devices.SmallChip) {
|
||||||
|
gate = new Gate((SmallChip) device);
|
||||||
|
}
|
||||||
|
if (gate != null) {
|
||||||
|
sc.gates.addElement(gate);
|
||||||
|
for (int p = 0; p < device.ports.length; p++) {
|
||||||
|
if (device.ports[p].myWire != null) {
|
||||||
|
int index = pc.InternalRoom.wires.indexOf(device.ports[p].myWire);
|
||||||
|
gate.portSignals[p].externalSignal = sc.signals.elementAt(index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
gate.portSignals[p].externalSignal = dummy;
|
gate.portSignals[p].externalSignal = dummy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove Node Gates, and transfer Signals
|
// Remove Node Gates, and transfer Signals
|
||||||
for (a = 0; a < sc.gates.size(); a++) //For every Gate in the chip
|
for (a = 0; a < sc.gates.size(); a++) //For every Gate in the chip
|
||||||
{
|
{
|
||||||
Gate gate1 = (Gate) sc.gates.elementAt(a);
|
Gate gate1 = sc.gates.elementAt(a);
|
||||||
if (gate1.type == "NODE")
|
if (gate1.type.equals("NODE")) {
|
||||||
{
|
|
||||||
for (int ap = 1; ap < 4; ap++) // For every output Signal in the Node
|
for (int ap = 1; ap < 4; ap++) // For every output Signal in the Node
|
||||||
{
|
{
|
||||||
Signal s1 = gate1.portSignals[ap].externalSignal;
|
Signal s1 = gate1.portSignals[ap].externalSignal;
|
||||||
if (s1!= null && s1!=dummy)
|
if (s1 != null && s1 != dummy) {
|
||||||
{
|
|
||||||
for (int b = 0; b < sc.gates.size(); b++) // For every other Gate in the Chip
|
for (int b = 0; b < sc.gates.size(); b++) // For every other Gate in the Chip
|
||||||
{
|
{
|
||||||
Gate gate2 = (Gate) sc.gates.elementAt(b);
|
Gate gate2 = sc.gates.elementAt(b);
|
||||||
if (gate1 != gate2)
|
if (gate1 != gate2) {
|
||||||
{
|
|
||||||
for (int bp = 0; bp < 8; bp++) // For every Signal connection in that other gate
|
for (int bp = 0; bp < 8; bp++) // For every Signal connection in that other gate
|
||||||
{
|
{
|
||||||
Signal s2 = gate2.portSignals[bp].externalSignal;
|
Signal s2 = gate2.portSignals[bp].externalSignal;
|
||||||
if (s1 == s2) // If Signal is an output Node signal
|
if (s1 == s2) // If Signal is an output Node signal
|
||||||
{
|
{
|
||||||
// System.out.println("Changing " + gate2.type
|
|
||||||
// + "[" + bp + "] = Signal "
|
|
||||||
// + sc.signals.indexOf(s2)
|
|
||||||
// + " to Signal "
|
|
||||||
// + sc.signals.indexOf(gate1.portSignals[0]));
|
|
||||||
gate2.portSignals[bp].externalSignal
|
gate2.portSignals[bp].externalSignal
|
||||||
= gate1.portSignals[0].externalSignal;
|
= gate1.portSignals[0].externalSignal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int ps=0; ps<8; ps++)
|
for (int ps = 0; ps < 8; ps++) {
|
||||||
if (sc.portSignals[ps].internalSignal==s1)
|
if (sc.portSignals[ps].internalSignal == s1) {
|
||||||
sc.portSignals[ps].internalSignal
|
sc.portSignals[ps].internalSignal
|
||||||
= gate1.portSignals[0].externalSignal;
|
= gate1.portSignals[0].externalSignal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
sc.gates.removeElement(gate1);
|
sc.gates.removeElement(gate1);
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove unused Signals
|
// Remove unused Signals
|
||||||
// System.out.println("Starting with " + sc.signals.size() + " signals");
|
for (a = 0; a < sc.signals.size(); a++) {
|
||||||
// System.out.println("Starting with " + sc.gates.size() + " gates");
|
|
||||||
for (a=0; a<sc.signals.size(); a++)
|
|
||||||
{
|
|
||||||
boolean used = false;
|
boolean used = false;
|
||||||
Signal sig1 = (Signal) sc.signals.elementAt(a);
|
Signal sig1 = sc.signals.elementAt(a);
|
||||||
for (int g = 0; g< sc.gates.size(); g++)
|
for (int g = 0; g < sc.gates.size(); g++) {
|
||||||
{
|
Gate gate = sc.gates.elementAt(g);
|
||||||
Gate gate = (Gate) sc.gates.elementAt(g);
|
for (int s = 0; s < 8; s++) {
|
||||||
for (int s = 0; s< 8; s++)
|
|
||||||
{
|
|
||||||
Signal sig2 = gate.portSignals[s].externalSignal;
|
Signal sig2 = gate.portSignals[s].externalSignal;
|
||||||
if (sig2 != null)
|
if (sig2 != null)
|
||||||
// System.out.println(gate.type + "Gate["+s+"] connected to Signal "
|
|
||||||
// + sc.signals.indexOf(sig2));
|
|
||||||
if (sig1==sig2)
|
|
||||||
{
|
{
|
||||||
// System.out.println("Signal " + a + " is used by " + gate.type + "Gate ");
|
if (sig1 == sig2) {
|
||||||
used = true;
|
used = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int ps = 0; ps<8; ps++)
|
}
|
||||||
if (sc.portSignals[ps].internalSignal==sig1)
|
for (int ps = 0; ps < 8; ps++) {
|
||||||
|
if (sc.portSignals[ps].internalSignal == sig1) {
|
||||||
used = true;
|
used = true;
|
||||||
if (used == false)
|
}
|
||||||
{
|
}
|
||||||
// System.out.println("Removing unused Signal at " + a);
|
if (!used) {
|
||||||
sc.signals.removeElement(sig1);
|
sc.signals.removeElement(sig1);
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Signal types
|
// Set Signal types
|
||||||
for (a=0; a<8; a++)
|
for (a = 0; a < 8; a++) {
|
||||||
if (sc.portSignals[a]!=null)
|
if (sc.portSignals[a] != null) {
|
||||||
sc.portSignals[a].type = sc.ports[a].type;
|
sc.portSignals[a].type = sc.ports[a].type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Debug report
|
// Debug report
|
||||||
System.out.println(sc.signals.size() + " Signals");
|
System.out.println(sc.signals.size() + " Signals");
|
||||||
System.out.println(sc.gates.size() + " Gates");
|
System.out.println(sc.gates.size() + " Gates");
|
||||||
for(a=0; a<sc.gates.size(); a++)
|
for (a = 0; a < sc.gates.size(); a++) {
|
||||||
{
|
Gate gate1 = sc.gates.elementAt(a);
|
||||||
Gate gate1 = (Gate) sc.gates.elementAt(a);
|
for (int b = 0; b < 8; b++) {
|
||||||
gate1.DebugReport(1);
|
if (gate1.portSignals[b].externalSignal != null) {
|
||||||
for (int b=0; b<8; b++)
|
|
||||||
if (gate1.portSignals[b].externalSignal!=null)
|
|
||||||
System.out.println(a + ": " + gate1.type
|
System.out.println(a + ": " + gate1.type
|
||||||
+ " gate["
|
+ " gate["
|
||||||
+ b
|
+ b
|
||||||
+ "] = Signal "
|
+ "] = Signal "
|
||||||
+ sc.signals.indexOf(gate1.portSignals[b].externalSignal));
|
+ sc.signals.indexOf(gate1.portSignals[b].externalSignal));
|
||||||
}
|
}
|
||||||
for (a=0; a<8; a++)
|
}
|
||||||
if (sc.portSignals[a].internalSignal != null)
|
}
|
||||||
|
for (a = 0; a < 8; a++) {
|
||||||
|
if (sc.portSignals[a].internalSignal != null) {
|
||||||
System.out.println("PortSignal "
|
System.out.println("PortSignal "
|
||||||
+ a
|
+ a
|
||||||
+ " = Signal "
|
+ " = Signal "
|
||||||
+ sc.signals.indexOf(sc.portSignals[a].internalSignal));
|
+ sc.signals.indexOf(sc.portSignals[a].internalSignal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sc.speed = chipSpeed;
|
sc.speed = chipSpeed;
|
||||||
if (pc.label != null)
|
if (pc.label != null) {
|
||||||
sc.label = new String(pc.label);
|
sc.label = pc.label;
|
||||||
if (pc.description != null)
|
}
|
||||||
sc.description = new String(pc.description);
|
if (pc.description != null) {
|
||||||
|
sc.description = pc.description;
|
||||||
|
}
|
||||||
sc.GenerateIcons();
|
sc.GenerateIcons();
|
||||||
pc.grabbable = true;
|
pc.grabbable = true;
|
||||||
sc.grabbable = true;
|
sc.grabbable = true;
|
||||||
|
|||||||
@@ -1,131 +1,115 @@
|
|||||||
package com.droidquest.chipstuff;
|
package com.droidquest.chipstuff;
|
||||||
|
|
||||||
|
import com.droidquest.devices.SmallChip;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import com.droidquest.devices.SmallChip;
|
public class Gate implements Serializable {
|
||||||
|
|
||||||
public class Gate implements Serializable
|
|
||||||
{
|
|
||||||
public transient PortSignal[] portSignals = new PortSignal[8];
|
public transient PortSignal[] portSignals = new PortSignal[8];
|
||||||
public boolean state;
|
public boolean state;
|
||||||
public String type;
|
public String type;
|
||||||
public int speed;
|
public int speed;
|
||||||
|
|
||||||
public Vector mySignals = new Vector();
|
public Vector<Signal> mySignals = new Vector<Signal>();
|
||||||
public Vector myGates = new Vector();
|
public Vector<Gate> myGates = new Vector<Gate>();
|
||||||
|
|
||||||
public Gate(String t)
|
public Gate(String t) {
|
||||||
{
|
|
||||||
// Called whenever a non-chip gate is created.
|
// Called whenever a non-chip gate is created.
|
||||||
type = t;
|
type = t;
|
||||||
speed = 1;
|
speed = 1;
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
portSignals[a] = new PortSignal();
|
portSignals[a] = new PortSignal();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Gate(SmallChip sc)
|
public Gate(SmallChip sc) {
|
||||||
{
|
|
||||||
// Called by ChipCompiler to put a nested chip into a gate
|
// Called by ChipCompiler to put a nested chip into a gate
|
||||||
speed = sc.speed;
|
speed = sc.speed;
|
||||||
type = "Chip";
|
type = "Chip";
|
||||||
Signal dummySignal;
|
|
||||||
portSignals = new PortSignal[8];
|
portSignals = new PortSignal[8];
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
portSignals[a] = new PortSignal();
|
portSignals[a] = new PortSignal();
|
||||||
for (int a=0; a<sc.signals.size(); a++)
|
}
|
||||||
{
|
for (int a = 0; a < sc.signals.size(); a++) {
|
||||||
Signal newsig = new Signal();
|
Signal newsig = new Signal();
|
||||||
Signal oldsig = (Signal) sc.signals.elementAt(a);
|
Signal oldsig = sc.signals.elementAt(a);
|
||||||
newsig.Set(oldsig.Get());
|
newsig.Set(oldsig.Get());
|
||||||
newsig.working = oldsig.working;
|
newsig.working = oldsig.working;
|
||||||
mySignals.addElement(newsig);
|
mySignals.addElement(newsig);
|
||||||
if (newsig.working == false)
|
|
||||||
dummySignal=newsig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<sc.gates.size(); a++)
|
for (int a = 0; a < sc.gates.size(); a++) {
|
||||||
{
|
Gate oldgate = sc.gates.elementAt(a);
|
||||||
Gate oldgate = (Gate) sc.gates.elementAt(a);
|
|
||||||
Gate newgate = new Gate(oldgate);
|
Gate newgate = new Gate(oldgate);
|
||||||
myGates.addElement(newgate);
|
myGates.addElement(newgate);
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
if (oldgate.portSignals[b].externalSignal!=null)
|
if (oldgate.portSignals[b].externalSignal != null) {
|
||||||
{
|
|
||||||
int sigIndex = sc.signals.indexOf(oldgate.portSignals[b].externalSignal);
|
int sigIndex = sc.signals.indexOf(oldgate.portSignals[b].externalSignal);
|
||||||
Signal sig = (Signal) mySignals.elementAt(sigIndex);
|
newgate.portSignals[b].externalSignal = mySignals.elementAt(sigIndex);
|
||||||
newgate.portSignals[b].externalSignal = sig;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
if (sc.portSignals[a].internalSignal != null) {
|
||||||
if (sc.portSignals[a].internalSignal!=null)
|
|
||||||
{
|
|
||||||
int sigIndex = sc.signals.indexOf(sc.portSignals[a].internalSignal);
|
int sigIndex = sc.signals.indexOf(sc.portSignals[a].internalSignal);
|
||||||
Signal sig = (Signal) mySignals.elementAt(sigIndex);
|
portSignals[a].internalSignal = mySignals.elementAt(sigIndex);
|
||||||
portSignals[a].internalSignal = sig;
|
|
||||||
portSignals[a].type = sc.portSignals[a].type;
|
portSignals[a].type = sc.portSignals[a].type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gate(Gate g)
|
public Gate(Gate g) {
|
||||||
{
|
|
||||||
// Create a new Gate based off an existing one
|
// Create a new Gate based off an existing one
|
||||||
type = g.type;
|
type = g.type;
|
||||||
state = g.state;
|
state = g.state;
|
||||||
speed = g.speed;
|
speed = g.speed;
|
||||||
portSignals = new PortSignal[8];
|
portSignals = new PortSignal[8];
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
portSignals[a] = new PortSignal();
|
portSignals[a] = new PortSignal();
|
||||||
if (type.equalsIgnoreCase("Chip"))
|
}
|
||||||
{
|
if (type.equalsIgnoreCase("Chip")) {
|
||||||
for (int a=0; a<g.mySignals.size(); a++)
|
for (int a = 0; a < g.mySignals.size(); a++) {
|
||||||
{
|
|
||||||
Signal newsig = new Signal();
|
Signal newsig = new Signal();
|
||||||
Signal oldsig = (Signal) g.mySignals.elementAt(a);
|
Signal oldsig = g.mySignals.elementAt(a);
|
||||||
newsig.Set(oldsig.Get());
|
newsig.Set(oldsig.Get());
|
||||||
newsig.working = oldsig.working;
|
newsig.working = oldsig.working;
|
||||||
mySignals.addElement(newsig);
|
mySignals.addElement(newsig);
|
||||||
}
|
}
|
||||||
for (int a=0; a<g.myGates.size(); a++)
|
for (int a = 0; a < g.myGates.size(); a++) {
|
||||||
{
|
Gate oldgate = g.myGates.elementAt(a);
|
||||||
Gate oldgate = (Gate) g.myGates.elementAt(a);
|
|
||||||
Gate newgate = new Gate(oldgate);
|
Gate newgate = new Gate(oldgate);
|
||||||
myGates.addElement(newgate);
|
myGates.addElement(newgate);
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
|
||||||
int signalIndex = g.mySignals.indexOf(oldgate.portSignals[b].externalSignal);
|
int signalIndex = g.mySignals.indexOf(oldgate.portSignals[b].externalSignal);
|
||||||
if (signalIndex != -1)
|
if (signalIndex != -1) {
|
||||||
newgate.portSignals[b].externalSignal = (Signal)mySignals.elementAt(signalIndex);
|
newgate.portSignals[b].externalSignal = mySignals.elementAt(signalIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int a=0; a<8; a++)
|
}
|
||||||
{
|
for (int a = 0; a < 8; a++) {
|
||||||
if (g.portSignals[a].internalSignal != null)
|
if (g.portSignals[a].internalSignal != null) {
|
||||||
{
|
|
||||||
int sigIndex = g.mySignals.indexOf(g.portSignals[a].internalSignal);
|
int sigIndex = g.mySignals.indexOf(g.portSignals[a].internalSignal);
|
||||||
portSignals[a].internalSignal = (Signal) mySignals.elementAt(sigIndex);
|
portSignals[a].internalSignal = mySignals.elementAt(sigIndex);
|
||||||
portSignals[a].type = g.portSignals[a].type;
|
portSignals[a].type = g.portSignals[a].type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
for (int a = 0; a < 8; a++) {
|
||||||
for (int a=0; a<8; a++)
|
|
||||||
s.writeInt(mySignals.indexOf(portSignals[a].internalSignal));
|
s.writeInt(mySignals.indexOf(portSignals[a].internalSignal));
|
||||||
for (int a=0; a<myGates.size(); a++)
|
}
|
||||||
{
|
for (int a = 0; a < myGates.size(); a++) {
|
||||||
Gate gate = (Gate) myGates.elementAt(a);
|
Gate gate = myGates.elementAt(a);
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
|
||||||
s.writeInt(mySignals.indexOf(gate.portSignals[b].externalSignal));
|
s.writeInt(mySignals.indexOf(gate.portSignals[b].externalSignal));
|
||||||
s.writeInt(gate.portSignals[b].type);
|
s.writeInt(gate.portSignals[b].type);
|
||||||
}
|
}
|
||||||
@@ -133,178 +117,151 @@ public void writeRef(ObjectOutputStream s) throws IOException
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
for (int a = 0; a < 8; a++) {
|
||||||
for (int a=0; a<8; a++)
|
|
||||||
{
|
|
||||||
int portIndex = s.readInt();
|
int portIndex = s.readInt();
|
||||||
if (portIndex>=0)
|
if (portIndex >= 0) {
|
||||||
portSignals[a].internalSignal = (Signal) mySignals.elementAt(portIndex);
|
portSignals[a].internalSignal = mySignals.elementAt(portIndex);
|
||||||
}
|
}
|
||||||
for (int a=0; a<myGates.size(); a++)
|
}
|
||||||
{
|
for (int a = 0; a < myGates.size(); a++) {
|
||||||
Gate gate = (Gate) myGates.elementAt(a);
|
Gate gate = myGates.elementAt(a);
|
||||||
gate.portSignals = new PortSignal[8];
|
gate.portSignals = new PortSignal[8];
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
|
||||||
gate.portSignals[b] = new PortSignal();
|
gate.portSignals[b] = new PortSignal();
|
||||||
int sigIndex = s.readInt();
|
int sigIndex = s.readInt();
|
||||||
if (sigIndex>=0)
|
if (sigIndex >= 0) {
|
||||||
gate.portSignals[b].externalSignal = (Signal) mySignals.elementAt(sigIndex);
|
gate.portSignals[b].externalSignal = mySignals.elementAt(sigIndex);
|
||||||
|
}
|
||||||
gate.portSignals[b].type = s.readInt();
|
gate.portSignals[b].type = s.readInt();
|
||||||
}
|
}
|
||||||
gate.readRef(s);
|
gate.readRef(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Function()
|
public void Function() {
|
||||||
{
|
if (type.equalsIgnoreCase("AND")) {
|
||||||
if (type.equalsIgnoreCase("AND"))
|
|
||||||
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get()
|
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get()
|
||||||
& portSignals[1].externalSignal.Get());
|
& portSignals[1].externalSignal.Get());
|
||||||
if (type.equalsIgnoreCase("OR"))
|
}
|
||||||
|
else if (type.equalsIgnoreCase("OR")) {
|
||||||
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get()
|
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get()
|
||||||
| portSignals[1].externalSignal.Get());
|
| portSignals[1].externalSignal.Get());
|
||||||
if (type.equalsIgnoreCase("NOT"))
|
}
|
||||||
|
else if (type.equalsIgnoreCase("NOT")) {
|
||||||
portSignals[1].externalSignal.Set(!portSignals[0].externalSignal.Get());
|
portSignals[1].externalSignal.Set(!portSignals[0].externalSignal.Get());
|
||||||
if (type.equalsIgnoreCase("XOR"))
|
}
|
||||||
|
else if (type.equalsIgnoreCase("XOR")) {
|
||||||
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get()
|
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get()
|
||||||
^ portSignals[1].externalSignal.Get());
|
^ portSignals[1].externalSignal.Get());
|
||||||
if (type.equalsIgnoreCase("FF"))
|
}
|
||||||
{
|
else if (type.equalsIgnoreCase("FF")) {
|
||||||
if (portSignals[0].externalSignal.Get() ^ portSignals[1].externalSignal.Get())
|
if (portSignals[0].externalSignal.Get() ^ portSignals[1].externalSignal.Get()) {
|
||||||
state = portSignals[0].externalSignal.Get();
|
state = portSignals[0].externalSignal.Get();
|
||||||
|
}
|
||||||
portSignals[2].externalSignal.Set(state);
|
portSignals[2].externalSignal.Set(state);
|
||||||
portSignals[3].externalSignal.Set(!state);
|
portSignals[3].externalSignal.Set(!state);
|
||||||
}
|
}
|
||||||
if (type.equalsIgnoreCase("NODE"))
|
else if (type.equalsIgnoreCase("NODE")) {
|
||||||
{
|
|
||||||
portSignals[1].externalSignal.Set(portSignals[0].externalSignal.Get());
|
portSignals[1].externalSignal.Set(portSignals[0].externalSignal.Get());
|
||||||
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get());
|
portSignals[2].externalSignal.Set(portSignals[0].externalSignal.Get());
|
||||||
if (portSignals[3].externalSignal!=null)
|
if (portSignals[3].externalSignal != null) {
|
||||||
portSignals[3].externalSignal.Set(portSignals[0].externalSignal.Get());
|
portSignals[3].externalSignal.Set(portSignals[0].externalSignal.Get());
|
||||||
}
|
}
|
||||||
if (type.equalsIgnoreCase("Chip"))
|
}
|
||||||
{
|
else if (type.equalsIgnoreCase("Chip")) {
|
||||||
|
|
||||||
for (int s=0; s<speed; s++)
|
for (int s = 0; s < speed; s++) {
|
||||||
{
|
for (int a = 0; a < mySignals.size(); a++) {
|
||||||
for (int a=0; a<mySignals.size(); a++)
|
mySignals.elementAt(a).Flip();
|
||||||
((Signal) mySignals.elementAt(a)).Flip();
|
}
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
if (portSignals[a].externalSignal != null
|
if (portSignals[a].externalSignal != null
|
||||||
&& portSignals[a].internalSignal!=null)
|
&& portSignals[a].internalSignal != null) {
|
||||||
if (portSignals[a].type==Port.TYPE_INPUT)
|
if (portSignals[a].type == Port.TYPE_INPUT) {
|
||||||
portSignals[a].internalSignal.Set(portSignals[a].externalSignal.Get());
|
portSignals[a].internalSignal.Set(portSignals[a].externalSignal.Get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=0; a<myGates.size(); a++)
|
for (int a = 0; a < myGates.size(); a++) {
|
||||||
((Gate) myGates.elementAt(a)).Function();
|
myGates.elementAt(a).Function();
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
if (portSignals[a].externalSignal != null
|
if (portSignals[a].externalSignal != null
|
||||||
&& portSignals[a].internalSignal!=null)
|
&& portSignals[a].internalSignal != null) {
|
||||||
if (portSignals[a].type==Port.TYPE_OUTPUT)
|
if (portSignals[a].type == Port.TYPE_OUTPUT) {
|
||||||
portSignals[a].externalSignal.Set(portSignals[a].internalSignal.Get());
|
portSignals[a].externalSignal.Set(portSignals[a].internalSignal.Get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveSubGate(ObjectOutputStream s) throws IOException
|
public void SaveSubGate(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
s.writeInt(mySignals.size());
|
s.writeInt(mySignals.size());
|
||||||
for (int a=0; a<mySignals.size(); a++)
|
for (int a = 0; a < mySignals.size(); a++) {
|
||||||
{
|
Signal sig = mySignals.elementAt(a);
|
||||||
Signal sig = (Signal)mySignals.elementAt(a);
|
|
||||||
s.writeBoolean(sig.Get());
|
s.writeBoolean(sig.Get());
|
||||||
s.writeBoolean(sig.working);
|
s.writeBoolean(sig.working);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
s.writeInt(mySignals.indexOf(portSignals[a].internalSignal));
|
s.writeInt(mySignals.indexOf(portSignals[a].internalSignal));
|
||||||
s.writeInt(portSignals[a].type);
|
s.writeInt(portSignals[a].type);
|
||||||
}
|
}
|
||||||
|
|
||||||
s.writeInt(myGates.size());
|
s.writeInt(myGates.size());
|
||||||
for (int a=0; a<myGates.size(); a++)
|
for (int a = 0; a < myGates.size(); a++) {
|
||||||
{
|
Gate gate = myGates.elementAt(a);
|
||||||
Gate gate = (Gate) myGates.elementAt(a);
|
|
||||||
s.writeObject(gate.type);
|
s.writeObject(gate.type);
|
||||||
s.writeBoolean(gate.state);
|
s.writeBoolean(gate.state);
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
s.writeInt(mySignals.indexOf(gate.portSignals[b].externalSignal));
|
s.writeInt(mySignals.indexOf(gate.portSignals[b].externalSignal));
|
||||||
if (gate.type.equalsIgnoreCase("Chip"))
|
}
|
||||||
|
if (gate.type.equalsIgnoreCase("Chip")) {
|
||||||
gate.SaveSubGate(s);
|
gate.SaveSubGate(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
s.writeInt(speed);
|
s.writeInt(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadSubGate(ObjectInputStream s) throws IOException, ClassNotFoundException
|
public void LoadSubGate(ObjectInputStream s) throws IOException, ClassNotFoundException {
|
||||||
{
|
|
||||||
int numSignals = s.readInt();
|
int numSignals = s.readInt();
|
||||||
mySignals = new Vector();
|
mySignals = new Vector<Signal>();
|
||||||
for (int a=0; a<numSignals; a++)
|
for (int a = 0; a < numSignals; a++) {
|
||||||
{
|
|
||||||
Signal newSignal = new Signal();
|
Signal newSignal = new Signal();
|
||||||
newSignal.Set(s.readBoolean());
|
newSignal.Set(s.readBoolean());
|
||||||
newSignal.working = s.readBoolean();
|
newSignal.working = s.readBoolean();
|
||||||
mySignals.addElement(newSignal);
|
mySignals.addElement(newSignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
int sigIndex = s.readInt();
|
int sigIndex = s.readInt();
|
||||||
if (sigIndex>=0)
|
if (sigIndex >= 0) {
|
||||||
portSignals[a].internalSignal = (Signal) mySignals.elementAt(sigIndex);
|
portSignals[a].internalSignal = mySignals.elementAt(sigIndex);
|
||||||
|
}
|
||||||
portSignals[a].type = s.readInt();
|
portSignals[a].type = s.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
int numGates = s.readInt();
|
int numGates = s.readInt();
|
||||||
for (int a=0; a<numGates; a++)
|
for (int a = 0; a < numGates; a++) {
|
||||||
{
|
|
||||||
Gate newGate = new Gate((String) s.readObject());
|
Gate newGate = new Gate((String) s.readObject());
|
||||||
newGate.state = s.readBoolean();
|
newGate.state = s.readBoolean();
|
||||||
myGates.addElement(newGate);
|
myGates.addElement(newGate);
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
|
||||||
int sigIndex = s.readInt();
|
int sigIndex = s.readInt();
|
||||||
if (sigIndex>=0)
|
if (sigIndex >= 0) {
|
||||||
newGate.portSignals[b].externalSignal = (Signal) mySignals.elementAt(sigIndex);
|
newGate.portSignals[b].externalSignal = mySignals.elementAt(sigIndex);
|
||||||
}
|
}
|
||||||
if (newGate.type.equalsIgnoreCase("Chip"))
|
}
|
||||||
|
if (newGate.type.equalsIgnoreCase("Chip")) {
|
||||||
newGate.LoadSubGate(s);
|
newGate.LoadSubGate(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
speed = s.readInt();
|
speed = s.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DebugReport(int indent)
|
|
||||||
{
|
|
||||||
// String ind = "";
|
|
||||||
// for (int a=0; a<indent; a++)
|
|
||||||
// ind += " ";
|
|
||||||
// System.out.println(ind + type + "Gate");
|
|
||||||
// System.out.println(ind + mySignals.size() + " Signals");
|
|
||||||
// System.out.println(ind + myGates.size() + " Gates");
|
|
||||||
// for(int a=0; a<myGates.size(); a++)
|
|
||||||
// {
|
|
||||||
// Gate gate1 = (Gate) myGates.elementAt(a);
|
|
||||||
// gate1.DebugReport(indent+1);
|
|
||||||
// for (int b=0; b<8; b++)
|
|
||||||
// if (gate1.myPortSignals[b]!=null)
|
|
||||||
// System.out.println(ind + a + ": " + gate1.type
|
|
||||||
// + " gate["
|
|
||||||
// + b
|
|
||||||
// + "] = Signal "
|
|
||||||
// + mySignals.indexOf(gate1.myPortSignals[b]));
|
|
||||||
// }
|
|
||||||
// for (int a=0; a<8; a++)
|
|
||||||
// if (portSignals[a] != null)
|
|
||||||
// System.out.println(ind + "PortSignal "
|
|
||||||
// + a
|
|
||||||
// + " = Signal "
|
|
||||||
// + mySignals.indexOf(portSignals[a]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ import com.droidquest.devices.Device;
|
|||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class Port implements Serializable
|
public class Port implements Serializable {
|
||||||
{
|
|
||||||
// Input or Output of a Device
|
// Input or Output of a Device
|
||||||
|
|
||||||
public int type; // 0=Input, 1=Output, 2=Undefined
|
public int type; // 0=Input, 1=Output, 2=Undefined
|
||||||
@@ -21,7 +20,7 @@ public class Port implements Serializable
|
|||||||
public static final int TYPE_OUTPUT = 1;
|
public static final int TYPE_OUTPUT = 1;
|
||||||
public static final int TYPE_UNDEFINED = 2;
|
public static final int TYPE_UNDEFINED = 2;
|
||||||
private int size; // Short or Long port 0=Short, 1=Long
|
private int size; // Short or Long port 0=Short, 1=Long
|
||||||
boolean standard; // Shows Graphics?
|
private boolean standard; // Shows Graphics?
|
||||||
public int rotation; //0=Up, 1=Left, 2=Down, 3=Right;
|
public int rotation; //0=Up, 1=Left, 2=Down, 3=Right;
|
||||||
public static final int ROT_UP = 0;
|
public static final int ROT_UP = 0;
|
||||||
public static final int ROT_RIGHT = 1;
|
public static final int ROT_RIGHT = 1;
|
||||||
@@ -31,15 +30,16 @@ public class Port implements Serializable
|
|||||||
public boolean value; // True or False, what else?
|
public boolean value; // True or False, what else?
|
||||||
public int x, y;
|
public int x, y;
|
||||||
public int width, height; // width & height
|
public int width, height; // width & height
|
||||||
public int wireX, wireY;
|
private int wireX;
|
||||||
|
private int wireY;
|
||||||
public transient Item myDevice;
|
public transient Item myDevice;
|
||||||
public transient Wire myWire;
|
public transient Wire myWire;
|
||||||
public boolean locked; // False = Reverts to Undefined with no connections
|
private boolean locked; // False = Reverts to Undefined with no connections
|
||||||
|
|
||||||
public Port() {}
|
public Port() {
|
||||||
|
}
|
||||||
|
|
||||||
public Port(int X, int Y, int Type, int Size, int rot, Device d)
|
public Port(int X, int Y, int Type, int Size, int rot, Device d) {
|
||||||
{
|
|
||||||
// There are realy only two types of Ports: Standard and Chip. A
|
// There are realy only two types of Ports: Standard and Chip. A
|
||||||
// Standard Port is what appears on all Gates, Robot Devices, and
|
// Standard Port is what appears on all Gates, Robot Devices, and
|
||||||
// the Prototype Chip. 20 images are defined for these conditions:
|
// the Prototype Chip. 20 images are defined for these conditions:
|
||||||
@@ -47,61 +47,60 @@ public class Port implements Serializable
|
|||||||
// always Off. If the type is not Standard, it's a chip port, and
|
// always Off. If the type is not Standard, it's a chip port, and
|
||||||
// uses no graphics.
|
// uses no graphics.
|
||||||
|
|
||||||
x=X; y=Y;
|
x = X;
|
||||||
|
y = Y;
|
||||||
type = Type;
|
type = Type;
|
||||||
size = Size;
|
size = Size;
|
||||||
rotation = rot;
|
rotation = rot;
|
||||||
standard = (size > 0);
|
standard = (size > 0);
|
||||||
myDevice = d;
|
myDevice = d;
|
||||||
|
|
||||||
if (standard)
|
if (standard) {
|
||||||
{
|
width = 12;
|
||||||
width = 12; height=size;
|
height = size;
|
||||||
wireX = x + 6; wireY = y + height - 6;
|
wireX = x + 6;
|
||||||
|
wireY = y + height - 6;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
width = 2;
|
||||||
width = 2; height = 2;
|
height = 2;
|
||||||
wireX = x; wireY = y;
|
wireX = x;
|
||||||
|
wireY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type==TYPE_UNDEFINED)
|
locked = type != TYPE_UNDEFINED;
|
||||||
locked=false;
|
|
||||||
else
|
|
||||||
locked=true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
Level level = myDevice.level;
|
Level level = myDevice.level;
|
||||||
s.writeInt(level.items.indexOf(myDevice));
|
s.writeInt(level.items.indexOf(myDevice));
|
||||||
if (myDevice.room != null)
|
if (myDevice.room != null) {
|
||||||
s.writeInt(myDevice.room.wires.indexOf(myWire));
|
s.writeInt(myDevice.room.wires.indexOf(myWire));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s, Level level) throws IOException
|
|
||||||
{
|
|
||||||
myDevice = (Item) level.FindItem(s.readInt());
|
|
||||||
if (myDevice != null)
|
|
||||||
if (myDevice.room != null)
|
|
||||||
myWire = myDevice.room.FindWire(s.readInt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g, int rot)
|
public void readRef(ObjectInputStream s, Level level) throws IOException {
|
||||||
{
|
myDevice = level.FindItem(s.readInt());
|
||||||
if (value)
|
if (myDevice != null) {
|
||||||
|
if (myDevice.room != null) {
|
||||||
|
myWire = myDevice.room.FindWire(s.readInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw(Graphics g, int rot) {
|
||||||
|
if (value) {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
|
}
|
||||||
int relRot = (rotation + rot) % 4;
|
int relRot = (rotation + rot) % 4;
|
||||||
if (standard)
|
if (standard) {
|
||||||
{
|
switch (type) {
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case TYPE_INPUT:
|
case TYPE_INPUT:
|
||||||
switch(relRot)
|
switch (relRot) {
|
||||||
{
|
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.fillRect(x + 0, y + 4, 4, size);
|
g.fillRect(x + 0, y + 4, 4, size);
|
||||||
g.fillRect(x - 4, y + 0, 4, 4);
|
g.fillRect(x - 4, y + 0, 4, 4);
|
||||||
@@ -129,8 +128,7 @@ public class Port implements Serializable
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TYPE_OUTPUT:
|
case TYPE_OUTPUT:
|
||||||
switch(relRot)
|
switch (relRot) {
|
||||||
{
|
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.fillRect(x + 0, y + 0, 4, size);
|
g.fillRect(x + 0, y + 0, 4, size);
|
||||||
g.fillRect(x - 4, y + 2, 12, 2);
|
g.fillRect(x - 4, y + 2, 12, 2);
|
||||||
@@ -158,8 +156,7 @@ public class Port implements Serializable
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TYPE_UNDEFINED:
|
case TYPE_UNDEFINED:
|
||||||
switch(relRot)
|
switch (relRot) {
|
||||||
{
|
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.fillRect(x - 2, y - 4, 8, 12);
|
g.fillRect(x - 2, y - 4, 8, 12);
|
||||||
g.fillRect(x, y + 8, 4, size);
|
g.fillRect(x, y + 8, 4, size);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.droidquest.chipstuff;
|
package com.droidquest.chipstuff;
|
||||||
|
|
||||||
|
|
||||||
public class PortSignal
|
public class PortSignal {
|
||||||
{
|
|
||||||
public Signal externalSignal;
|
public Signal externalSignal;
|
||||||
public Signal internalSignal;
|
public Signal internalSignal;
|
||||||
public int type;
|
public int type;
|
||||||
|
|
||||||
public PortSignal() {}
|
public PortSignal() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,26 +2,25 @@ package com.droidquest.chipstuff;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class Signal implements Serializable
|
public class Signal implements Serializable {
|
||||||
{
|
|
||||||
transient private int index;
|
transient private int index;
|
||||||
private boolean[] value = new boolean[2];
|
private boolean[] value = new boolean[2];
|
||||||
public boolean working;
|
public boolean working;
|
||||||
public Signal()
|
|
||||||
{
|
public Signal() {
|
||||||
index = 0;
|
index = 0;
|
||||||
working = true;
|
working = true;
|
||||||
}
|
}
|
||||||
public void Flip()
|
|
||||||
{
|
public void Flip() {
|
||||||
index = 1 - index;
|
index = 1 - index;
|
||||||
}
|
}
|
||||||
public boolean Get()
|
|
||||||
{
|
public boolean Get() {
|
||||||
return value[index] && working;
|
return value[index] && working;
|
||||||
}
|
}
|
||||||
public void Set(boolean v)
|
|
||||||
{
|
public void Set(boolean v) {
|
||||||
value[1 - index] = v && working;
|
value[1 - index] = v && working;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,33 +4,31 @@ import java.awt.Color;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class Arrow implements Serializable
|
public class Arrow implements Serializable {
|
||||||
{
|
|
||||||
public static int DIR_UP = 0;
|
public static int DIR_UP = 0;
|
||||||
public static int DIR_RIGHT = 1;
|
public static int DIR_RIGHT = 1;
|
||||||
public static int DIR_DOWN = 2;
|
public static int DIR_DOWN = 2;
|
||||||
public static int DIR_LEFT = 3;
|
public static int DIR_LEFT = 3;
|
||||||
public int direction;
|
public int direction;
|
||||||
public int length;
|
private int length;
|
||||||
public int x;
|
private int x;
|
||||||
public int y;
|
public int y;
|
||||||
public Color color;
|
private Color color;
|
||||||
|
|
||||||
public Arrow() {}
|
public Arrow() {
|
||||||
|
}
|
||||||
|
|
||||||
public Arrow(int X, int Y, int dir, int len, Color c)
|
public Arrow(int X, int Y, int dir, int len, Color c) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
direction = dir;
|
direction = dir;
|
||||||
length = len;
|
length = len;
|
||||||
color = c;
|
color = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g)
|
public void Draw(Graphics g) {
|
||||||
{
|
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
switch(direction)
|
switch (direction) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
g.drawLine(x, y, x - 8, y + 8);
|
g.drawLine(x, y, x - 8, y + 8);
|
||||||
g.drawLine(x, y, x + 8, y + 8);
|
g.drawLine(x, y, x + 8, y + 8);
|
||||||
|
|||||||
@@ -7,126 +7,128 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.RoomDisplay;
|
import com.droidquest.RoomDisplay;
|
||||||
|
|
||||||
public class Graphix implements Serializable
|
public class Graphix implements Serializable {
|
||||||
{
|
|
||||||
public String[] filenames;
|
public String[] filenames;
|
||||||
transient protected ImageIcon[] icons; // Array of images for this item
|
private transient ImageIcon[] icons; // Array of images for this item
|
||||||
transient ImageIcon icon;
|
private transient ImageIcon icon;
|
||||||
int animationState;
|
private int animationState;
|
||||||
public int x; // Current position
|
public int x; // Current position
|
||||||
int y;
|
private int y;
|
||||||
int behavior; // Overall behavior (SIT, CYCLE, BOUNCE)
|
private int behavior; // Overall behavior (SIT, CYCLE, BOUNCE)
|
||||||
int current=1; // Current behavior; 1=move forward, -1=move backward
|
private int current = 1; // Current behavior; 1=move forward, -1=move backward
|
||||||
int dx, dy; // Direction of "forward"
|
private int dx;
|
||||||
|
private int dy; // Direction of "forward"
|
||||||
public int count;
|
public int count;
|
||||||
int length; // Number of times the Graphix moves forward
|
private int length; // Number of times the Graphix moves forward
|
||||||
public static int SIT=0;
|
private static int SIT = 0;
|
||||||
public static int CYCLE = 1;
|
public static int CYCLE = 1;
|
||||||
public static int BOUNCE = 2;
|
public static int BOUNCE = 2;
|
||||||
|
|
||||||
public Graphix() {}
|
public Graphix() {
|
||||||
|
}
|
||||||
|
|
||||||
public Graphix(int X, int Y)
|
public Graphix(int X, int Y) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graphix(String file, int X, int Y)
|
public Graphix(String file, int X, int Y) {
|
||||||
{
|
|
||||||
filenames = new String[1];
|
filenames = new String[1];
|
||||||
filenames[0] = new String(file);
|
filenames[0] = file;
|
||||||
behavior = SIT;
|
behavior = SIT;
|
||||||
x=X; y=Y;
|
x = X;
|
||||||
|
y = Y;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graphix(String[] files, int X, int Y)
|
public Graphix(String[] files, int X, int Y) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
filenames = files;
|
filenames = files;
|
||||||
behavior = SIT;
|
behavior = SIT;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graphix(String file, int X, int Y, int b, int DX, int DY, int L)
|
public Graphix(String file, int X, int Y, int b, int DX, int DY, int L) {
|
||||||
{
|
|
||||||
filenames = new String[1];
|
filenames = new String[1];
|
||||||
filenames[0] = new String(file);
|
filenames[0] = file;
|
||||||
x=X; y=Y;
|
x = X;
|
||||||
|
y = Y;
|
||||||
behavior = b;
|
behavior = b;
|
||||||
dx=DX; dy=DY;
|
dx = DX;
|
||||||
|
dy = DY;
|
||||||
length = L;
|
length = L;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graphix(String[] files, int X, int Y, int b, int DX, int DY, int L)
|
public Graphix(String[] files, int X, int Y, int b, int DX, int DY, int L) {
|
||||||
{
|
|
||||||
filenames = files;
|
filenames = files;
|
||||||
x=X; y=Y;
|
x = X;
|
||||||
|
y = Y;
|
||||||
behavior = b;
|
behavior = b;
|
||||||
dx=DX; dy=DY;
|
dx = DX;
|
||||||
|
dy = DY;
|
||||||
length = L;
|
length = L;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
int numfiles = filenames.length;
|
int numfiles = filenames.length;
|
||||||
icons = new ImageIcon[numfiles];
|
icons = new ImageIcon[numfiles];
|
||||||
for (int a=0; a< numfiles; a++)
|
for (int a = 0; a < numfiles; a++) {
|
||||||
icons[a] = new ImageIcon("images/" + filenames[a]);
|
icons[a] = new ImageIcon("images/" + filenames[a]);
|
||||||
|
}
|
||||||
icon = icons[0];
|
icon = icons[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g, RoomDisplay rd)
|
public void Draw(Graphics g, RoomDisplay rd) {
|
||||||
{
|
if (icon != null) {
|
||||||
if (icon != null)
|
|
||||||
g.drawImage(icon.getImage(), x, y, rd);
|
g.drawImage(icon.getImage(), x, y, rd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
int numfiles = filenames.length;
|
int numfiles = filenames.length;
|
||||||
animationState++;
|
animationState++;
|
||||||
if (animationState==numfiles)
|
if (animationState == numfiles) {
|
||||||
animationState = 0;
|
animationState = 0;
|
||||||
|
}
|
||||||
icon = icons[animationState];
|
icon = icons[animationState];
|
||||||
if (behavior==CYCLE)
|
if (behavior == CYCLE) {
|
||||||
{
|
if (count == length) {
|
||||||
if (count==length)
|
|
||||||
{
|
|
||||||
x -= dx * length;
|
x -= dx * length;
|
||||||
y -= dy * length;
|
y -= dy * length;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
x += dx;
|
||||||
x+=dx; y+=dy;
|
y += dy;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (behavior==BOUNCE)
|
if (behavior == BOUNCE) {
|
||||||
if (current==1)
|
if (current == 1) {
|
||||||
{
|
if (count == length) {
|
||||||
if (count==length)
|
|
||||||
current = -1;
|
current = -1;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
x+=dx; y+=dy;
|
x += dx;
|
||||||
|
y += dy;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (count == 0) {
|
||||||
if (count==0)
|
|
||||||
current = 1;
|
current = 1;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
x-=dx; y-=dy;
|
x -= dx;
|
||||||
|
y -= dy;
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,38 +6,42 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Spark implements Serializable
|
public class Spark implements Serializable {
|
||||||
{
|
|
||||||
public int x, y;
|
public int x, y;
|
||||||
public int dx,dy;
|
private int dx;
|
||||||
|
private int dy;
|
||||||
public int age;
|
public int age;
|
||||||
public Room room;
|
public Room room;
|
||||||
|
|
||||||
public Spark() {}
|
|
||||||
|
|
||||||
public Spark(int X, int Y, int Dx, int Dy, Room r)
|
public Spark(int X, int Y, int Dx, int Dy, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
dx = Dx; dy= Dy;
|
dx = Dx;
|
||||||
|
dy = Dy;
|
||||||
room = r;
|
room = r;
|
||||||
age = 0;
|
age = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Age()
|
public void Age() {
|
||||||
{
|
x += dx;
|
||||||
x += dx; y+= dy;
|
y += dy;
|
||||||
if (x<0 || x>560 || y<0 || y>384) room=null;
|
if (x < 0 || x > 560 || y < 0 || y > 384) {
|
||||||
|
room = null;
|
||||||
|
}
|
||||||
age++;
|
age++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g)
|
public void Draw(Graphics g) {
|
||||||
{
|
if (age < 2) {
|
||||||
if (age<2)
|
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
else if (age>=2 && age<4)
|
}
|
||||||
|
else if (age >= 2 && age < 4) {
|
||||||
g.setColor(Color.yellow);
|
g.setColor(Color.yellow);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(Color.red);
|
g.setColor(Color.red);
|
||||||
|
}
|
||||||
g.fillRect(x, y, 2, 2);
|
g.fillRect(x, y, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,25 +2,26 @@ package com.droidquest.decorations;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class TextBox implements Serializable
|
public class TextBox implements Serializable {
|
||||||
{
|
|
||||||
public String textString;
|
public String textString;
|
||||||
public int x; // Position
|
public int x; // Position
|
||||||
public int y;
|
public int y;
|
||||||
public int width; // Size
|
public int width; // Size
|
||||||
|
|
||||||
public TextBox() {}
|
public TextBox() {
|
||||||
|
|
||||||
public TextBox(String t, int X, int Y, int W)
|
|
||||||
{
|
|
||||||
textString = t;
|
|
||||||
x=X; y=Y; width=W;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextBox(String t, int X, int Y)
|
public TextBox(String t, int X, int Y, int W) {
|
||||||
{
|
|
||||||
textString = t;
|
textString = t;
|
||||||
x=X; y=Y;
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
width = W;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextBox(String t, int X, int Y) {
|
||||||
|
textString = t;
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
width = 500;
|
width = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,96 +1,90 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.Wire;
|
import com.droidquest.Wire;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.items.ToolBox;
|
|
||||||
|
|
||||||
public class ANDGate extends Device
|
public class ANDGate extends Device {
|
||||||
{
|
private transient ImageIcon[] images;
|
||||||
transient ImageIcon images[];
|
|
||||||
|
|
||||||
public ANDGate(int X, int Y, Room r)
|
public ANDGate(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room =r;
|
y = Y;
|
||||||
width=28; height=50;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 50;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
if (ports[0].value && ports[1].value)
|
if (ports[0].value && ports[1].value) {
|
||||||
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[3];
|
ports = new Port[3];
|
||||||
ports[0] = new Port(7, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
ports[0] = new Port(7, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
||||||
ports[1] = new Port(23, 43, Port.TYPE_INPUT, 8, Port.ROT_DOWN, this);
|
ports[1] = new Port(23, 43, Port.TYPE_INPUT, 8, Port.ROT_DOWN, this);
|
||||||
ports[2] = new Port(12, 2, Port.TYPE_OUTPUT, 16, Port.ROT_UP, this);
|
ports[2] = new Port(12, 2, Port.TYPE_OUTPUT, 16, Port.ROT_UP, this);
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goesInToolbox = true;
|
goesInToolbox = true;
|
||||||
images = new ImageIcon[8];
|
images = new ImageIcon[8];
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
if (rotation%2==0)
|
if (rotation % 2 == 0) {
|
||||||
{w=width; h=height;}
|
w = width;
|
||||||
else
|
h = height;
|
||||||
{w=height; h=width;}
|
}
|
||||||
for (int v=0; v<2; v++)
|
else {
|
||||||
for (int r=0; r<4; r++)
|
w = height;
|
||||||
{
|
h = width;
|
||||||
|
}
|
||||||
|
for (int v = 0; v < 2; v++) {
|
||||||
|
for (int r = 0; r < 4; r++) {
|
||||||
int a = r + v * 4;
|
int a = r + v * 4;
|
||||||
if (r%2==0)
|
if (r % 2 == 0) {
|
||||||
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
}
|
||||||
{
|
try {
|
||||||
g = images[a].getImage().getGraphics();
|
g = images[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -98,12 +92,13 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
if (v==0)
|
if (v == 0) {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
switch(r)
|
}
|
||||||
{
|
switch (r) {
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.fillRect(8, 16, 12, 2);
|
g.fillRect(8, 16, 12, 2);
|
||||||
g.fillRect(8, 16, 4, 4);
|
g.fillRect(8, 16, 4, 4);
|
||||||
@@ -146,30 +141,39 @@ public void GenerateIcons()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
ports[2].value = ports[0].value & ports[1].value;
|
ports[2].value = ports[0].value & ports[1].value;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flip()
|
public void flip() {
|
||||||
{
|
|
||||||
Wire wire1 = ports[0].myWire;
|
Wire wire1 = ports[0].myWire;
|
||||||
Wire wire2 = ports[1].myWire;
|
Wire wire2 = ports[1].myWire;
|
||||||
if (wire1 != null)
|
if (wire1 != null) {
|
||||||
{
|
if (wire1.fromPort == ports[0]) {
|
||||||
if (wire1.fromPort == ports[0]) wire1.fromPort = ports[1];
|
wire1.fromPort = ports[1];
|
||||||
if (wire1.toPort == ports[0]) wire1.toPort = ports[1];
|
}
|
||||||
if (wire1.inPort == ports[0]) wire1.inPort = ports[1];
|
if (wire1.toPort == ports[0]) {
|
||||||
|
wire1.toPort = ports[1];
|
||||||
|
}
|
||||||
|
if (wire1.inPort == ports[0]) {
|
||||||
|
wire1.inPort = ports[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wire2 != null) {
|
||||||
|
if (wire2.fromPort == ports[1]) {
|
||||||
|
wire2.fromPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.toPort == ports[1]) {
|
||||||
|
wire2.toPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.inPort == ports[1]) {
|
||||||
|
wire2.inPort = ports[0];
|
||||||
}
|
}
|
||||||
if (wire2 != null)
|
|
||||||
{
|
|
||||||
if (wire2.fromPort == ports[1]) wire2.fromPort = ports[0];
|
|
||||||
if (wire2.toPort == ports[1]) wire2.toPort = ports[0];
|
|
||||||
if (wire2.inPort == ports[1]) wire2.inPort = ports[0];
|
|
||||||
}
|
}
|
||||||
ports[0].myWire = wire2;
|
ports[0].myWire = wire2;
|
||||||
ports[1].myWire = wire1;
|
ports[1].myWire = wire1;
|
||||||
|
|||||||
@@ -1,79 +1,76 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
import com.droidquest.Room;
|
||||||
import java.awt.Dimension;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
import com.droidquest.decorations.Spark;
|
||||||
|
import com.droidquest.items.GenericRobot;
|
||||||
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
public class Antenna extends Device {
|
||||||
|
|
||||||
import com.droidquest.items.GenericRobot;
|
|
||||||
import com.droidquest.Room;
|
|
||||||
import com.droidquest.chipstuff.Port;
|
|
||||||
import com.droidquest.decorations.Spark;
|
|
||||||
import com.droidquest.items.Item;
|
|
||||||
|
|
||||||
public class Antenna extends Device
|
|
||||||
{
|
|
||||||
public static int radio = 0; // One frequency that all Antennas use (robots)
|
public static int radio = 0; // One frequency that all Antennas use (robots)
|
||||||
public static int radio2 = 0; // Second frequency transmitted outside of robots.
|
private static int radio2 = 0; // Second frequency transmitted outside of robots.
|
||||||
private boolean oldRadio = false; // Was this radio transmitting last phase?
|
private boolean oldRadio = false; // Was this radio transmitting last phase?
|
||||||
Color color;
|
private Color color;
|
||||||
transient GenericRobot robot;
|
private transient GenericRobot robot;
|
||||||
|
|
||||||
public Antenna(int X, int Y, Room r, Color col)
|
public Antenna(int X, int Y, Room r, Color col) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; color= col;
|
y = Y;
|
||||||
width=44; height=52;
|
color = col;
|
||||||
|
width = 44;
|
||||||
|
height = 52;
|
||||||
room = r;
|
room = r;
|
||||||
if (room.portalItem!=null)
|
if (room.portalItem != null) {
|
||||||
if (room.portalItem.getClass().toString().endsWith("Robot"))
|
if (room.portalItem.getClass().toString().endsWith("Robot")) {
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.writeRef(s);
|
super.writeRef(s);
|
||||||
s.writeInt(level.items.indexOf(robot)); // Index of fromport device
|
s.writeInt(level.items.indexOf(robot)); // Index of fromport device
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
robot = (GenericRobot) level.FindItem(s.readInt());
|
robot = (GenericRobot) level.FindItem(s.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
radio = 0;
|
radio = 0;
|
||||||
radio2 = 0;
|
radio2 = 0;
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[2];
|
ports = new Port[2];
|
||||||
ports[0] = new Port(39, 45, Port.TYPE_INPUT, 18, Port.ROT_DOWN, this);
|
ports[0] = new Port(39, 45, Port.TYPE_INPUT, 18, Port.ROT_DOWN, this);
|
||||||
ports[1] = new Port(11, 50, Port.TYPE_OUTPUT, 26, Port.ROT_DOWN, this);
|
ports[1] = new Port(11, 50, Port.TYPE_OUTPUT, 26, Port.ROT_DOWN, this);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].myDevice = this;
|
port.myDevice = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
super.Animate();
|
super.Animate();
|
||||||
if (robot==null)
|
if (robot == null) {
|
||||||
if (ports[0].value && level.electricity)
|
if (ports[0].value && level.electricity) {
|
||||||
{
|
|
||||||
Dimension d = GetXY();
|
Dimension d = GetXY();
|
||||||
level.sparks.addElement(new Spark(d.width + 26, d.height + 4,
|
level.sparks.addElement(new Spark(d.width + 26, d.height + 4,
|
||||||
level.random.nextInt(9) - 4,
|
level.random.nextInt(9) - 4,
|
||||||
@@ -81,111 +78,103 @@ public void Animate()
|
|||||||
room));
|
room));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = currentIcon.getGraphics();
|
g = currentIcon.getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (robot!=null)
|
if (robot != null) {
|
||||||
{
|
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
g.fillRect(18, 0, 14, 6);
|
g.fillRect(18, 0, 14, 6);
|
||||||
g.fillRect(22, 6, 6, 16);
|
g.fillRect(22, 6, 6, 16);
|
||||||
g.fillRect(8, 22, 32, 2);
|
g.fillRect(8, 22, 32, 2);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (radio2 > 0) {
|
||||||
if (radio2>0)
|
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
|
}
|
||||||
g.fillRect(18, 0, 14, 6);
|
g.fillRect(18, 0, 14, 6);
|
||||||
g.fillRect(22, 6, 6, 16);
|
g.fillRect(22, 6, 6, 16);
|
||||||
g.fillRect(8, 22, 32, 2);
|
g.fillRect(8, 22, 32, 2);
|
||||||
if (ports[0].value && level.electricity)
|
if (ports[0].value && level.electricity) {
|
||||||
level.PlaySound(room, level.BEEPSOUND);
|
level.PlaySound(room, Level.BEEPSOUND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
if (robot != null) {
|
||||||
if (robot!=null)
|
if (radio < 0) {
|
||||||
{
|
|
||||||
if (radio<0)
|
|
||||||
radio = 0;
|
radio = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (radio>0)
|
if (radio > 0) {
|
||||||
{
|
|
||||||
robot.antenna = true;
|
robot.antenna = true;
|
||||||
ports[1].value = true;
|
ports[1].value = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
robot.antenna = false;
|
robot.antenna = false;
|
||||||
ports[1].value = false;
|
ports[1].value = false;
|
||||||
}
|
}
|
||||||
if (oldRadio != ports[0].value)
|
if (oldRadio != ports[0].value) {
|
||||||
{
|
if (ports[0].value) {
|
||||||
if (ports[0].value == true)
|
|
||||||
{
|
|
||||||
robot.broadcasting = true;
|
robot.broadcasting = true;
|
||||||
radio++;
|
radio++;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
robot.broadcasting = false;
|
robot.broadcasting = false;
|
||||||
radio--;
|
radio--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oldRadio = ports[0].value;
|
oldRadio = ports[0].value;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (radio2 < 0) {
|
||||||
if (radio2<0)
|
|
||||||
radio2 = 0;
|
radio2 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (radio2>0)
|
ports[1].value = radio2 > 0;
|
||||||
ports[1].value = true;
|
if (oldRadio != ports[0].value) {
|
||||||
else
|
if (ports[0].value) {
|
||||||
ports[1].value = false;
|
|
||||||
if (oldRadio != ports[0].value)
|
|
||||||
{
|
|
||||||
if (ports[0].value == true)
|
|
||||||
radio2++;
|
radio2++;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
radio2--;
|
radio2--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
oldRadio = ports[0].value;
|
oldRadio = ports[0].value;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRoom(Room r)
|
public void SetRoom(Room r) {
|
||||||
{
|
if (oldRadio) {
|
||||||
if (oldRadio)
|
if (robot != null) {
|
||||||
{
|
|
||||||
if (robot!=null)
|
|
||||||
radio--;
|
radio--;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
radio2--;
|
radio2--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
super.SetRoom(r);
|
super.SetRoom(r);
|
||||||
robot = null;
|
robot = null;
|
||||||
if (room.portalItem!=null)
|
if (room.portalItem != null) {
|
||||||
if (room.portalItem.getClass().toString().endsWith("Robot"))
|
if (room.portalItem.getClass().toString().endsWith("Robot")) {
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
robot = null;
|
robot = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,124 +1,123 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
import com.droidquest.Room;
|
||||||
import java.awt.Dimension;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
import com.droidquest.items.GenericRobot;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
public class Bumper extends Device {
|
||||||
|
private int rotation;
|
||||||
|
private Color color;
|
||||||
|
private transient GenericRobot robot;
|
||||||
|
|
||||||
import com.droidquest.items.GenericRobot;
|
public Bumper(int X, int Y, Room r, int direction, Color col) {
|
||||||
import com.droidquest.Room;
|
x = X;
|
||||||
import com.droidquest.chipstuff.Port;
|
y = Y;
|
||||||
|
|
||||||
public class Bumper extends Device
|
|
||||||
{
|
|
||||||
int rotation;
|
|
||||||
Color color;
|
|
||||||
transient GenericRobot robot;
|
|
||||||
|
|
||||||
public Bumper(int X, int Y , Room r, int direction, Color col)
|
|
||||||
{
|
|
||||||
x=X; y=Y;
|
|
||||||
room = r;
|
room = r;
|
||||||
if (room.portalItem!=null)
|
if (room.portalItem != null) {
|
||||||
if (room.portalItem.getClass().toString().endsWith("Robot"))
|
if (room.portalItem.getClass().toString().endsWith("Robot")) {
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
rotation = direction;
|
rotation = direction;
|
||||||
color = col;
|
color = col;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.writeRef(s);
|
super.writeRef(s);
|
||||||
s.writeInt(level.items.indexOf(robot));
|
s.writeInt(level.items.indexOf(robot));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
robot = (GenericRobot) level.FindItem(s.readInt());
|
robot = (GenericRobot) level.FindItem(s.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[1];
|
ports = new Port[1];
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
width=30; height=42;
|
width = 30;
|
||||||
|
height = 42;
|
||||||
ports[0] = new Port(16, 39, Port.TYPE_OUTPUT, 26, Port.ROT_DOWN, this);
|
ports[0] = new Port(16, 39, Port.TYPE_OUTPUT, 26, Port.ROT_DOWN, this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_RIGHT:
|
case Port.ROT_RIGHT:
|
||||||
width=54; height=24;
|
width = 54;
|
||||||
|
height = 24;
|
||||||
ports[0] = new Port(0, 13, Port.TYPE_OUTPUT, 42, Port.ROT_LEFT, this);
|
ports[0] = new Port(0, 13, Port.TYPE_OUTPUT, 42, Port.ROT_LEFT, this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_DOWN:
|
case Port.ROT_DOWN:
|
||||||
width=30; height=38;
|
width = 30;
|
||||||
|
height = 38;
|
||||||
ports[0] = new Port(13, 2, Port.TYPE_OUTPUT, 22, Port.ROT_UP, this);
|
ports[0] = new Port(13, 2, Port.TYPE_OUTPUT, 22, Port.ROT_UP, this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_LEFT:
|
case Port.ROT_LEFT:
|
||||||
width=54; height=24;
|
width = 54;
|
||||||
|
height = 24;
|
||||||
ports[0] = new Port(52, 10, Port.TYPE_OUTPUT, 40, Port.ROT_RIGHT, this);
|
ports[0] = new Port(52, 10, Port.TYPE_OUTPUT, 40, Port.ROT_RIGHT, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].myDevice = this;
|
port.myDevice = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
width=30; height=42;
|
width = 30;
|
||||||
|
height = 42;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_RIGHT:
|
case Port.ROT_RIGHT:
|
||||||
width=54; height=24;
|
width = 54;
|
||||||
|
height = 24;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_DOWN:
|
case Port.ROT_DOWN:
|
||||||
width=30; height=38;
|
width = 30;
|
||||||
|
height = 38;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_LEFT:
|
case Port.ROT_LEFT:
|
||||||
width=54; height=24;
|
width = 54;
|
||||||
|
height = 24;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = currentIcon.getGraphics();
|
g = currentIcon.getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP: // Thrusts Up, moves Down
|
case Port.ROT_UP: // Thrusts Up, moves Down
|
||||||
g.fillRect(8, 0, 14, 4);
|
g.fillRect(8, 0, 14, 4);
|
||||||
g.fillRect(4, 2, 6, 4);
|
g.fillRect(4, 2, 6, 4);
|
||||||
@@ -160,8 +159,7 @@ public void Decorate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
// Check the walls on the sides of the GenericRobot and set the
|
// Check the walls on the sides of the GenericRobot and set the
|
||||||
// Port outputs and the bumper variables
|
// Port outputs and the bumper variables
|
||||||
|
|
||||||
@@ -169,18 +167,18 @@ public boolean Function()
|
|||||||
int X = d.width;
|
int X = d.width;
|
||||||
int Y = d.height;
|
int Y = d.height;
|
||||||
|
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP: // Top Bumper
|
case Port.ROT_UP: // Top Bumper
|
||||||
{
|
{
|
||||||
int bigXl = (X + 14) / 28;
|
int bigXl = (X + 14) / 28;
|
||||||
int bigXr = (X + 41) / 28;
|
int bigXr = (X + 41) / 28;
|
||||||
int bigY = (Y - 3) / 32;
|
int bigY = (Y - 3) / 32;
|
||||||
boolean collide = false;
|
boolean collide = false;
|
||||||
for (int a=bigXl; a<=bigXr; a++)
|
for (int a = bigXl; a <= bigXr; a++) {
|
||||||
// if (a>=0 && a<19 && bigY>=0 && bigY<12)
|
if (robot.level.materialAt(a, bigY, robot.room).Detectable(robot)) {
|
||||||
if (robot.level.materialAt(a,bigY,robot.room).Detectable(robot))
|
|
||||||
collide = true;
|
collide = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
ports[0].value = collide;
|
ports[0].value = collide;
|
||||||
robot.topBumper = collide;
|
robot.topBumper = collide;
|
||||||
}
|
}
|
||||||
@@ -191,10 +189,11 @@ public boolean Function()
|
|||||||
int bigYt = (Y + 5) / 32;
|
int bigYt = (Y + 5) / 32;
|
||||||
int bigYb = (Y + 36) / 32;
|
int bigYb = (Y + 36) / 32;
|
||||||
boolean collide = false;
|
boolean collide = false;
|
||||||
for (int a=bigYt; a<=bigYb; a++)
|
for (int a = bigYt; a <= bigYb; a++) {
|
||||||
// if (a>=0 && a<12 && bigX>=0 && bigX<20)
|
if (robot.level.materialAt(bigX, a, robot.room).Detectable(robot)) {
|
||||||
if (robot.level.materialAt(bigX,a,robot.room).Detectable(robot))
|
|
||||||
collide = true;
|
collide = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
ports[0].value = collide;
|
ports[0].value = collide;
|
||||||
robot.rightBumper = collide;
|
robot.rightBumper = collide;
|
||||||
}
|
}
|
||||||
@@ -205,10 +204,11 @@ public boolean Function()
|
|||||||
int bigXr = (X + 41) / 28;
|
int bigXr = (X + 41) / 28;
|
||||||
int bigY = (Y + 44) / 32;
|
int bigY = (Y + 44) / 32;
|
||||||
boolean collide = false;
|
boolean collide = false;
|
||||||
for (int a=bigXl; a<=bigXr; a++)
|
for (int a = bigXl; a <= bigXr; a++) {
|
||||||
// if (a>=0 && a<19 && bigY>=0 && bigY<12)
|
if (robot.level.materialAt(a, bigY, robot.room).Detectable(robot)) {
|
||||||
if (robot.level.materialAt(a,bigY,robot.room).Detectable(robot))
|
|
||||||
collide = true;
|
collide = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
ports[0].value = collide;
|
ports[0].value = collide;
|
||||||
robot.bottomBumper = collide;
|
robot.bottomBumper = collide;
|
||||||
}
|
}
|
||||||
@@ -219,10 +219,11 @@ public boolean Function()
|
|||||||
int bigYt = (Y + 5) / 32;
|
int bigYt = (Y + 5) / 32;
|
||||||
int bigYb = (Y + 36) / 32;
|
int bigYb = (Y + 36) / 32;
|
||||||
boolean collide = false;
|
boolean collide = false;
|
||||||
for (int a=bigYt; a<=bigYb; a++)
|
for (int a = bigYt; a <= bigYb; a++) {
|
||||||
// if (a>=0 && a<12 && bigX>=0 && bigX<20)
|
if (robot.level.materialAt(bigX, a, robot.room).Detectable(robot)) {
|
||||||
if (robot.level.materialAt(bigX,a,robot.room).Detectable(robot))
|
|
||||||
collide = true;
|
collide = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
ports[0].value = collide;
|
ports[0].value = collide;
|
||||||
robot.leftBumper = collide;
|
robot.leftBumper = collide;
|
||||||
}
|
}
|
||||||
@@ -232,8 +233,7 @@ public boolean Function()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
robot = null;
|
robot = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,16 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import javax.swing.*;
|
||||||
import java.awt.Container;
|
import java.awt.*;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
public class ChipText extends JDialog {
|
||||||
import javax.swing.JDialog;
|
private JTextArea textarea;
|
||||||
import javax.swing.JPanel;
|
private JTextField textfield;
|
||||||
import javax.swing.JScrollPane;
|
private GenericChip myChip;
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
|
|
||||||
public class ChipText extends JDialog
|
public ChipText(GenericChip gc) {
|
||||||
{
|
|
||||||
JTextArea textarea;
|
|
||||||
JTextField textfield;
|
|
||||||
GenericChip myChip;
|
|
||||||
|
|
||||||
public ChipText(GenericChip gc)
|
|
||||||
{
|
|
||||||
myChip = gc;
|
myChip = gc;
|
||||||
setModal(false);
|
setModal(false);
|
||||||
Container contentPane = getContentPane();
|
Container contentPane = getContentPane();
|
||||||
@@ -34,24 +22,24 @@ public ChipText(GenericChip gc)
|
|||||||
textarea.setLineWrap(true);
|
textarea.setLineWrap(true);
|
||||||
textarea.setWrapStyleWord(true);
|
textarea.setWrapStyleWord(true);
|
||||||
|
|
||||||
JScrollPane scrollpane = new JScrollPane(textarea);
|
JScrollPane scrollPane = new JScrollPane(textarea);
|
||||||
scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||||
scrollpane.setPreferredSize(new Dimension(250,250));
|
scrollPane.setPreferredSize(new Dimension(250, 250));
|
||||||
|
|
||||||
JPanel buttonpanel = new JPanel();
|
JPanel buttonPanel = new JPanel();
|
||||||
buttonpanel.setLayout(new FlowLayout());
|
buttonPanel.setLayout(new FlowLayout());
|
||||||
|
|
||||||
JButton saveButton = new JButton("Save");
|
JButton saveButton = new JButton("Save");
|
||||||
JButton restoreButton = new JButton("Restore");
|
JButton restoreButton = new JButton("Restore");
|
||||||
|
|
||||||
textfield = new JTextField(3);
|
textfield = new JTextField(3);
|
||||||
|
|
||||||
buttonpanel.add(saveButton);
|
buttonPanel.add(saveButton);
|
||||||
buttonpanel.add(restoreButton);
|
buttonPanel.add(restoreButton);
|
||||||
buttonpanel.add(textfield);
|
buttonPanel.add(textfield);
|
||||||
|
|
||||||
contentPane.add(buttonpanel, BorderLayout.NORTH);
|
contentPane.add(buttonPanel, BorderLayout.NORTH);
|
||||||
contentPane.add(scrollpane, BorderLayout.CENTER);
|
contentPane.add(scrollPane, BorderLayout.CENTER);
|
||||||
pack();
|
pack();
|
||||||
|
|
||||||
saveButton.addMouseListener(new MouseAdapter() {
|
saveButton.addMouseListener(new MouseAdapter() {
|
||||||
@@ -71,13 +59,11 @@ public ChipText(GenericChip gc)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEditable(boolean editable)
|
public void setEditable(boolean editable) {
|
||||||
{
|
|
||||||
textarea.setEditable(editable);
|
textarea.setEditable(editable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(String text, String label)
|
public void setText(String text, String label) {
|
||||||
{
|
|
||||||
textarea.setText(text);
|
textarea.setText(text);
|
||||||
textfield.setText(label);
|
textfield.setText(label);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,16 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
|
||||||
public class ContactSensor extends Device
|
public class ContactSensor extends Device {
|
||||||
{
|
private String targetClass;
|
||||||
String targetClass;
|
private Item target;
|
||||||
Item target;
|
private Dimension d1 = new Dimension(); // Output pointing Right, Left
|
||||||
Dimension d1 = new Dimension(); // Output pointing Right, Left
|
private Dimension d2 = new Dimension(); // Output pointing Up, Down
|
||||||
Dimension d2 = new Dimension(); // Output pointing Up, Down
|
|
||||||
|
|
||||||
public ContactSensor(int X, int Y, Room r, Item item)
|
public ContactSensor(int X, int Y, Room r, Item item) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room = r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
target = item;
|
target = item;
|
||||||
editable = true;
|
editable = true;
|
||||||
targetClass = target.getClass().toString().substring(6); // Removes "class "
|
targetClass = target.getClass().toString().substring(6); // Removes "class "
|
||||||
@@ -32,26 +32,23 @@ public ContactSensor(int X, int Y, Room r, Item item)
|
|||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
if (ports == null) {
|
||||||
if (ports==null)
|
|
||||||
{
|
|
||||||
ports = new Port[1];
|
ports = new Port[1];
|
||||||
ports[0] = new Port(width - 2, height / 2 - 2, Port.TYPE_OUTPUT, 24, Port.ROT_UP, this);
|
ports[0] = new Port(width - 2, height / 2 - 2, Port.TYPE_OUTPUT, 24, Port.ROT_UP, this);
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(d2.width, d2.height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(d2.width, d2.height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(d1.width, d1.height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(d1.width, d1.height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -59,50 +56,46 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
ports[0].value = false;
|
ports[0].value = false;
|
||||||
if (room.portalItem == null)
|
if (room.portalItem == null) {
|
||||||
{
|
|
||||||
// Contact Sensor is not inside robot.
|
// Contact Sensor is not inside robot.
|
||||||
for (int a=0;a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.room == room) {
|
||||||
if (item.room == room)
|
if (target.getClass().isInstance(item)) {
|
||||||
// if (item.getClass().toString().endsWith(targetClass))
|
if (item.carriedBy == null) {
|
||||||
if (target.getClass().isInstance(item))
|
if (Overlaps(item)) {
|
||||||
if (item.carriedBy == null)
|
|
||||||
if (Overlaps(item))
|
|
||||||
{
|
|
||||||
ports[0].value = true;
|
ports[0].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Contact Sensor is inside Robot.
|
// Contact Sensor is inside Robot.
|
||||||
for (int a=0;a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.room == room.portalItem.room) {
|
||||||
if (item.room == room.portalItem.room)
|
if (target.getClass().isInstance(item)) {
|
||||||
if (target.getClass().isInstance(item))
|
if (item.carriedBy == null) {
|
||||||
if (item.carriedBy == null)
|
if (room.portalItem.Overlaps(item)) {
|
||||||
if (room.portalItem.Overlaps(item))
|
|
||||||
{
|
|
||||||
ports[0].value = true;
|
ports[0].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
switch (rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
g.drawImage(target.currentIcon, width / 2 - target.getWidth() / 2, 28, level);
|
g.drawImage(target.currentIcon, width / 2 - target.getWidth() / 2, 28, level);
|
||||||
break;
|
break;
|
||||||
@@ -118,27 +111,27 @@ public void Decorate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotate(int dir)
|
public void rotate(int dir) {
|
||||||
{
|
if (rotation == 0 && dir == -1) {
|
||||||
if (rotation ==0 && dir == -1)
|
|
||||||
rotation = 3;
|
rotation = 3;
|
||||||
else if (rotation == 3 && dir == 1)
|
}
|
||||||
|
else if (rotation == 3 && dir == 1) {
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
rotation += dir;
|
rotation += dir;
|
||||||
|
}
|
||||||
|
|
||||||
if (rotation % 2 == 0) // if rotation == Up or Down
|
if (rotation % 2 == 0) // if rotation == Up or Down
|
||||||
{
|
{
|
||||||
width = d2.width;
|
width = d2.width;
|
||||||
height = d2.height;
|
height = d2.height;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
width = d1.width;
|
width = d1.width;
|
||||||
height = d1.height;
|
height = d1.height;
|
||||||
}
|
}
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
ports[0].x = width / 2 - 2;
|
ports[0].x = width / 2 - 2;
|
||||||
ports[0].y = 2;
|
ports[0].y = 2;
|
||||||
@@ -158,8 +151,7 @@ public void rotate(int dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
import com.droidquest.items.ToolBox;
|
import com.droidquest.items.ToolBox;
|
||||||
|
|
||||||
public class Device extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
public class Device extends Item {
|
||||||
// Base Class for the Logical Devices
|
// Base Class for the Logical Devices
|
||||||
|
|
||||||
transient Graphics g;
|
transient Graphics g;
|
||||||
@@ -25,49 +21,46 @@ public class Device extends Item
|
|||||||
// Reference to the toolbox means this device can be put inside the ToolBox
|
// Reference to the toolbox means this device can be put inside the ToolBox
|
||||||
transient boolean goesInToolbox;
|
transient boolean goesInToolbox;
|
||||||
|
|
||||||
public Device()
|
protected Device() {
|
||||||
{
|
|
||||||
// Constructor
|
// Constructor
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.writeRef(s);
|
super.writeRef(s);
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].writeRef(s);
|
port.writeRef(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].readRef(s,level);
|
port.readRef(s, level);
|
||||||
|
}
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
goesInToolbox = false;
|
goesInToolbox = false;
|
||||||
if (ports!=null)
|
if (ports != null) {
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].myDevice = this;
|
port.myDevice = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
if (rotation%2==0)
|
if (rotation % 2 == 0) {
|
||||||
{
|
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(height, width, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(height, width, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[0] = new ImageIcon(new BufferedImage(height, width, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(height, width, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
// Performs the function of the device, such as calculating the
|
// Performs the function of the device, such as calculating the
|
||||||
// output based upon inputs, or handling external functions such as
|
// output based upon inputs, or handling external functions such as
|
||||||
// thrusting, touching walls, grabbing objects, antenna, etc...
|
// thrusting, touching walls, grabbing objects, antenna, etc...
|
||||||
@@ -79,121 +72,110 @@ public class Device extends Item
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = currentIcon.getGraphics();
|
g = currentIcon.getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].Draw(g, rotation);
|
port.Draw(g, rotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDevice()
|
public boolean isDevice() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNode()
|
public boolean isNode() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotate(int dir)
|
public void rotate(int dir) {
|
||||||
{
|
if (rotation == 0 && dir == -1) {
|
||||||
if (rotation ==0 && dir == -1)
|
|
||||||
rotation = 3;
|
rotation = 3;
|
||||||
else if (rotation == 3 && dir == 1)
|
}
|
||||||
|
else if (rotation == 3 && dir == 1) {
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
rotation += dir;
|
rotation += dir;
|
||||||
|
}
|
||||||
|
|
||||||
int oldW = width;
|
int oldW = width;
|
||||||
int oldH = height;
|
int oldH = height;
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
{
|
int oldX = port.x * 2 + 1;
|
||||||
int oldX = ports[a].x*2 + 1;
|
int oldY = port.y * 2 + 1;
|
||||||
int oldY = ports[a].y*2 + 1;
|
temp = port.width;
|
||||||
temp = ports[a].width;
|
port.width = port.height;
|
||||||
ports[a].width = ports[a].height;
|
port.height = temp;
|
||||||
ports[a].height = temp;
|
switch (dir) {
|
||||||
switch (dir)
|
|
||||||
{
|
|
||||||
case 1: // Turn Right
|
case 1: // Turn Right
|
||||||
oldX = oldX - oldW;
|
oldX = oldX - oldW;
|
||||||
oldY = oldY - oldH;
|
oldY = oldY - oldH;
|
||||||
ports[a].x = (width - oldY)/2;
|
port.x = (width - oldY) / 2;
|
||||||
ports[a].y = (height + oldX)/2 ;
|
port.y = (height + oldX) / 2;
|
||||||
break;
|
break;
|
||||||
case -1: // Turn Left
|
case -1: // Turn Left
|
||||||
oldX = oldX - oldW;
|
oldX = oldX - oldW;
|
||||||
oldY = oldY - oldH;
|
oldY = oldY - oldH;
|
||||||
ports[a].x = (width + oldY)/2;
|
port.x = (width + oldY) / 2;
|
||||||
ports[a].y = (height - oldX)/2;
|
port.y = (height - oldX) / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
|
||||||
super.IsDropped();
|
super.IsDropped();
|
||||||
if (goesInToolbox)
|
if (goesInToolbox) {
|
||||||
{
|
if (level.toolbox != null) {
|
||||||
if (level.toolbox != null)
|
if (((ToolBox) level.toolbox).open) {
|
||||||
if (((ToolBox)level.toolbox).open)
|
if (Overlaps(level.toolbox)) {
|
||||||
{
|
|
||||||
if (Overlaps(level.toolbox))
|
|
||||||
{
|
|
||||||
// Remove all wires and delete device
|
// Remove all wires and delete device
|
||||||
for (int a = 0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
if (ports[a].myWire!=null)
|
if (port.myWire != null) {
|
||||||
ports[a].myWire.Remove();
|
port.myWire.Remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
level.items.removeElement(this);
|
level.items.removeElement(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
|
||||||
{
|
|
||||||
if (item.getClass().toString().endsWith("Robot"))
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return super.CanBePickedUp(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
return !item.getClass().toString().endsWith("Robot") && super.CanBePickedUp(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Erase() {
|
||||||
super.Erase();
|
super.Erase();
|
||||||
g = null;
|
g = null;
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
{
|
port.myDevice = null;
|
||||||
ports[a].myDevice = null;
|
port.myWire = null;
|
||||||
ports[a].myWire = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flip()
|
public void flip() {
|
||||||
{
|
// Just rotate twice to flip
|
||||||
return;
|
rotate(1);
|
||||||
|
rotate(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone()
|
public Object clone() {
|
||||||
{
|
Device newDevice;
|
||||||
Device newDevice = null;
|
|
||||||
newDevice = (Device) super.clone();
|
newDevice = (Device) super.clone();
|
||||||
newDevice.ports = null;
|
newDevice.ports = null;
|
||||||
newDevice.GenerateIcons();
|
newDevice.GenerateIcons();
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
import com.droidquest.materials.Material;
|
|
||||||
|
|
||||||
public class DirectionalSensor extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
String targetClass;
|
import java.awt.image.BufferedImage;
|
||||||
Item target;
|
|
||||||
|
|
||||||
public DirectionalSensor(int X, int Y, Room r, Item item)
|
public class DirectionalSensor extends Device {
|
||||||
{
|
private String targetClass;
|
||||||
x=X; y=Y; room = r;
|
private Item target;
|
||||||
|
|
||||||
|
public DirectionalSensor(int X, int Y, Room r, Item item) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
target = item;
|
target = item;
|
||||||
editable = true;
|
editable = true;
|
||||||
targetClass = target.getClass().toString().substring(6); // Removes "class "
|
targetClass = target.getClass().toString().substring(6); // Removes "class "
|
||||||
@@ -33,10 +29,8 @@ public DirectionalSensor(int X, int Y, Room r, Item item)
|
|||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
if (ports == null) {
|
||||||
if (ports==null)
|
|
||||||
{
|
|
||||||
ports = new Port[4];
|
ports = new Port[4];
|
||||||
ports[0] = new Port(width / 2 - 4, 0, Port.TYPE_OUTPUT, 24, Port.ROT_UP, this);
|
ports[0] = new Port(width / 2 - 4, 0, Port.TYPE_OUTPUT, 24, Port.ROT_UP, this);
|
||||||
ports[1] = new Port(width - 5, height / 2 - 4, Port.TYPE_OUTPUT, 24, Port.ROT_RIGHT, this);
|
ports[1] = new Port(width - 5, height / 2 - 4, Port.TYPE_OUTPUT, 24, Port.ROT_RIGHT, this);
|
||||||
@@ -49,88 +43,73 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
ports[0].value = false;
|
ports[0].value = false;
|
||||||
ports[1].value = false;
|
ports[1].value = false;
|
||||||
ports[2].value = false;
|
ports[2].value = false;
|
||||||
ports[3].value = false;
|
ports[3].value = false;
|
||||||
if (room.portalItem == null)
|
if (room.portalItem == null) {
|
||||||
{
|
|
||||||
// Directional Sensor is not inside robot.
|
// Directional Sensor is not inside robot.
|
||||||
for (int a=0;a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.room == room && item.carriedBy == null) {
|
||||||
if (item.room == room && item.carriedBy==null)
|
if (target.getClass().isInstance(item)) {
|
||||||
// if (item.getClass().toString().endsWith(targetClass))
|
|
||||||
if (target.getClass().isInstance(item))
|
|
||||||
{
|
|
||||||
Dimension d = GetXY();
|
Dimension d = GetXY();
|
||||||
int X = d.width;
|
int X = d.width;
|
||||||
int Y = d.height;
|
int Y = d.height;
|
||||||
if (item.y < Y)
|
if (item.y < Y) {
|
||||||
{
|
|
||||||
ports[0].value = true;
|
ports[0].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
if (item.x + item.getWidth() > X + width)
|
if (item.x + item.getWidth() > X + width) {
|
||||||
{
|
|
||||||
ports[1].value = true;
|
ports[1].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
if (item.y + item.getHeight() > Y + height)
|
if (item.y + item.getHeight() > Y + height) {
|
||||||
{
|
|
||||||
ports[2].value = true;
|
ports[2].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
if (item.x < X)
|
if (item.x < X) {
|
||||||
{
|
|
||||||
ports[3].value = true;
|
ports[3].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
// Directional Sensor is inside Robot.
|
// Directional Sensor is inside Robot.
|
||||||
for (int a=0;a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.room == room.portalItem.room && item.carriedBy == null) {
|
||||||
if (item.room == room.portalItem.room && item.carriedBy==null)
|
if (target.getClass().isInstance(item)) {
|
||||||
if (target.getClass().isInstance(item))
|
|
||||||
{
|
|
||||||
Dimension d = room.portalItem.GetXY();
|
Dimension d = room.portalItem.GetXY();
|
||||||
int X = d.width;
|
int X = d.width;
|
||||||
int Y = d.height;
|
int Y = d.height;
|
||||||
if (item.y < Y)
|
if (item.y < Y) {
|
||||||
{
|
|
||||||
ports[0].value = true;
|
ports[0].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
if (item.x + item.getWidth() > X + room.portalItem.getWidth())
|
if (item.x + item.getWidth() > X + room.portalItem.getWidth()) {
|
||||||
{
|
|
||||||
ports[1].value = true;
|
ports[1].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
if (item.y + item.getHeight() > Y + room.portalItem.getHeight())
|
if (item.y + item.getHeight() > Y + room.portalItem.getHeight()) {
|
||||||
{
|
|
||||||
ports[2].value = true;
|
ports[2].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
if (item.x < X)
|
if (item.x < X) {
|
||||||
{
|
|
||||||
ports[3].value = true;
|
ports[3].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
g.drawRect(24, 24, target.getWidth() + 12, target.getHeight() + 12);
|
g.drawRect(24, 24, target.getWidth() + 12, target.getHeight() + 12);
|
||||||
@@ -138,13 +117,11 @@ public void Decorate()
|
|||||||
g.drawImage(target.currentIcon, 30, 30, level);
|
g.drawImage(target.currentIcon, 30, 30, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotate(int dir)
|
public void rotate(int dir) {
|
||||||
{
|
|
||||||
// Does not Rotate!
|
// Does not Rotate!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,96 +1,92 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import com.droidquest.devices.Device;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.Wire;
|
import com.droidquest.Wire;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
|
||||||
public class FlipFlop extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public boolean state;
|
import java.awt.image.BufferedImage;
|
||||||
public Color c1;
|
|
||||||
public Color c2;
|
|
||||||
public transient ImageIcon images[];
|
|
||||||
|
|
||||||
public FlipFlop(int X, int Y, Room r)
|
public class FlipFlop extends Device {
|
||||||
{
|
public boolean state;
|
||||||
x=X; y=Y; room =r;
|
private Color c1;
|
||||||
width=48; height=32;
|
private Color c2;
|
||||||
|
private transient ImageIcon[] images;
|
||||||
|
|
||||||
|
public FlipFlop(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 48;
|
||||||
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
if (!state)
|
if (!state) {
|
||||||
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[4];
|
ports = new Port[4];
|
||||||
ports[0] = new Port(11, 29, Port.TYPE_INPUT, 6, Port.ROT_DOWN, this);
|
ports[0] = new Port(11, 29, Port.TYPE_INPUT, 6, Port.ROT_DOWN, this);
|
||||||
ports[1] = new Port(39, 27, Port.TYPE_INPUT, 4, Port.ROT_DOWN, this);
|
ports[1] = new Port(39, 27, Port.TYPE_INPUT, 4, Port.ROT_DOWN, this);
|
||||||
ports[2] = new Port(8, 2, Port.TYPE_OUTPUT, 8, Port.ROT_UP, this);
|
ports[2] = new Port(8, 2, Port.TYPE_OUTPUT, 8, Port.ROT_UP, this);
|
||||||
ports[3] = new Port(36, 0, Port.TYPE_OUTPUT, 10, Port.ROT_UP, this);
|
ports[3] = new Port(36, 0, Port.TYPE_OUTPUT, 10, Port.ROT_UP, this);
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goesInToolbox = true;
|
goesInToolbox = true;
|
||||||
images = new ImageIcon[8];
|
images = new ImageIcon[8];
|
||||||
int w; int h;
|
int w;
|
||||||
if (rotation%2==0)
|
int h;
|
||||||
{w=width; h=height;}
|
if (rotation % 2 == 0) {
|
||||||
else
|
w = width;
|
||||||
{w=height; h=width;}
|
h = height;
|
||||||
for (int v=0; v<2; v++)
|
}
|
||||||
for (int r=0; r<4; r++)
|
else {
|
||||||
{
|
w = height;
|
||||||
|
h = width;
|
||||||
|
}
|
||||||
|
for (int v = 0; v < 2; v++) {
|
||||||
|
for (int r = 0; r < 4; r++) {
|
||||||
int a = r + v * 4;
|
int a = r + v * 4;
|
||||||
if (r%2==0)
|
if (r % 2 == 0) {
|
||||||
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
}
|
||||||
{
|
try {
|
||||||
g = images[a].getImage().getGraphics();
|
g = images[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -98,18 +94,15 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
if (v==0)
|
if (v == 0) {
|
||||||
{
|
|
||||||
c1 = new Color(255, 128, 0);
|
c1 = new Color(255, 128, 0);
|
||||||
c2 = Color.white;
|
c2 = Color.white;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
c1 = Color.white;
|
c1 = Color.white;
|
||||||
c2 = new Color(255, 128, 0);
|
c2 = new Color(255, 128, 0);
|
||||||
}
|
}
|
||||||
switch(r)
|
switch (r) {
|
||||||
{
|
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.setColor(c1);
|
g.setColor(c1);
|
||||||
g.fillRect(0, 10, 24, 12);
|
g.fillRect(0, 10, 24, 12);
|
||||||
@@ -134,49 +127,69 @@ public void GenerateIcons()
|
|||||||
g.setColor(c1);
|
g.setColor(c1);
|
||||||
g.fillRect(10, 24, 12, 24);
|
g.fillRect(10, 24, 12, 24);
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
if (ports[0].value ^ ports[1].value) {
|
||||||
if (ports[0].value ^ ports[1].value)
|
|
||||||
state = ports[0].value;
|
state = ports[0].value;
|
||||||
|
}
|
||||||
ports[2].value = state;
|
ports[2].value = state;
|
||||||
ports[3].value = !state;
|
ports[3].value = !state;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flip()
|
public void flip() {
|
||||||
{
|
|
||||||
Wire wire1 = ports[0].myWire;
|
Wire wire1 = ports[0].myWire;
|
||||||
Wire wire2 = ports[1].myWire;
|
Wire wire2 = ports[1].myWire;
|
||||||
Wire wire3 = ports[2].myWire;
|
Wire wire3 = ports[2].myWire;
|
||||||
Wire wire4 = ports[3].myWire;
|
Wire wire4 = ports[3].myWire;
|
||||||
if (wire1 != null)
|
if (wire1 != null) {
|
||||||
{
|
if (wire1.fromPort == ports[0]) {
|
||||||
if (wire1.fromPort == ports[0]) wire1.fromPort = ports[1];
|
wire1.fromPort = ports[1];
|
||||||
if (wire1.toPort == ports[0]) wire1.toPort = ports[1];
|
|
||||||
if (wire1.inPort == ports[0]) wire1.inPort = ports[1];
|
|
||||||
}
|
}
|
||||||
if (wire2 != null)
|
if (wire1.toPort == ports[0]) {
|
||||||
{
|
wire1.toPort = ports[1];
|
||||||
if (wire2.fromPort == ports[1]) wire2.fromPort = ports[0];
|
|
||||||
if (wire2.toPort == ports[1]) wire2.toPort = ports[0];
|
|
||||||
if (wire2.inPort == ports[1]) wire2.inPort = ports[0];
|
|
||||||
}
|
}
|
||||||
if (wire3 != null)
|
if (wire1.inPort == ports[0]) {
|
||||||
{
|
wire1.inPort = ports[1];
|
||||||
if (wire3.fromPort == ports[2]) wire3.fromPort = ports[3];
|
}
|
||||||
if (wire3.toPort == ports[2]) wire3.toPort = ports[3];
|
}
|
||||||
if (wire3.outPort == ports[2]) wire3.outPort = ports[3];
|
if (wire2 != null) {
|
||||||
|
if (wire2.fromPort == ports[1]) {
|
||||||
|
wire2.fromPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.toPort == ports[1]) {
|
||||||
|
wire2.toPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.inPort == ports[1]) {
|
||||||
|
wire2.inPort = ports[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wire3 != null) {
|
||||||
|
if (wire3.fromPort == ports[2]) {
|
||||||
|
wire3.fromPort = ports[3];
|
||||||
|
}
|
||||||
|
if (wire3.toPort == ports[2]) {
|
||||||
|
wire3.toPort = ports[3];
|
||||||
|
}
|
||||||
|
if (wire3.outPort == ports[2]) {
|
||||||
|
wire3.outPort = ports[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wire4 != null) {
|
||||||
|
if (wire4.fromPort == ports[3]) {
|
||||||
|
wire4.fromPort = ports[2];
|
||||||
|
}
|
||||||
|
if (wire4.toPort == ports[3]) {
|
||||||
|
wire4.toPort = ports[2];
|
||||||
|
}
|
||||||
|
if (wire4.outPort == ports[3]) {
|
||||||
|
wire4.outPort = ports[2];
|
||||||
}
|
}
|
||||||
if (wire4 != null)
|
|
||||||
{
|
|
||||||
if (wire4.fromPort == ports[3]) wire4.fromPort = ports[2];
|
|
||||||
if (wire4.toPort == ports[3]) wire4.toPort = ports[2];
|
|
||||||
if (wire4.outPort == ports[3]) wire4.outPort = ports[2];
|
|
||||||
}
|
}
|
||||||
ports[0].myWire = wire2;
|
ports[0].myWire = wire2;
|
||||||
ports[1].myWire = wire1;
|
ports[1].myWire = wire1;
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
public class GenericChip extends Device
|
public class GenericChip extends Device {
|
||||||
{
|
|
||||||
public String label;
|
public String label;
|
||||||
public boolean inBurner;
|
public boolean inBurner;
|
||||||
public boolean inTester;
|
public boolean inTester;
|
||||||
public String description = "Chip Pinouts";
|
public String description = "Chip Pinouts";
|
||||||
public transient ChipText chiptext;
|
private transient ChipText chiptext;
|
||||||
|
|
||||||
public GenericChip() {}
|
GenericChip() {
|
||||||
|
}
|
||||||
|
|
||||||
public void rotate(int dir)
|
public void rotate(int dir) {
|
||||||
{
|
|
||||||
// Does not Rotate!
|
// Does not Rotate!
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowText(boolean editable)
|
public void ShowText(boolean editable) {
|
||||||
{
|
if (chiptext == null) {
|
||||||
if (chiptext==null)
|
|
||||||
{
|
|
||||||
chiptext = new ChipText(this);
|
chiptext = new ChipText(this);
|
||||||
chiptext.setTitle("Pinout for Chip " + label);
|
chiptext.setTitle("Pinout for Chip " + label);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,74 +1,71 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.items.GenericRobot;
|
import com.droidquest.items.GenericRobot;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
|
||||||
public class Grabber extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
Color color;
|
import java.awt.image.BufferedImage;
|
||||||
transient GenericRobot robot;
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
public Grabber(int X, int Y, Room r, Color col)
|
public class Grabber extends Device {
|
||||||
{
|
private Color color;
|
||||||
x=X; y=Y; color= col;
|
private transient GenericRobot robot;
|
||||||
width=40; height=48;
|
|
||||||
|
public Grabber(int X, int Y, Room r, Color col) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
color = col;
|
||||||
|
width = 40;
|
||||||
|
height = 48;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
room = r;
|
room = r;
|
||||||
if (room.portalItem!=null)
|
if (room.portalItem != null) {
|
||||||
if (room.portalItem.getClass().toString().endsWith("Robot"))
|
if (room.portalItem.getClass().toString().endsWith("Robot")) {
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.writeRef(s);
|
super.writeRef(s);
|
||||||
s.writeInt(level.items.indexOf(robot)); // Index of fromport device
|
s.writeInt(level.items.indexOf(robot)); // Index of fromport device
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
robot = (GenericRobot) level.FindItem(s.readInt());
|
robot = (GenericRobot) level.FindItem(s.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[2];
|
ports = new Port[2];
|
||||||
ports[0] = new Port(35, 41, Port.TYPE_INPUT, 16, Port.ROT_DOWN, this);
|
ports[0] = new Port(35, 41, Port.TYPE_INPUT, 16, Port.ROT_DOWN, this);
|
||||||
ports[1] = new Port(11, 47, Port.TYPE_OUTPUT, 26, Port.ROT_DOWN, this);
|
ports[1] = new Port(11, 47, Port.TYPE_OUTPUT, 26, Port.ROT_DOWN, this);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].myDevice = this;
|
port.myDevice = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = currentIcon.getGraphics();
|
g = currentIcon.getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -87,32 +84,23 @@ public void Decorate()
|
|||||||
g.fillRect(0, 8, 4, 4);
|
g.fillRect(0, 8, 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
ports[1].value = robot.carrying != null;
|
||||||
if (robot.carrying != null)
|
|
||||||
ports[1].value=true;
|
|
||||||
else
|
|
||||||
ports[1].value=false;
|
|
||||||
|
|
||||||
if (ports[0].value == false)
|
if (!ports[0].value) { // Input Low
|
||||||
{ // Input Low
|
if (robot.carrying != null) {
|
||||||
if (robot.carrying != null)
|
|
||||||
robot.Drops();
|
robot.Drops();
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{ // Input High
|
else { // Input High
|
||||||
if (robot.carrying == null)
|
if (robot.carrying == null) {
|
||||||
{
|
|
||||||
// Try and pick up something
|
// Try and pick up something
|
||||||
Item item = robot.level.FindNearestItem(robot);
|
Item item = robot.level.FindNearestItem(robot);
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
{
|
if (item.CanBePickedUp(robot) && item.carriedBy == null) {
|
||||||
if (item.CanBePickedUp(robot) && item.carriedBy==null)
|
|
||||||
{
|
|
||||||
int CX = item.x + item.getWidth() / 2;
|
int CX = item.x + item.getWidth() / 2;
|
||||||
int CY = item.y + item.getHeight() / 2;
|
int CY = item.y + item.getHeight() / 2;
|
||||||
if (CX>=28+robot.x && CY<21+robot.y)
|
if (CX >= 28 + robot.x && CY < 21 + robot.y) {
|
||||||
{
|
|
||||||
// Move item to robot.x,robot.y
|
// Move item to robot.x,robot.y
|
||||||
item.x = robot.x + 60 - item.getWidth() / 2;
|
item.x = robot.x + 60 - item.getWidth() / 2;
|
||||||
item.y = robot.y - 9 - item.getHeight() / 2;
|
item.y = robot.y - 9 - item.getHeight() / 2;
|
||||||
@@ -120,8 +108,7 @@ public boolean Function()
|
|||||||
robot.PicksUp(item);
|
robot.PicksUp(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CX>=28+robot.x && CY>=21+robot.y)
|
if (CX >= 28 + robot.x && CY >= 21 + robot.y) {
|
||||||
{
|
|
||||||
// Move item to robot.x,robot.y
|
// Move item to robot.x,robot.y
|
||||||
item.x = robot.x + 66 - item.getWidth() / 2;
|
item.x = robot.x + 66 - item.getWidth() / 2;
|
||||||
item.y = robot.y + 41 - item.getHeight() / 2;
|
item.y = robot.y + 41 - item.getHeight() / 2;
|
||||||
@@ -129,8 +116,7 @@ public boolean Function()
|
|||||||
robot.PicksUp(item);
|
robot.PicksUp(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CX<28+robot.x && CY>=21+robot.y)
|
if (CX < 28 + robot.x && CY >= 21 + robot.y) {
|
||||||
{
|
|
||||||
// Move item to robot.x,robot.y
|
// Move item to robot.x,robot.y
|
||||||
item.x = robot.x + 5 - item.getWidth() / 2;
|
item.x = robot.x + 5 - item.getWidth() / 2;
|
||||||
item.y = robot.y + 52 - item.getHeight() / 2;
|
item.y = robot.y + 52 - item.getHeight() / 2;
|
||||||
@@ -138,8 +124,7 @@ public boolean Function()
|
|||||||
robot.PicksUp(item);
|
robot.PicksUp(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CX<28+robot.x && CY<21+robot.y)
|
if (CX < 28 + robot.x && CY < 21 + robot.y) {
|
||||||
{
|
|
||||||
// Move item to robot.x,robot.y
|
// Move item to robot.x,robot.y
|
||||||
item.x = robot.x - 5 - item.getWidth() / 2;
|
item.x = robot.x - 5 - item.getWidth() / 2;
|
||||||
item.y = robot.y + 3 - item.getHeight() / 2;
|
item.y = robot.y + 3 - item.getHeight() / 2;
|
||||||
@@ -155,8 +140,7 @@ public boolean Function()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
robot = null;
|
robot = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,88 +1,86 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
|
||||||
public class NOTGate extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
transient ImageIcon images[];
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public NOTGate(int X, int Y, Room r)
|
public class NOTGate extends Device {
|
||||||
{
|
private transient ImageIcon[] images;
|
||||||
x=X; y=Y; room =r;
|
|
||||||
width=28; height=50;
|
public NOTGate(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 50;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
if (!ports[0].value)
|
if (!ports[0].value) {
|
||||||
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[2];
|
ports = new Port[2];
|
||||||
ports[0] = new Port(15, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
ports[0] = new Port(15, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
||||||
ports[1] = new Port(12, 2, Port.TYPE_OUTPUT, 14, Port.ROT_UP, this);
|
ports[1] = new Port(12, 2, Port.TYPE_OUTPUT, 14, Port.ROT_UP, this);
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goesInToolbox = true;
|
goesInToolbox = true;
|
||||||
images = new ImageIcon[8];
|
images = new ImageIcon[8];
|
||||||
int w; int h;
|
int w;
|
||||||
if (rotation%2==0)
|
int h;
|
||||||
{w=width; h=height;}
|
if (rotation % 2 == 0) {
|
||||||
else
|
w = width;
|
||||||
{w=height; h=width;}
|
h = height;
|
||||||
for (int v=0; v<2; v++)
|
}
|
||||||
for (int r=0; r<4; r++)
|
else {
|
||||||
{
|
w = height;
|
||||||
|
h = width;
|
||||||
|
}
|
||||||
|
for (int v = 0; v < 2; v++) {
|
||||||
|
for (int r = 0; r < 4; r++) {
|
||||||
int a = r + v * 4;
|
int a = r + v * 4;
|
||||||
if (r%2==0)
|
if (r % 2 == 0) {
|
||||||
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
}
|
||||||
{
|
try {
|
||||||
g = images[a].getImage().getGraphics();
|
g = images[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -90,12 +88,13 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
if (v==0)
|
if (v == 0) {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
switch(r)
|
}
|
||||||
{
|
switch (r) {
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.fillRect(8, 16, 4, 4);
|
g.fillRect(8, 16, 4, 4);
|
||||||
g.fillRect(16, 16, 4, 4);
|
g.fillRect(16, 16, 4, 4);
|
||||||
@@ -144,13 +143,13 @@ public void GenerateIcons()
|
|||||||
g.fillRect(30, 24, 4, 4);
|
g.fillRect(30, 24, 4, 4);
|
||||||
g.fillRect(32, 0, 2, 32);
|
g.fillRect(32, 0, 2, 32);
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
ports[1].value = !ports[0].value;
|
ports[1].value = !ports[0].value;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,51 +11,47 @@ import javax.swing.ImageIcon;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
|
||||||
public class Node extends Device
|
public class Node extends Device {
|
||||||
{
|
|
||||||
public static final int TYPE_STRAIGHT = 0;
|
public static final int TYPE_STRAIGHT = 0;
|
||||||
public static final int TYPE_RIGHT = 1;
|
public static final int TYPE_RIGHT = 1;
|
||||||
public static final int TYPE_THREE = 2;
|
public static final int TYPE_THREE = 2;
|
||||||
transient ImageIcon images[];
|
private transient ImageIcon[] images;
|
||||||
int type;
|
private int type;
|
||||||
|
|
||||||
public Node(int X, int Y, Room r, int t)
|
public Node(int X, int Y, Room r, int t) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room =r;
|
y = Y;
|
||||||
width=36; height=32;
|
room = r;
|
||||||
|
width = 36;
|
||||||
|
height = 32;
|
||||||
type = t;
|
type = t;
|
||||||
|
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
System.out.println("Could not get Graphics pointer to ANDGate Image");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
if (ports[0].value)
|
if (ports[0].value) {
|
||||||
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
switch (type) {
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case TYPE_STRAIGHT:
|
case TYPE_STRAIGHT:
|
||||||
ports = new Port[3];
|
ports = new Port[3];
|
||||||
ports[0] = new Port(16, 14, Port.TYPE_INPUT, 0, Port.ROT_UP, this);
|
ports[0] = new Port(16, 14, Port.TYPE_INPUT, 0, Port.ROT_UP, this);
|
||||||
@@ -76,41 +72,44 @@ public void GenerateIcons()
|
|||||||
ports[3] = new Port(19, 31, Port.TYPE_OUTPUT, 12, Port.ROT_DOWN, this);
|
ports[3] = new Port(19, 31, Port.TYPE_OUTPUT, 12, Port.ROT_DOWN, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goesInToolbox = true;
|
goesInToolbox = true;
|
||||||
images = new ImageIcon[8];
|
images = new ImageIcon[8];
|
||||||
int w; int h;
|
int w;
|
||||||
if (rotation%2==0)
|
int h;
|
||||||
{w=width; h=height;}
|
if (rotation % 2 == 0) {
|
||||||
else
|
w = width;
|
||||||
{w=height; h=width;}
|
h = height;
|
||||||
for (int v=0; v<2; v++)
|
}
|
||||||
for (int r=0; r<4; r++)
|
else {
|
||||||
{
|
w = height;
|
||||||
|
h = width;
|
||||||
|
}
|
||||||
|
for (int v = 0; v < 2; v++) {
|
||||||
|
for (int r = 0; r < 4; r++) {
|
||||||
int a = r + v * 4;
|
int a = r + v * 4;
|
||||||
if (r%2==0)
|
if (r % 2 == 0) {
|
||||||
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
}
|
||||||
{
|
try {
|
||||||
g = images[a].getImage().getGraphics();
|
g = images[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -118,12 +117,13 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
if (v==0)
|
if (v == 0) {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
switch(r)
|
}
|
||||||
{
|
switch (r) {
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
case 2: // Down
|
case 2: // Down
|
||||||
g.fillRect(12, 12, 12, 2);
|
g.fillRect(12, 12, 12, 2);
|
||||||
@@ -138,21 +138,21 @@ public void GenerateIcons()
|
|||||||
g.fillRect(12, 12, 2, 12);
|
g.fillRect(12, 12, 2, 12);
|
||||||
g.fillRect(18, 12, 2, 12);
|
g.fillRect(18, 12, 2, 12);
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
boolean oldValue = ports[1].value;
|
boolean oldValue = ports[1].value;
|
||||||
for (int a=1; a<ports.length; a++)
|
for (int a = 1; a < ports.length; a++) {
|
||||||
ports[a].value = ports[0].value;
|
ports[a].value = ports[0].value;
|
||||||
|
}
|
||||||
return (ports[0].value != oldValue);
|
return (ports[0].value != oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNode()
|
public boolean isNode() {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,81 +10,81 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.Wire;
|
import com.droidquest.Wire;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
|
||||||
public class ORGate extends Device
|
public class ORGate extends Device {
|
||||||
{
|
private transient ImageIcon[] images;
|
||||||
transient ImageIcon images[];
|
|
||||||
|
|
||||||
public ORGate(int X, int Y, Room r)
|
public ORGate(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room =r;
|
y = Y;
|
||||||
width=28; height=50;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 50;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to ORGate Image");
|
System.out.println("Could not get Graphics pointer to ORGate Image");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
if (ports[0].value || ports[1].value)
|
if (ports[0].value || ports[1].value) {
|
||||||
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[3];
|
ports = new Port[3];
|
||||||
ports[0] = new Port(7, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
ports[0] = new Port(7, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
||||||
ports[1] = new Port(23, 43, Port.TYPE_INPUT, 8, Port.ROT_DOWN, this);
|
ports[1] = new Port(23, 43, Port.TYPE_INPUT, 8, Port.ROT_DOWN, this);
|
||||||
ports[2] = new Port(12, 2, Port.TYPE_OUTPUT, 16, Port.ROT_UP, this);
|
ports[2] = new Port(12, 2, Port.TYPE_OUTPUT, 16, Port.ROT_UP, this);
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goesInToolbox = true;
|
goesInToolbox = true;
|
||||||
images = new ImageIcon[8];
|
images = new ImageIcon[8];
|
||||||
int w; int h;
|
int w;
|
||||||
if (rotation%2==0)
|
int h;
|
||||||
{w=width; h=height;}
|
if (rotation % 2 == 0) {
|
||||||
else
|
w = width;
|
||||||
{w=height; h=width;}
|
h = height;
|
||||||
for (int v=0; v<2; v++)
|
}
|
||||||
for (int r=0; r<4; r++)
|
else {
|
||||||
{
|
w = height;
|
||||||
|
h = width;
|
||||||
|
}
|
||||||
|
for (int v = 0; v < 2; v++) {
|
||||||
|
for (int r = 0; r < 4; r++) {
|
||||||
int a = r + v * 4;
|
int a = r + v * 4;
|
||||||
if (r%2==0)
|
if (r % 2 == 0) {
|
||||||
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
}
|
||||||
{
|
try {
|
||||||
g = images[a].getImage().getGraphics();
|
g = images[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -92,12 +92,13 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
if (v==0)
|
if (v == 0) {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
switch(r)
|
}
|
||||||
{
|
switch (r) {
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.fillRect(8, 16, 12, 2);
|
g.fillRect(8, 16, 12, 2);
|
||||||
g.fillRect(8, 16, 4, 4);
|
g.fillRect(8, 16, 4, 4);
|
||||||
@@ -157,30 +158,39 @@ public void GenerateIcons()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
ports[2].value = ports[0].value | ports[1].value;
|
ports[2].value = ports[0].value | ports[1].value;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flip()
|
public void flip() {
|
||||||
{
|
|
||||||
Wire wire1 = ports[0].myWire;
|
Wire wire1 = ports[0].myWire;
|
||||||
Wire wire2 = ports[1].myWire;
|
Wire wire2 = ports[1].myWire;
|
||||||
if (wire1 != null)
|
if (wire1 != null) {
|
||||||
{
|
if (wire1.fromPort == ports[0]) {
|
||||||
if (wire1.fromPort == ports[0]) wire1.fromPort = ports[1];
|
wire1.fromPort = ports[1];
|
||||||
if (wire1.toPort == ports[0]) wire1.toPort = ports[1];
|
}
|
||||||
if (wire1.inPort == ports[0]) wire1.inPort = ports[1];
|
if (wire1.toPort == ports[0]) {
|
||||||
|
wire1.toPort = ports[1];
|
||||||
|
}
|
||||||
|
if (wire1.inPort == ports[0]) {
|
||||||
|
wire1.inPort = ports[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wire2 != null) {
|
||||||
|
if (wire2.fromPort == ports[1]) {
|
||||||
|
wire2.fromPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.toPort == ports[1]) {
|
||||||
|
wire2.toPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.inPort == ports[1]) {
|
||||||
|
wire2.inPort = ports[0];
|
||||||
}
|
}
|
||||||
if (wire2 != null)
|
|
||||||
{
|
|
||||||
if (wire2.fromPort == ports[1]) wire2.fromPort = ports[0];
|
|
||||||
if (wire2.toPort == ports[1]) wire2.toPort = ports[0];
|
|
||||||
if (wire2.inPort == ports[1]) wire2.inPort = ports[0];
|
|
||||||
}
|
}
|
||||||
ports[0].myWire = wire2;
|
ports[0].myWire = wire2;
|
||||||
ports[1].myWire = wire1;
|
ports[1].myWire = wire1;
|
||||||
|
|||||||
@@ -3,50 +3,46 @@ package com.droidquest.devices;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
|
||||||
public class PortDevice extends Device
|
public class PortDevice extends Device {
|
||||||
{
|
|
||||||
// This is an invisible device which has a port sticking out of it. It's
|
// This is an invisible device which has a port sticking out of it. It's
|
||||||
// used inside the Prototype chip as well as in various spots inside the Tutorials.
|
// used inside the Prototype chip as well as in various spots inside the Tutorials.
|
||||||
|
|
||||||
int type;
|
private int type;
|
||||||
int size;
|
private int size;
|
||||||
|
|
||||||
public boolean value = false; // Used for constants in Tutorials
|
public boolean value = false; // Used for constants in Tutorials
|
||||||
|
|
||||||
public PortDevice(int X, int Y, Room r, int s, int t)
|
public PortDevice(int X, int Y, Room r, int s, int t) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room = r;
|
y = Y;
|
||||||
type=t; size=s;
|
room = r;
|
||||||
|
type = t;
|
||||||
|
size = s;
|
||||||
width = 20;
|
width = 20;
|
||||||
height = size + 20;
|
height = size + 20;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[1];
|
ports = new Port[1];
|
||||||
ports[0] = new Port(8, 8, type, size, Port.ROT_UP, this);
|
ports[0] = new Port(8, 8, type, size, Port.ROT_UP, this);
|
||||||
}
|
}
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
if (value && ports[0].type == Port.TYPE_OUTPUT) {
|
||||||
if (value && ports[0].type == Port.TYPE_OUTPUT)
|
|
||||||
ports[0].value = true;
|
ports[0].value = true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +1,32 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.FontMetrics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
import com.droidquest.materials.ChipTrash;
|
import com.droidquest.materials.ChipTrash;
|
||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
public class Prototype16Chip extends GenericChip
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
transient PortDevice portdevices[];
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
public Prototype16Chip(int X, int Y, Room r)
|
public class Prototype16Chip extends GenericChip {
|
||||||
{
|
private transient PortDevice[] portdevices;
|
||||||
x=X; y=Y; room =r;
|
|
||||||
width=40; height=40;
|
public Prototype16Chip(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 40;
|
||||||
|
height = 40;
|
||||||
|
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// g = icons[0].getImage().getGraphics();
|
|
||||||
// }
|
|
||||||
// catch (NullPointerException e)
|
|
||||||
// {
|
|
||||||
// System.out.println("Could not get Graphics pointer to PrototypeChip Image");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
InternalRoom = new Room();
|
InternalRoom = new Room();
|
||||||
int[][] table = {
|
InternalRoom.RoomArray = new int[][]{
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
@@ -52,13 +40,16 @@ public Prototype16Chip(int X, int Y, Room r)
|
|||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||||
};
|
};
|
||||||
InternalRoom.RoomArray = table;
|
|
||||||
Material mat1 = new Material(Color.blue, false, true);
|
Material mat1 = new Material(Color.blue, false, true);
|
||||||
level.materials.addElement(mat1);
|
level.materials.addElement(mat1);
|
||||||
int mat1Index = level.materials.size() - 1;
|
int mat1Index = level.materials.size() - 1;
|
||||||
for (int rY=0; rY<12; rY++)
|
for (int rY = 0; rY < 12; rY++) {
|
||||||
for (int rX=0; rX<20; rX++)
|
for (int rX = 0; rX < 20; rX++) {
|
||||||
if (InternalRoom.RoomArray[rY][rX]==1) InternalRoom.RoomArray[rY][rX] = mat1Index;
|
if (InternalRoom.RoomArray[rY][rX] == 1) {
|
||||||
|
InternalRoom.RoomArray[rY][rX] = mat1Index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
InternalRoom.GenerateArray();
|
InternalRoom.GenerateArray();
|
||||||
InternalRoom.portalItem = this;
|
InternalRoom.portalItem = this;
|
||||||
level.rooms.addElement(InternalRoom);
|
level.rooms.addElement(InternalRoom);
|
||||||
@@ -88,20 +79,22 @@ public Prototype16Chip(int X, int Y, Room r)
|
|||||||
portdevices[9].rotate(-1);
|
portdevices[9].rotate(-1);
|
||||||
portdevices[10].rotate(-1);
|
portdevices[10].rotate(-1);
|
||||||
portdevices[11].rotate(-1);
|
portdevices[11].rotate(-1);
|
||||||
portdevices[12].rotate(1);portdevices[12].rotate(1);
|
portdevices[12].rotate(1);
|
||||||
portdevices[13].rotate(1);portdevices[13].rotate(1);
|
portdevices[12].rotate(1);
|
||||||
portdevices[14].rotate(1);portdevices[14].rotate(1);
|
portdevices[13].rotate(1);
|
||||||
portdevices[15].rotate(1);portdevices[15].rotate(1);
|
portdevices[13].rotate(1);
|
||||||
|
portdevices[14].rotate(1);
|
||||||
|
portdevices[14].rotate(1);
|
||||||
|
portdevices[15].rotate(1);
|
||||||
|
portdevices[15].rotate(1);
|
||||||
|
|
||||||
for (int a=0; a<16; a++)
|
for (int a = 0; a < 16; a++) {
|
||||||
level.items.addElement(portdevices[a]);
|
level.items.addElement(portdevices[a]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
if (ports == null) {
|
||||||
// super.GenerateIcons();
|
|
||||||
if (ports==null)
|
|
||||||
{
|
|
||||||
ports = new Port[16];
|
ports = new Port[16];
|
||||||
ports[0] = new Port(1, 8, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
ports[0] = new Port(1, 8, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
||||||
ports[1] = new Port(1, 16, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
ports[1] = new Port(1, 16, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
||||||
@@ -122,12 +115,10 @@ public void GenerateIcons()
|
|||||||
}
|
}
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -153,8 +144,7 @@ public void GenerateIcons()
|
|||||||
g.fillRect(15, 1, 2, 2);
|
g.fillRect(15, 1, 2, 2);
|
||||||
g.fillRect(7, 1, 2, 2);
|
g.fillRect(7, 1, 2, 2);
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
if (label != null)
|
if (label != null) {
|
||||||
{
|
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
Font font = new Font("Courier", Font.BOLD, 20);
|
Font font = new Font("Courier", Font.BOLD, 20);
|
||||||
g.setFont(font);
|
g.setFont(font);
|
||||||
@@ -165,30 +155,27 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{}
|
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
|
||||||
{
|
|
||||||
super.writeRef(s);
|
|
||||||
for (int a=0; a<16; a++)
|
|
||||||
s.writeInt(level.items.indexOf(portdevices[a]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
super.writeRef(s);
|
||||||
|
for (int a = 0; a < 16; a++) {
|
||||||
|
s.writeInt(level.items.indexOf(portdevices[a]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
portdevices = new PortDevice[16];
|
portdevices = new PortDevice[16];
|
||||||
for (int a=0; a<ports.length; a++)
|
for (int a = 0; a < ports.length; a++) {
|
||||||
{
|
|
||||||
Item item = level.FindItem(s.readInt());
|
Item item = level.FindItem(s.readInt());
|
||||||
portdevices[a] = (PortDevice) item;
|
portdevices[a] = (PortDevice) item;
|
||||||
}
|
}
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
|
||||||
inBurner = false;
|
inBurner = false;
|
||||||
inTester = false;
|
inTester = false;
|
||||||
int bigXl = (x) / 28;
|
int bigXl = (x) / 28;
|
||||||
@@ -196,14 +183,16 @@ public void IsDropped()
|
|||||||
int bigYt = (y) / 32;
|
int bigYt = (y) / 32;
|
||||||
int bigYb = (y + height - 1) / 32;
|
int bigYb = (y + height - 1) / 32;
|
||||||
|
|
||||||
if (bigXr>19) bigXr=19;
|
if (bigXr > 19) {
|
||||||
if (bigYb>11) bigYb=11;
|
bigXr = 19;
|
||||||
|
}
|
||||||
|
if (bigYb > 11) {
|
||||||
|
bigYb = 11;
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=bigYt; a<=bigYb; a++)
|
for (int a = bigYt; a <= bigYb; a++) {
|
||||||
for (int b=bigXl; b<=bigXr; b++)
|
for (int b = bigXl; b <= bigXr; b++) {
|
||||||
{
|
if (level.materials.elementAt(room.RoomArray[a][b]) instanceof ChipTrash) {
|
||||||
if (level.materials.elementAt(room.RoomArray[a][b]) instanceof ChipTrash)
|
|
||||||
{
|
|
||||||
SetRoom(null);
|
SetRoom(null);
|
||||||
level.items.removeElement(this);
|
level.items.removeElement(this);
|
||||||
level.PlaySound(room, level.DISCHARGESOUND);
|
level.PlaySound(room, level.DISCHARGESOUND);
|
||||||
@@ -211,66 +200,64 @@ public void IsDropped()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
// Transfer values between the ports and the portdevices.
|
||||||
// Transfer values bewteen the ports and the portdevices.
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (int a = 0; a<16; a++)
|
for (int a = 0; a < 16; a++) {
|
||||||
{
|
|
||||||
Port outer = ports[a];
|
Port outer = ports[a];
|
||||||
Port inner = portdevices[a].ports[0];
|
Port inner = portdevices[a].ports[0];
|
||||||
|
|
||||||
if (outer.type == Port.TYPE_INPUT)
|
if (outer.type == Port.TYPE_INPUT) {
|
||||||
if (outer.value != inner.value)
|
if (outer.value != inner.value) {
|
||||||
{
|
|
||||||
changed = true;
|
changed = true;
|
||||||
inner.value = outer.value;
|
inner.value = outer.value;
|
||||||
}
|
}
|
||||||
if (outer.type == Port.TYPE_OUTPUT)
|
}
|
||||||
if (outer.value != inner.value)
|
if (outer.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
if (outer.value != inner.value) {
|
||||||
changed = true;
|
changed = true;
|
||||||
outer.value = inner.value;
|
outer.value = inner.value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (outer.myWire==null && inner.myWire==null)
|
if (outer.myWire == null && inner.myWire == null) {
|
||||||
{
|
|
||||||
outer.type = Port.TYPE_UNDEFINED;
|
outer.type = Port.TYPE_UNDEFINED;
|
||||||
inner.type = Port.TYPE_UNDEFINED;
|
inner.type = Port.TYPE_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outer.type == Port.TYPE_UNDEFINED)
|
if (outer.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
if (inner.myWire != null) {
|
||||||
if (inner.myWire != null)
|
if (inner.type == Port.TYPE_INPUT) {
|
||||||
{
|
|
||||||
if (inner.type == Port.TYPE_INPUT)
|
|
||||||
outer.type = Port.TYPE_OUTPUT;
|
outer.type = Port.TYPE_OUTPUT;
|
||||||
else if (inner.type == Port.TYPE_OUTPUT)
|
}
|
||||||
|
else if (inner.type == Port.TYPE_OUTPUT) {
|
||||||
outer.type = Port.TYPE_INPUT;
|
outer.type = Port.TYPE_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inner.type == Port.TYPE_UNDEFINED)
|
}
|
||||||
{
|
if (inner.type == Port.TYPE_UNDEFINED) {
|
||||||
if (outer.myWire != null)
|
if (outer.myWire != null) {
|
||||||
{
|
if (outer.type == Port.TYPE_INPUT) {
|
||||||
if (outer.type == Port.TYPE_INPUT)
|
|
||||||
inner.type = Port.TYPE_OUTPUT;
|
inner.type = Port.TYPE_OUTPUT;
|
||||||
else if (outer.type == Port.TYPE_OUTPUT)
|
}
|
||||||
|
else if (outer.type == Port.TYPE_OUTPUT) {
|
||||||
inner.type = Port.TYPE_INPUT;
|
inner.type = Port.TYPE_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
for (int a=0; a<portdevices.length; a++)
|
for (int a = 0; a < portdevices.length; a++) {
|
||||||
portdevices[a] = null;
|
portdevices[a] = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,33 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
import com.droidquest.Room;
|
||||||
import java.awt.Font;
|
import com.droidquest.chipstuff.Port;
|
||||||
import java.awt.FontMetrics;
|
import com.droidquest.items.Item;
|
||||||
import java.awt.Graphics2D;
|
import com.droidquest.levels.Level;
|
||||||
|
import com.droidquest.materials.ChipTrash;
|
||||||
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
public class Prototype32Chip extends GenericChip {
|
||||||
|
private transient PortDevice[] portdevices;
|
||||||
|
|
||||||
import com.droidquest.Room;
|
public Prototype32Chip(int X, int Y, Room r) {
|
||||||
import com.droidquest.chipstuff.Port;
|
x = X;
|
||||||
import com.droidquest.items.Item;
|
y = Y;
|
||||||
import com.droidquest.materials.ChipTrash;
|
room = r;
|
||||||
import com.droidquest.materials.Material;
|
width = 80;
|
||||||
|
height = 80;
|
||||||
public class Prototype32Chip extends GenericChip
|
|
||||||
{
|
|
||||||
transient PortDevice portdevices[];
|
|
||||||
|
|
||||||
public Prototype32Chip(int X, int Y, Room r)
|
|
||||||
{
|
|
||||||
x=X; y=Y; room =r;
|
|
||||||
width=80; height=80;
|
|
||||||
|
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// g = icons[0].getImage().getGraphics();
|
|
||||||
// }
|
|
||||||
// catch (NullPointerException e)
|
|
||||||
// {
|
|
||||||
// System.out.println("Could not get Graphics pointer to PrototypeChip Image");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
InternalRoom = new Room();
|
InternalRoom = new Room();
|
||||||
int[][] table = {
|
InternalRoom.RoomArray = new int[][]{
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
@@ -52,13 +41,16 @@ public Prototype32Chip(int X, int Y, Room r)
|
|||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||||
};
|
};
|
||||||
InternalRoom.RoomArray = table;
|
|
||||||
Material mat1 = new Material(Color.blue, false, true);
|
Material mat1 = new Material(Color.blue, false, true);
|
||||||
level.materials.addElement(mat1);
|
level.materials.addElement(mat1);
|
||||||
int mat1Index = level.materials.size() - 1;
|
int mat1Index = level.materials.size() - 1;
|
||||||
for (int rY=0; rY<12; rY++)
|
for (int rY = 0; rY < 12; rY++) {
|
||||||
for (int rX=0; rX<20; rX++)
|
for (int rX = 0; rX < 20; rX++) {
|
||||||
if (InternalRoom.RoomArray[rY][rX]==1) InternalRoom.RoomArray[rY][rX] = mat1Index;
|
if (InternalRoom.RoomArray[rY][rX] == 1) {
|
||||||
|
InternalRoom.RoomArray[rY][rX] = mat1Index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
InternalRoom.GenerateArray();
|
InternalRoom.GenerateArray();
|
||||||
InternalRoom.portalItem = this;
|
InternalRoom.portalItem = this;
|
||||||
level.rooms.addElement(InternalRoom);
|
level.rooms.addElement(InternalRoom);
|
||||||
@@ -100,23 +92,20 @@ public Prototype32Chip(int X, int Y, Room r)
|
|||||||
portdevices[30] = new PortDevice(5 * 28, 12, InternalRoom, 28, Port.TYPE_UNDEFINED);
|
portdevices[30] = new PortDevice(5 * 28, 12, InternalRoom, 28, Port.TYPE_UNDEFINED);
|
||||||
portdevices[31] = new PortDevice(3 * 28, 12, InternalRoom, 28, Port.TYPE_UNDEFINED);
|
portdevices[31] = new PortDevice(3 * 28, 12, InternalRoom, 28, Port.TYPE_UNDEFINED);
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
portdevices[a].rotate(1);
|
portdevices[a].rotate(1);
|
||||||
portdevices[a + 16].rotate(-1);
|
portdevices[a + 16].rotate(-1);
|
||||||
portdevices[a + 24].rotate(1);
|
portdevices[a + 24].rotate(1);
|
||||||
portdevices[a + 24].rotate(1);
|
portdevices[a + 24].rotate(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<32; a++)
|
for (int a = 0; a < 32; a++) {
|
||||||
level.items.addElement(portdevices[a]);
|
level.items.addElement(portdevices[a]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
if (ports == null) {
|
||||||
// super.GenerateIcons();
|
|
||||||
if (ports==null)
|
|
||||||
{
|
|
||||||
ports = new Port[32];
|
ports = new Port[32];
|
||||||
ports[0] = new Port(1, 8, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
ports[0] = new Port(1, 8, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
||||||
ports[1] = new Port(1, 16, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
ports[1] = new Port(1, 16, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
||||||
@@ -156,12 +145,10 @@ public void GenerateIcons()
|
|||||||
}
|
}
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -208,8 +195,7 @@ public void GenerateIcons()
|
|||||||
g.fillRect(7, 1, 2, 2);
|
g.fillRect(7, 1, 2, 2);
|
||||||
|
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
if (label != null)
|
if (label != null) {
|
||||||
{
|
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
Font font = new Font("Courier", Font.BOLD, 20);
|
Font font = new Font("Courier", Font.BOLD, 20);
|
||||||
g.setFont(font);
|
g.setFont(font);
|
||||||
@@ -220,84 +206,78 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{}
|
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
|
||||||
{
|
|
||||||
super.writeRef(s);
|
|
||||||
for (int a=0; a<32; a++)
|
|
||||||
s.writeInt(level.items.indexOf(portdevices[a]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
super.writeRef(s);
|
||||||
|
for (int a = 0; a < 32; a++) {
|
||||||
|
s.writeInt(level.items.indexOf(portdevices[a]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
portdevices = new PortDevice[32];
|
portdevices = new PortDevice[32];
|
||||||
for (int a=0; a<ports.length; a++)
|
for (int a = 0; a < ports.length; a++) {
|
||||||
{
|
|
||||||
Item item = level.FindItem(s.readInt());
|
Item item = level.FindItem(s.readInt());
|
||||||
portdevices[a] = (PortDevice) item;
|
portdevices[a] = (PortDevice) item;
|
||||||
}
|
}
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
// Transfer values bewteen the ports and the portdevices.
|
// Transfer values bewteen the ports and the portdevices.
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (int a = 0; a<32; a++)
|
for (int a = 0; a < 32; a++) {
|
||||||
{
|
|
||||||
Port outer = ports[a];
|
Port outer = ports[a];
|
||||||
Port inner = portdevices[a].ports[0];
|
Port inner = portdevices[a].ports[0];
|
||||||
|
|
||||||
if (outer.type == Port.TYPE_INPUT)
|
if (outer.type == Port.TYPE_INPUT) {
|
||||||
if (outer.value != inner.value)
|
if (outer.value != inner.value) {
|
||||||
{
|
|
||||||
changed = true;
|
changed = true;
|
||||||
inner.value = outer.value;
|
inner.value = outer.value;
|
||||||
}
|
}
|
||||||
if (outer.type == Port.TYPE_OUTPUT)
|
}
|
||||||
if (outer.value != inner.value)
|
if (outer.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
if (outer.value != inner.value) {
|
||||||
changed = true;
|
changed = true;
|
||||||
outer.value = inner.value;
|
outer.value = inner.value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (outer.myWire==null && inner.myWire==null)
|
if (outer.myWire == null && inner.myWire == null) {
|
||||||
{
|
|
||||||
outer.type = Port.TYPE_UNDEFINED;
|
outer.type = Port.TYPE_UNDEFINED;
|
||||||
inner.type = Port.TYPE_UNDEFINED;
|
inner.type = Port.TYPE_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outer.type == Port.TYPE_UNDEFINED)
|
if (outer.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
if (inner.myWire != null) {
|
||||||
if (inner.myWire != null)
|
if (inner.type == Port.TYPE_INPUT) {
|
||||||
{
|
|
||||||
if (inner.type == Port.TYPE_INPUT)
|
|
||||||
outer.type = Port.TYPE_OUTPUT;
|
outer.type = Port.TYPE_OUTPUT;
|
||||||
else if (inner.type == Port.TYPE_OUTPUT)
|
}
|
||||||
|
else if (inner.type == Port.TYPE_OUTPUT) {
|
||||||
outer.type = Port.TYPE_INPUT;
|
outer.type = Port.TYPE_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inner.type == Port.TYPE_UNDEFINED)
|
}
|
||||||
{
|
if (inner.type == Port.TYPE_UNDEFINED) {
|
||||||
if (outer.myWire != null)
|
if (outer.myWire != null) {
|
||||||
{
|
if (outer.type == Port.TYPE_INPUT) {
|
||||||
if (outer.type == Port.TYPE_INPUT)
|
|
||||||
inner.type = Port.TYPE_OUTPUT;
|
inner.type = Port.TYPE_OUTPUT;
|
||||||
else if (outer.type == Port.TYPE_OUTPUT)
|
}
|
||||||
|
else if (outer.type == Port.TYPE_OUTPUT) {
|
||||||
inner.type = Port.TYPE_INPUT;
|
inner.type = Port.TYPE_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
|
||||||
inBurner = false;
|
inBurner = false;
|
||||||
inTester = false;
|
inTester = false;
|
||||||
int bigXl = (x) / 28;
|
int bigXl = (x) / 28;
|
||||||
@@ -305,27 +285,30 @@ public void IsDropped()
|
|||||||
int bigYt = (y) / 32;
|
int bigYt = (y) / 32;
|
||||||
int bigYb = (y + height - 1) / 32;
|
int bigYb = (y + height - 1) / 32;
|
||||||
|
|
||||||
if (bigXr>19) bigXr=19;
|
if (bigXr > 19) {
|
||||||
if (bigYb>11) bigYb=11;
|
bigXr = 19;
|
||||||
|
}
|
||||||
|
if (bigYb > 11) {
|
||||||
|
bigYb = 11;
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=bigYt; a<=bigYb; a++)
|
for (int a = bigYt; a <= bigYb; a++) {
|
||||||
for (int b=bigXl; b<=bigXr; b++)
|
for (int b = bigXl; b <= bigXr; b++) {
|
||||||
{
|
if (level.materials.elementAt(room.RoomArray[a][b]) instanceof ChipTrash) {
|
||||||
if (level.materials.elementAt(room.RoomArray[a][b]) instanceof ChipTrash)
|
|
||||||
{
|
|
||||||
SetRoom(null);
|
SetRoom(null);
|
||||||
level.items.removeElement(this);
|
level.items.removeElement(this);
|
||||||
level.PlaySound(room,level.DISCHARGESOUND);
|
level.PlaySound(room, Level.DISCHARGESOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
for (int a=0; a<portdevices.length; a++)
|
for (int a = 0; a < portdevices.length; a++) {
|
||||||
portdevices[a] = null;
|
portdevices[a] = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +1,32 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
import com.droidquest.Room;
|
||||||
import java.awt.Font;
|
import com.droidquest.chipstuff.Port;
|
||||||
import java.awt.FontMetrics;
|
import com.droidquest.items.Item;
|
||||||
import java.awt.Graphics2D;
|
import com.droidquest.levels.Level;
|
||||||
import java.awt.Rectangle;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
public class PrototypeChip extends GenericChip {
|
||||||
|
|
||||||
import com.droidquest.Room;
|
|
||||||
import com.droidquest.chipstuff.Port;
|
|
||||||
import com.droidquest.items.Item;
|
|
||||||
import com.droidquest.materials.Material;
|
|
||||||
|
|
||||||
public class PrototypeChip extends GenericChip
|
|
||||||
{
|
|
||||||
public transient PortDevice portdevices[];
|
public transient PortDevice portdevices[];
|
||||||
|
|
||||||
public PrototypeChip(int X, int Y, Room r)
|
public PrototypeChip(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room =r;
|
y = Y;
|
||||||
width=104; height=64;
|
room = r;
|
||||||
|
width = 104;
|
||||||
|
height = 64;
|
||||||
|
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// g = icons[0].getImage().getGraphics();
|
|
||||||
// }
|
|
||||||
// catch (NullPointerException e)
|
|
||||||
// {
|
|
||||||
// System.out.println("Could not get Graphics pointer to PrototypeChip Image");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
InternalRoom = new Room();
|
InternalRoom = new Room();
|
||||||
int[][] table = {
|
InternalRoom.RoomArray = new int[][]{
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
@@ -52,13 +40,16 @@ public PrototypeChip(int X, int Y, Room r)
|
|||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}
|
{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||||
};
|
};
|
||||||
InternalRoom.RoomArray = table;
|
|
||||||
Material mat1 = new Material(Color.blue, false, true);
|
Material mat1 = new Material(Color.blue, false, true);
|
||||||
level.materials.addElement(mat1);
|
level.materials.addElement(mat1);
|
||||||
int mat1Index = level.materials.size() - 1;
|
int mat1Index = level.materials.size() - 1;
|
||||||
for (int rY=0; rY<12; rY++)
|
for (int rY = 0; rY < 12; rY++) {
|
||||||
for (int rX=0; rX<20; rX++)
|
for (int rX = 0; rX < 20; rX++) {
|
||||||
if (InternalRoom.RoomArray[rY][rX]==1) InternalRoom.RoomArray[rY][rX] = mat1Index;
|
if (InternalRoom.RoomArray[rY][rX] == 1) {
|
||||||
|
InternalRoom.RoomArray[rY][rX] = mat1Index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
InternalRoom.GenerateArray();
|
InternalRoom.GenerateArray();
|
||||||
InternalRoom.portalItem = this;
|
InternalRoom.portalItem = this;
|
||||||
level.rooms.addElement(InternalRoom);
|
level.rooms.addElement(InternalRoom);
|
||||||
@@ -89,15 +80,14 @@ public PrototypeChip(int X, int Y, Room r)
|
|||||||
portdevices[6].rotate(-1);
|
portdevices[6].rotate(-1);
|
||||||
portdevices[7].rotate(-1);
|
portdevices[7].rotate(-1);
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
level.items.addElement(portdevices[a]);
|
level.items.addElement(portdevices[a]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
// super.GenerateIcons();
|
// super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[8];
|
ports = new Port[8];
|
||||||
ports[0] = new Port(12, 9, Port.TYPE_UNDEFINED, 16, Port.ROT_LEFT, this);
|
ports[0] = new Port(12, 9, Port.TYPE_UNDEFINED, 16, Port.ROT_LEFT, this);
|
||||||
ports[1] = new Port(4, 25, Port.TYPE_UNDEFINED, 24, Port.ROT_LEFT, this);
|
ports[1] = new Port(4, 25, Port.TYPE_UNDEFINED, 24, Port.ROT_LEFT, this);
|
||||||
@@ -110,12 +100,10 @@ public void GenerateIcons()
|
|||||||
}
|
}
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -126,8 +114,7 @@ public void GenerateIcons()
|
|||||||
g.fillRect(24, 0, 56, 64);
|
g.fillRect(24, 0, 56, 64);
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
g.fillRect(26, 6, 4, 4);
|
g.fillRect(26, 6, 4, 4);
|
||||||
if (label != null)
|
if (label != null) {
|
||||||
{
|
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
Font font = new Font("Courier", Font.BOLD, 20);
|
Font font = new Font("Courier", Font.BOLD, 20);
|
||||||
g.setFont(font);
|
g.setFont(font);
|
||||||
@@ -138,28 +125,25 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
g = currentIcon.getGraphics();
|
g = currentIcon.getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].Draw(g, rotation);
|
port.Draw(g, rotation);
|
||||||
|
}
|
||||||
g.setColor(Color.blue);
|
g.setColor(Color.blue);
|
||||||
g.fillRect(24, 0, 56, 64);
|
g.fillRect(24, 0, 56, 64);
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
g.fillRect(26, 6, 4, 4);
|
g.fillRect(26, 6, 4, 4);
|
||||||
if (label != null)
|
if (label != null) {
|
||||||
{
|
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
Font font = new Font("Courier", Font.BOLD, 20);
|
Font font = new Font("Courier", Font.BOLD, 20);
|
||||||
g.setFont(font);
|
g.setFont(font);
|
||||||
@@ -169,84 +153,78 @@ public void Animate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{}
|
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
|
||||||
{
|
|
||||||
super.writeRef(s);
|
|
||||||
for (int a=0; a<8; a++)
|
|
||||||
s.writeInt(level.items.indexOf(portdevices[a]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
super.writeRef(s);
|
||||||
|
for (int a = 0; a < 8; a++) {
|
||||||
|
s.writeInt(level.items.indexOf(portdevices[a]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
portdevices = new PortDevice[8];
|
portdevices = new PortDevice[8];
|
||||||
for (int a=0; a<ports.length; a++)
|
for (int a = 0; a < ports.length; a++) {
|
||||||
{
|
|
||||||
Item item = level.FindItem(s.readInt());
|
Item item = level.FindItem(s.readInt());
|
||||||
portdevices[a] = (PortDevice) item;
|
portdevices[a] = (PortDevice) item;
|
||||||
}
|
}
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
// Transfer values bewteen the ports and the portdevices.
|
// Transfer values bewteen the ports and the portdevices.
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (int a = 0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
Port outer = ports[a];
|
Port outer = ports[a];
|
||||||
Port inner = portdevices[a].ports[0];
|
Port inner = portdevices[a].ports[0];
|
||||||
|
|
||||||
if (outer.type == Port.TYPE_INPUT)
|
if (outer.type == Port.TYPE_INPUT) {
|
||||||
if (outer.value != inner.value)
|
if (outer.value != inner.value) {
|
||||||
{
|
|
||||||
changed = true;
|
changed = true;
|
||||||
inner.value = outer.value;
|
inner.value = outer.value;
|
||||||
}
|
}
|
||||||
if (outer.type == Port.TYPE_OUTPUT)
|
}
|
||||||
if (outer.value != inner.value)
|
if (outer.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
if (outer.value != inner.value) {
|
||||||
changed = true;
|
changed = true;
|
||||||
outer.value = inner.value;
|
outer.value = inner.value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (outer.myWire==null && inner.myWire==null)
|
if (outer.myWire == null && inner.myWire == null) {
|
||||||
{
|
|
||||||
outer.type = Port.TYPE_UNDEFINED;
|
outer.type = Port.TYPE_UNDEFINED;
|
||||||
inner.type = Port.TYPE_UNDEFINED;
|
inner.type = Port.TYPE_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outer.type == Port.TYPE_UNDEFINED)
|
if (outer.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
if (inner.myWire != null) {
|
||||||
if (inner.myWire != null)
|
if (inner.type == Port.TYPE_INPUT) {
|
||||||
{
|
|
||||||
if (inner.type == Port.TYPE_INPUT)
|
|
||||||
outer.type = Port.TYPE_OUTPUT;
|
outer.type = Port.TYPE_OUTPUT;
|
||||||
else if (inner.type == Port.TYPE_OUTPUT)
|
}
|
||||||
|
else if (inner.type == Port.TYPE_OUTPUT) {
|
||||||
outer.type = Port.TYPE_INPUT;
|
outer.type = Port.TYPE_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inner.type == Port.TYPE_UNDEFINED)
|
}
|
||||||
{
|
if (inner.type == Port.TYPE_UNDEFINED) {
|
||||||
if (outer.myWire != null)
|
if (outer.myWire != null) {
|
||||||
{
|
if (outer.type == Port.TYPE_INPUT) {
|
||||||
if (outer.type == Port.TYPE_INPUT)
|
|
||||||
inner.type = Port.TYPE_OUTPUT;
|
inner.type = Port.TYPE_OUTPUT;
|
||||||
else if (outer.type == Port.TYPE_OUTPUT)
|
}
|
||||||
|
else if (outer.type == Port.TYPE_OUTPUT) {
|
||||||
inner.type = Port.TYPE_INPUT;
|
inner.type = Port.TYPE_INPUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
|
||||||
inBurner = false;
|
inBurner = false;
|
||||||
inTester = false;
|
inTester = false;
|
||||||
int bigXl = (x) / 28;
|
int bigXl = (x) / 28;
|
||||||
@@ -254,39 +232,42 @@ public void IsDropped()
|
|||||||
int bigYt = (y) / 32;
|
int bigYt = (y) / 32;
|
||||||
int bigYb = (y + height - 1) / 32;
|
int bigYb = (y + height - 1) / 32;
|
||||||
|
|
||||||
if (bigXr>19) bigXr=19;
|
if (bigXr > 19) {
|
||||||
if (bigYb>11) bigYb=11;
|
bigXr = 19;
|
||||||
|
}
|
||||||
|
if (bigYb > 11) {
|
||||||
|
bigYb = 11;
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=bigYt; a<=bigYb; a++)
|
for (int a = bigYt; a <= bigYb; a++) {
|
||||||
for (int b=bigXl; b<=bigXr; b++)
|
for (int b = bigXl; b <= bigXr; b++) {
|
||||||
{
|
if (level.materials.elementAt(room.RoomArray[a][b]).getClass().toString().endsWith("PrototypeBurner")) {
|
||||||
if (level.materials.elementAt(room.RoomArray[a][b]).getClass().toString().endsWith("PrototypeBurner"))
|
a = bigYb;
|
||||||
{
|
b = bigXr;
|
||||||
a=bigYb; b=bigXr;
|
|
||||||
x = 3 * 28 + 4;
|
x = 3 * 28 + 4;
|
||||||
y = 5 * 32 + 12;
|
y = 5 * 32 + 12;
|
||||||
inBurner = true;
|
inBurner = true;
|
||||||
}
|
}
|
||||||
if (level.materials.elementAt(room.RoomArray[a][b]).getClass().toString().endsWith("ChipTrash"))
|
if (level.materials.elementAt(room.RoomArray[a][b]).getClass().toString().endsWith("ChipTrash")) {
|
||||||
{
|
|
||||||
level.items.removeElement(this);
|
level.items.removeElement(this);
|
||||||
level.PlaySound(room,level.DISCHARGESOUND);
|
level.PlaySound(room, Level.DISCHARGESOUND);
|
||||||
}
|
}
|
||||||
if (level.materials.elementAt(room.RoomArray[a][b]).getClass().toString().endsWith("ChipTester"))
|
if (level.materials.elementAt(room.RoomArray[a][b]).getClass().toString().endsWith("ChipTester")) {
|
||||||
{
|
a = bigYb;
|
||||||
a=bigYb; b=bigXr;
|
b = bigXr;
|
||||||
x = 10 * 28 - width / 2;
|
x = 10 * 28 - width / 2;
|
||||||
y = 5 * 32 - height / 2;
|
y = 5 * 32 - height / 2;
|
||||||
inTester = true;
|
inTester = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
for (int a=0; a<portdevices.length; a++)
|
for (int a = 0; a < portdevices.length; a++) {
|
||||||
portdevices[a] = null;
|
portdevices[a] = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,16 +10,16 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.items.Item;
|
import com.droidquest.items.Item;
|
||||||
|
|
||||||
public class RoomSensor extends Device
|
public class RoomSensor extends Device {
|
||||||
{
|
private String targetClass;
|
||||||
String targetClass;
|
private Item target;
|
||||||
Item target;
|
private Dimension d1 = new Dimension(); // Output pointing Right, Left
|
||||||
Dimension d1 = new Dimension(); // Output pointing Right, Left
|
private Dimension d2 = new Dimension(); // Output pointing Up, Down
|
||||||
Dimension d2 = new Dimension(); // Output pointing Up, Down
|
|
||||||
|
|
||||||
public RoomSensor(int X, int Y, Room r, Item item)
|
public RoomSensor(int X, int Y, Room r, Item item) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room = r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
target = item;
|
target = item;
|
||||||
editable = true;
|
editable = true;
|
||||||
targetClass = target.getClass().toString().substring(6); // Removes "class "
|
targetClass = target.getClass().toString().substring(6); // Removes "class "
|
||||||
@@ -36,26 +36,23 @@ public RoomSensor(int X, int Y, Room r, Item item)
|
|||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
if (ports == null) {
|
||||||
if (ports==null)
|
|
||||||
{
|
|
||||||
ports = new Port[1];
|
ports = new Port[1];
|
||||||
ports[0] = new Port(width - 2, height / 2, Port.TYPE_OUTPUT, 24, Port.ROT_UP, this);
|
ports[0] = new Port(width - 2, height / 2, Port.TYPE_OUTPUT, 24, Port.ROT_UP, this);
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(d2.width, d2.height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(d2.width, d2.height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(d1.width, d1.height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(d1.width, d1.height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -63,47 +60,39 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
ports[0].value = false;
|
ports[0].value = false;
|
||||||
if (room.portalItem == null)
|
if (room.portalItem == null) {
|
||||||
{
|
|
||||||
// Room Sensor is not inside robot.
|
// Room Sensor is not inside robot.
|
||||||
for (int a=0;a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.room == room && item.carriedBy == null) {
|
||||||
if (item.room==room && item.carriedBy==null)
|
if (target.getClass().isInstance(item)) {
|
||||||
// if (item.getClass().toString().endsWith(targetClass))
|
|
||||||
if (target.getClass().isInstance(item))
|
|
||||||
{
|
|
||||||
ports[0].value = true;
|
ports[0].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
// Room Sensor is inside Robot.
|
// Room Sensor is inside Robot.
|
||||||
for (int a=0;a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.room == room.portalItem.room && item.carriedBy == null) {
|
||||||
if (item.room == room.portalItem.room && item.carriedBy==null)
|
if (target.getClass().isInstance(item)) {
|
||||||
if (target.getClass().isInstance(item))
|
|
||||||
{
|
|
||||||
ports[0].value = true;
|
ports[0].value = true;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
switch (rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
g.drawRect(0, 24, width, height - 24);
|
g.drawRect(0, 24, width, height - 24);
|
||||||
g.drawRect(1, 25, width - 2, height - 26);
|
g.drawRect(1, 25, width - 2, height - 26);
|
||||||
@@ -127,27 +116,27 @@ public void Decorate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotate(int dir)
|
public void rotate(int dir) {
|
||||||
{
|
if (rotation == 0 && dir == -1) {
|
||||||
if (rotation ==0 && dir == -1)
|
|
||||||
rotation = 3;
|
rotation = 3;
|
||||||
else if (rotation == 3 && dir == 1)
|
}
|
||||||
|
else if (rotation == 3 && dir == 1) {
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
rotation += dir;
|
rotation += dir;
|
||||||
|
}
|
||||||
|
|
||||||
if (rotation % 2 == 0) // if rotation == Up or Down
|
if (rotation % 2 == 0) // if rotation == Up or Down
|
||||||
{
|
{
|
||||||
width = d2.width;
|
width = d2.width;
|
||||||
height = d2.height;
|
height = d2.height;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
width = d1.width;
|
width = d1.width;
|
||||||
height = d1.height;
|
height = d1.height;
|
||||||
}
|
}
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
ports[0].x = width / 2 - 2;
|
ports[0].x = width / 2 - 2;
|
||||||
ports[0].y = 0;
|
ports[0].y = 0;
|
||||||
@@ -167,8 +156,7 @@ public void rotate(int dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +1,43 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.FontMetrics;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.Wire;
|
import com.droidquest.Wire;
|
||||||
import com.droidquest.chipstuff.ChipCompiler;
|
import com.droidquest.chipstuff.*;
|
||||||
import com.droidquest.chipstuff.Gate;
|
|
||||||
import com.droidquest.chipstuff.Port;
|
|
||||||
import com.droidquest.chipstuff.PortSignal;
|
|
||||||
import com.droidquest.chipstuff.Signal;
|
|
||||||
import com.droidquest.decorations.TextBox;
|
import com.droidquest.decorations.TextBox;
|
||||||
|
import com.droidquest.levels.Level;
|
||||||
import com.droidquest.materials.ChipTester;
|
import com.droidquest.materials.ChipTester;
|
||||||
import com.droidquest.materials.ChipTrash;
|
import com.droidquest.materials.ChipTrash;
|
||||||
import com.droidquest.materials.SmallChipBurner;
|
import com.droidquest.materials.SmallChipBurner;
|
||||||
|
|
||||||
public class SmallChip extends GenericChip
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class SmallChip extends GenericChip {
|
||||||
public int speed;
|
public int speed;
|
||||||
|
|
||||||
public transient PortSignal[] portSignals = new PortSignal[8];
|
public transient PortSignal[] portSignals = new PortSignal[8];
|
||||||
public Vector signals = new Vector();
|
public Vector<Signal> signals = new Vector<Signal>();
|
||||||
public Vector gates = new Vector();
|
public Vector<Gate> gates = new Vector<Gate>();
|
||||||
|
|
||||||
public SmallChip(int X, int Y, Room r, String l)
|
public SmallChip(int X, int Y, Room r, String l) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
label = l;
|
label = l;
|
||||||
width=26; height=30;
|
width = 26;
|
||||||
|
height = 30;
|
||||||
speed = 1;
|
speed = 1;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
portSignals[a] = new PortSignal();
|
portSignals[a] = new PortSignal();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
if (ports == null) {
|
||||||
if (ports==null)
|
|
||||||
{
|
|
||||||
ports = new Port[8];
|
ports = new Port[8];
|
||||||
ports[0] = new Port(0, 3, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
ports[0] = new Port(0, 3, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
||||||
ports[1] = new Port(0, 11, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
ports[1] = new Port(0, 11, Port.TYPE_UNDEFINED, 0, Port.ROT_LEFT, this);
|
||||||
@@ -63,21 +50,19 @@ public void GenerateIcons()
|
|||||||
}
|
}
|
||||||
ChipText chiptext = new ChipText(this);
|
ChipText chiptext = new ChipText(this);
|
||||||
chiptext.setTitle("Pinout for Chip " + label);
|
chiptext.setTitle("Pinout for Chip " + label);
|
||||||
if (portSignals == null)
|
if (portSignals == null) {
|
||||||
{
|
|
||||||
portSignals = new PortSignal[8];
|
portSignals = new PortSignal[8];
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
portSignals[a] = new PortSignal();
|
portSignals[a] = new PortSignal();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -100,19 +85,15 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.writeRef(s);
|
super.writeRef(s);
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
s.writeInt(signals.indexOf(portSignals[a].internalSignal));
|
s.writeInt(signals.indexOf(portSignals[a].internalSignal));
|
||||||
s.writeInt(portSignals[a].type);
|
s.writeInt(portSignals[a].type);
|
||||||
}
|
}
|
||||||
for (int a=0; a<gates.size(); a++)
|
for (int a = 0; a < gates.size(); a++) {
|
||||||
{
|
Gate gate = gates.elementAt(a);
|
||||||
Gate gate = (Gate) gates.elementAt(a);
|
for (int b = 0; b < 8; b++) {
|
||||||
for (int b=0; b<8; b++)
|
|
||||||
{
|
|
||||||
s.writeInt(signals.indexOf(gate.portSignals[b].externalSignal));
|
s.writeInt(signals.indexOf(gate.portSignals[b].externalSignal));
|
||||||
s.writeInt(gate.portSignals[b].type);
|
s.writeInt(gate.portSignals[b].type);
|
||||||
}
|
}
|
||||||
@@ -120,38 +101,35 @@ public void writeRef(ObjectOutputStream s) throws IOException
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
int portIndex = s.readInt();
|
int portIndex = s.readInt();
|
||||||
if (portIndex>=0)
|
if (portIndex >= 0) {
|
||||||
portSignals[a].internalSignal = (Signal) signals.elementAt(portIndex);
|
portSignals[a].internalSignal = signals.elementAt(portIndex);
|
||||||
|
}
|
||||||
portSignals[a].type = s.readInt();
|
portSignals[a].type = s.readInt();
|
||||||
}
|
}
|
||||||
for (int a=0; a<gates.size(); a++)
|
for (int a = 0; a < gates.size(); a++) {
|
||||||
{
|
Gate gate = gates.elementAt(a);
|
||||||
Gate gate = (Gate) gates.elementAt(a);
|
|
||||||
gate.portSignals = new PortSignal[8];
|
gate.portSignals = new PortSignal[8];
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
|
||||||
gate.portSignals[b] = new PortSignal();
|
gate.portSignals[b] = new PortSignal();
|
||||||
int sigIndex = s.readInt();
|
int sigIndex = s.readInt();
|
||||||
if (sigIndex>=0)
|
if (sigIndex >= 0) {
|
||||||
gate.portSignals[b].externalSignal = (Signal) signals.elementAt(sigIndex);
|
gate.portSignals[b].externalSignal = signals.elementAt(sigIndex);
|
||||||
|
}
|
||||||
gate.portSignals[b].type = s.readInt();
|
gate.portSignals[b].type = s.readInt();
|
||||||
}
|
}
|
||||||
gate.readRef(s);
|
gate.readRef(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
|
||||||
inBurner = false;
|
inBurner = false;
|
||||||
inTester = false;
|
inTester = false;
|
||||||
int bigXl = (x) / 28;
|
int bigXl = (x) / 28;
|
||||||
@@ -159,33 +137,31 @@ public void IsDropped()
|
|||||||
int bigYt = (y) / 32;
|
int bigYt = (y) / 32;
|
||||||
int bigYb = (y + height - 1) / 32;
|
int bigYb = (y + height - 1) / 32;
|
||||||
|
|
||||||
if (bigXr>19) bigXr=19;
|
if (bigXr > 19) {
|
||||||
if (bigYb>11) bigYb=11;
|
bigXr = 19;
|
||||||
|
}
|
||||||
|
if (bigYb > 11) {
|
||||||
|
bigYb = 11;
|
||||||
|
}
|
||||||
|
|
||||||
for (int a=bigYt; a<=bigYb; a++)
|
for (int a = bigYt; a <= bigYb; a++) {
|
||||||
for (int b=bigXl; b<=bigXr; b++)
|
for (int b = bigXl; b <= bigXr; b++) {
|
||||||
{
|
if (room.MaterialArray[a][b] instanceof SmallChipBurner) {
|
||||||
if (room.MaterialArray[a][b] instanceof SmallChipBurner)
|
|
||||||
{
|
|
||||||
a=bigYb; b=bigXr;
|
|
||||||
x = 13 * 28 - width / 2;
|
x = 13 * 28 - width / 2;
|
||||||
y = 8 * 32 - height / 2;
|
y = 8 * 32 - height / 2;
|
||||||
inBurner = true;
|
inBurner = true;
|
||||||
ChipCompiler.chipSpeed = speed;
|
ChipCompiler.chipSpeed = speed;
|
||||||
TextBox tb = (TextBox) room.textBoxes.elementAt(1);
|
TextBox tb = room.textBoxes.elementAt(1);
|
||||||
tb.textString = speed + "x";
|
tb.textString = speed + "x";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (room.MaterialArray[a][b] instanceof ChipTrash)
|
if (room.MaterialArray[a][b] instanceof ChipTrash) {
|
||||||
{
|
|
||||||
SetRoom(null); // Cheap way to remove the wires;
|
SetRoom(null); // Cheap way to remove the wires;
|
||||||
level.items.removeElement(this);
|
level.items.removeElement(this);
|
||||||
level.PlaySound(room,level.DISCHARGESOUND);
|
level.PlaySound(room, Level.DISCHARGESOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (room.MaterialArray[a][b] instanceof ChipTester)
|
if (room.MaterialArray[a][b] instanceof ChipTester) {
|
||||||
{
|
|
||||||
a=bigYb; b=bigXr;
|
|
||||||
x = 10 * 28 - width / 2;
|
x = 10 * 28 - width / 2;
|
||||||
y = 5 * 32 - height / 2;
|
y = 5 * 32 - height / 2;
|
||||||
inTester = true;
|
inTester = true;
|
||||||
@@ -193,74 +169,77 @@ public void IsDropped()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
for (int s=0; s<speed; s++)
|
for (int s = 0; s < speed; s++) {
|
||||||
{
|
for (a = 0; a < signals.size(); a++) {
|
||||||
for (a=0; a<signals.size(); a++)
|
signals.elementAt(a).Flip();
|
||||||
((Signal) signals.elementAt(a)).Flip();
|
}
|
||||||
|
|
||||||
for (a=0; a<8; a++)
|
for (a = 0; a < 8; a++) {
|
||||||
if (ports[a].type==Port.TYPE_INPUT)
|
if (ports[a].type == Port.TYPE_INPUT) {
|
||||||
if (portSignals[a].internalSignal != null)
|
if (portSignals[a].internalSignal != null) {
|
||||||
portSignals[a].internalSignal.Set(ports[a].value);
|
portSignals[a].internalSignal.Set(ports[a].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (a=0; a<gates.size(); a++)
|
for (a = 0; a < gates.size(); a++) {
|
||||||
((Gate) gates.elementAt(a)).Function();
|
gates.elementAt(a).Function();
|
||||||
|
}
|
||||||
|
|
||||||
for (a=0; a<8; a++)
|
for (a = 0; a < 8; a++) {
|
||||||
if (ports[a].type==Port.TYPE_OUTPUT)
|
if (ports[a].type == Port.TYPE_OUTPUT) {
|
||||||
if (portSignals[a].internalSignal != null)
|
if (portSignals[a].internalSignal != null) {
|
||||||
ports[a].value = portSignals[a].internalSignal.Get();
|
ports[a].value = portSignals[a].internalSignal.Get();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
portSignals = null;
|
portSignals = null;
|
||||||
signals = null;
|
signals = null;
|
||||||
gates = null;
|
gates = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Empty()
|
public void Empty() {
|
||||||
{
|
if (signals != null) {
|
||||||
if (signals != null)
|
|
||||||
signals.removeAllElements();
|
signals.removeAllElements();
|
||||||
signals = new Vector();
|
}
|
||||||
if (gates != null)
|
signals = new Vector<Signal>();
|
||||||
|
if (gates != null) {
|
||||||
gates.removeAllElements();
|
gates.removeAllElements();
|
||||||
gates = new Vector();
|
}
|
||||||
if (portSignals == null)
|
gates = new Vector<Gate>();
|
||||||
{
|
if (portSignals == null) {
|
||||||
portSignals = new PortSignal[8];
|
portSignals = new PortSignal[8];
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
portSignals[a] = new PortSignal();
|
portSignals[a] = new PortSignal();
|
||||||
}
|
}
|
||||||
for (int a=0; a<8; a++)
|
}
|
||||||
{
|
for (int a = 0; a < 8; a++) {
|
||||||
portSignals[a].externalSignal = null;
|
portSignals[a].externalSignal = null;
|
||||||
portSignals[a].internalSignal = null;
|
portSignals[a].internalSignal = null;
|
||||||
portSignals[a].type = Port.TYPE_UNDEFINED;
|
portSignals[a].type = Port.TYPE_UNDEFINED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadChip(String filename)
|
public void LoadChip(String filename) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
FileInputStream in = new FileInputStream(filename);
|
FileInputStream in = new FileInputStream(filename);
|
||||||
ObjectInputStream s = new ObjectInputStream(in);
|
ObjectInputStream s = new ObjectInputStream(in);
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
int numSignals = s.readInt();
|
int numSignals = s.readInt();
|
||||||
signals = new Vector();
|
signals = new Vector<Signal>();
|
||||||
for (int a=0; a<numSignals; a++)
|
for (int a = 0; a < numSignals; a++) {
|
||||||
{
|
|
||||||
Signal sig = new Signal();
|
Signal sig = new Signal();
|
||||||
sig.Set(s.readBoolean());
|
sig.Set(s.readBoolean());
|
||||||
sig.working = s.readBoolean();
|
sig.working = s.readBoolean();
|
||||||
@@ -269,29 +248,29 @@ public void LoadChip(String filename)
|
|||||||
|
|
||||||
// Gates
|
// Gates
|
||||||
int numGates = s.readInt();
|
int numGates = s.readInt();
|
||||||
gates = new Vector();
|
gates = new Vector<Gate>();
|
||||||
for (int a=0; a<numGates; a++)
|
for (int a = 0; a < numGates; a++) {
|
||||||
{
|
|
||||||
Gate gate = new Gate((String) s.readObject());
|
Gate gate = new Gate((String) s.readObject());
|
||||||
gates.addElement(gate);
|
gates.addElement(gate);
|
||||||
gate.state = s.readBoolean();
|
gate.state = s.readBoolean();
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
|
||||||
int sigIndex = s.readInt();
|
int sigIndex = s.readInt();
|
||||||
if (sigIndex>=0)
|
if (sigIndex >= 0) {
|
||||||
gate.portSignals[b].externalSignal = (Signal) signals.elementAt(sigIndex);
|
gate.portSignals[b].externalSignal = signals.elementAt(sigIndex);
|
||||||
|
}
|
||||||
gate.portSignals[b].type = s.readInt();
|
gate.portSignals[b].type = s.readInt();
|
||||||
}
|
}
|
||||||
if (gate.type.equalsIgnoreCase("Chip"))
|
if (gate.type.equalsIgnoreCase("Chip")) {
|
||||||
gate.LoadSubGate(s);
|
gate.LoadSubGate(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PortSignals
|
// PortSignals
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
int sigIndex = s.readInt();
|
int sigIndex = s.readInt();
|
||||||
if (sigIndex>=0)
|
if (sigIndex >= 0) {
|
||||||
portSignals[a].internalSignal = (Signal) signals.elementAt(sigIndex);
|
portSignals[a].internalSignal = signals.elementAt(sigIndex);
|
||||||
|
}
|
||||||
ports[a].type = s.readInt();
|
ports[a].type = s.readInt();
|
||||||
portSignals[a].type = ports[a].type;
|
portSignals[a].type = ports[a].type;
|
||||||
}
|
}
|
||||||
@@ -305,92 +284,65 @@ public void LoadChip(String filename)
|
|||||||
s.close();
|
s.close();
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException e) {}
|
catch (ClassNotFoundException e) {
|
||||||
catch (FileNotFoundException e)
|
}
|
||||||
{
|
catch (FileNotFoundException e) {
|
||||||
System.out.println("File Not Found");
|
System.out.println("File Not Found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e) {
|
||||||
{
|
|
||||||
System.out.println("IO Exception");
|
System.out.println("IO Exception");
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug report
|
for (int a = 0; a < 8; a++) {
|
||||||
// System.out.println(signals.size() + " Signals");
|
if (ports[a].myWire != null) {
|
||||||
// System.out.println(gates.size() + " Gates");
|
|
||||||
// for(int a=0; a<gates.size(); a++)
|
|
||||||
// {
|
|
||||||
// Gate gate1 = (Gate) gates.elementAt(a);
|
|
||||||
// for (int b=0; b<8; b++)
|
|
||||||
// if (gate1.portSignals[b]!=null)
|
|
||||||
// System.out.println(gate1.type
|
|
||||||
// + " gate["
|
|
||||||
// + b
|
|
||||||
// + "] = Signal "
|
|
||||||
// + signals.indexOf(gate1.portSignals[b]));
|
|
||||||
// }
|
|
||||||
// for (int a=0; a<8; a++)
|
|
||||||
// if (portSignals[a] != null)
|
|
||||||
// System.out.println("PortSignal "
|
|
||||||
// + a
|
|
||||||
// + " = Signal "
|
|
||||||
// + signals.indexOf(portSignals[a]));
|
|
||||||
//
|
|
||||||
for (int a=0; a<8; a++)
|
|
||||||
if (ports[a].myWire!=null)
|
|
||||||
{
|
|
||||||
Wire wire = ports[a].myWire;
|
Wire wire = ports[a].myWire;
|
||||||
if (wire.fromPort == ports[a])
|
if (wire.fromPort == ports[a]) {
|
||||||
{
|
if (wire.toPort.type == ports[a].type) {
|
||||||
if (wire.toPort.type == ports[a].type)
|
|
||||||
wire.Remove();
|
wire.Remove();
|
||||||
}
|
}
|
||||||
else if (wire.toPort == ports[a])
|
}
|
||||||
{
|
else if (wire.toPort == ports[a]) {
|
||||||
if (wire.fromPort.type == ports[a].type)
|
if (wire.fromPort.type == ports[a].type) {
|
||||||
wire.Remove();
|
wire.Remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveChip(String filename)
|
public void SaveChip(String filename) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream out = new FileOutputStream(filename);
|
FileOutputStream out = new FileOutputStream(filename);
|
||||||
ObjectOutputStream s = new ObjectOutputStream(out);
|
ObjectOutputStream s = new ObjectOutputStream(out);
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
s.writeInt(signals.size());
|
s.writeInt(signals.size());
|
||||||
for (int a=0; a<signals.size(); a++)
|
for (int a = 0; a < signals.size(); a++) {
|
||||||
{
|
Signal sig = signals.elementAt(a);
|
||||||
Signal sig = (Signal)signals.elementAt(a);
|
|
||||||
s.writeBoolean(sig.Get());
|
s.writeBoolean(sig.Get());
|
||||||
s.writeBoolean(sig.working);
|
s.writeBoolean(sig.working);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gates
|
// Gates
|
||||||
s.writeInt(gates.size());
|
s.writeInt(gates.size());
|
||||||
for (int a=0; a<gates.size(); a++)
|
for (int a = 0; a < gates.size(); a++) {
|
||||||
{
|
Gate gate = gates.elementAt(a);
|
||||||
Gate gate = (Gate) gates.elementAt(a);
|
|
||||||
s.writeObject(gate.type);
|
s.writeObject(gate.type);
|
||||||
s.writeBoolean(gate.state);
|
s.writeBoolean(gate.state);
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
|
||||||
s.writeInt(signals.indexOf(gate.portSignals[b].externalSignal));
|
s.writeInt(signals.indexOf(gate.portSignals[b].externalSignal));
|
||||||
s.writeInt(gate.portSignals[b].type);
|
s.writeInt(gate.portSignals[b].type);
|
||||||
}
|
}
|
||||||
if (gate.type.equalsIgnoreCase("Chip"))
|
if (gate.type.equalsIgnoreCase("Chip")) {
|
||||||
gate.SaveSubGate(s);
|
gate.SaveSubGate(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// PortSignals
|
// PortSignals
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
s.writeInt(signals.indexOf(portSignals[a].internalSignal));
|
s.writeInt(signals.indexOf(portSignals[a].internalSignal));
|
||||||
s.writeInt(ports[a].type);
|
s.writeInt(ports[a].type);
|
||||||
}
|
}
|
||||||
@@ -405,12 +357,10 @@ public void SaveChip(String filename)
|
|||||||
s.close();
|
s.close();
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e) {
|
||||||
{
|
|
||||||
System.out.println("File Not Found");
|
System.out.println("File Not Found");
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e) {
|
||||||
{
|
|
||||||
System.out.println("IO Exception");
|
System.out.println("IO Exception");
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,35 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
|
||||||
public class StormShield extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public StormShield(int X, int Y, Room r)
|
import java.awt.image.BufferedImage;
|
||||||
{
|
|
||||||
x=X; y=Y; room = r;
|
public class StormShield extends Device {
|
||||||
width=28; height=52;
|
public StormShield(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 52;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[1];
|
ports = new Port[1];
|
||||||
ports[0] = new Port(15, 49, Port.TYPE_INPUT, 22, Port.ROT_DOWN, this);
|
ports[0] = new Port(15, 49, Port.TYPE_INPUT, 22, Port.ROT_DOWN, this);
|
||||||
}
|
}
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -68,25 +62,22 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
g = currentIcon.getGraphics();
|
g = currentIcon.getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].Draw(g, rotation);
|
port.Draw(g, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotate(int dir)
|
public void rotate(int dir) {
|
||||||
{
|
|
||||||
// Does not Rotate!
|
// Does not Rotate!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,58 +1,52 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.decorations.Spark;
|
import com.droidquest.decorations.Spark;
|
||||||
import com.droidquest.items.GenericRobot;
|
import com.droidquest.items.GenericRobot;
|
||||||
|
|
||||||
public class Thruster extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public int rotation;
|
import java.awt.image.BufferedImage;
|
||||||
public Color color;
|
import java.io.IOException;
|
||||||
public transient GenericRobot robot;
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
public Thruster(int X, int Y, Room r, int direction, Color col)
|
public class Thruster extends Device {
|
||||||
{
|
private int rotation;
|
||||||
x=X; y=Y;
|
private Color color;
|
||||||
|
private transient GenericRobot robot;
|
||||||
|
|
||||||
|
public Thruster(int X, int Y, Room r, int direction, Color col) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
room = r;
|
room = r;
|
||||||
if (room.portalItem!=null)
|
if (room.portalItem != null) {
|
||||||
if (room.portalItem.getClass().toString().endsWith("Robot"))
|
if (room.portalItem.getClass().toString().endsWith("Robot")) {
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
rotation = direction;
|
rotation = direction;
|
||||||
color = col;
|
color = col;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.writeRef(s);
|
super.writeRef(s);
|
||||||
s.writeInt(level.items.indexOf(robot));
|
s.writeInt(level.items.indexOf(robot));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
robot = (GenericRobot) level.FindItem(s.readInt());
|
robot = (GenericRobot) level.FindItem(s.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
robot = (GenericRobot) room.portalItem;
|
robot = (GenericRobot) room.portalItem;
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[1];
|
ports = new Port[1];
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP: // Thrusts Up, moves Down
|
case Port.ROT_UP: // Thrusts Up, moves Down
|
||||||
ports[0] = new Port(16, 35, Port.TYPE_INPUT, 20, Port.ROT_DOWN, this);
|
ports[0] = new Port(16, 35, Port.TYPE_INPUT, 20, Port.ROT_DOWN, this);
|
||||||
break;
|
break;
|
||||||
@@ -70,52 +64,53 @@ public class Thruster extends Device
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
for (int a=0; a<ports.length; a++)
|
for (Port port : ports) {
|
||||||
ports[a].myDevice = this;
|
port.myDevice = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP: // Thrusts Up, moves Down
|
case Port.ROT_UP: // Thrusts Up, moves Down
|
||||||
width=30; height=38;
|
width = 30;
|
||||||
|
height = 38;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_RIGHT: // Thrusts Right, moves Left
|
case Port.ROT_RIGHT: // Thrusts Right, moves Left
|
||||||
width=54; height=20;
|
width = 54;
|
||||||
|
height = 20;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_DOWN: // Thrusts Down, moves Up
|
case Port.ROT_DOWN: // Thrusts Down, moves Up
|
||||||
width=30; height=32;
|
width = 30;
|
||||||
|
height = 32;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Port.ROT_LEFT: // Thrusts Left, moves Right
|
case Port.ROT_LEFT: // Thrusts Left, moves Right
|
||||||
width=52; height=20;
|
width = 52;
|
||||||
|
height = 20;
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = currentIcon.getGraphics();
|
g = currentIcon.getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
switch(rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP: // Thrusts Up, moves Down
|
case Port.ROT_UP: // Thrusts Up, moves Down
|
||||||
g.fillRect(0, 0, 30, 6);
|
g.fillRect(0, 0, 30, 6);
|
||||||
g.fillRect(4, 6, 22, 4);
|
g.fillRect(4, 6, 22, 4);
|
||||||
@@ -146,15 +141,12 @@ public class Thruster extends Device
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
boolean thrust = ports[0].value;
|
boolean thrust = ports[0].value;
|
||||||
|
|
||||||
if (robot==null && thrust)
|
if (robot == null && thrust) {
|
||||||
{
|
|
||||||
Dimension d = GetXY();
|
Dimension d = GetXY();
|
||||||
switch (rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
level.sparks.addElement(new Spark(d.width + level.random.nextInt(30),
|
level.sparks.addElement(new Spark(d.width + level.random.nextInt(30),
|
||||||
d.height + 0,
|
d.height + 0,
|
||||||
@@ -190,10 +182,11 @@ public class Thruster extends Device
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (robot==null) return false;
|
if (robot == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
switch (rotation)
|
switch (rotation) {
|
||||||
{
|
|
||||||
case Port.ROT_UP: // Thrusts Up, moves Down
|
case Port.ROT_UP: // Thrusts Up, moves Down
|
||||||
robot.topThruster = thrust;
|
robot.topThruster = thrust;
|
||||||
break;
|
break;
|
||||||
@@ -210,8 +203,7 @@ public class Thruster extends Device
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
robot = null;
|
robot = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,90 +1,88 @@
|
|||||||
package com.droidquest.devices;
|
package com.droidquest.devices;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.Wire;
|
import com.droidquest.Wire;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
|
|
||||||
public class XORGate extends Device
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
transient ImageIcon images[];
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public XORGate(int X, int Y, Room r)
|
public class XORGate extends Device {
|
||||||
{
|
private transient ImageIcon[] images;
|
||||||
x=X; y=Y; room =r;
|
|
||||||
width=28; height=50;
|
public XORGate(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 50;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to XORGate Image");
|
System.out.println("Could not get Graphics pointer to XORGate Image");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
if (ports[0].value ^ ports[1].value)
|
if (ports[0].value ^ ports[1].value) {
|
||||||
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
g.drawImage(images[4 + rotation].getImage(), 0, 0, level);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
g.drawImage(images[rotation].getImage(), 0, 0, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
super.GenerateIcons();
|
super.GenerateIcons();
|
||||||
if (ports==null)
|
if (ports == null) {
|
||||||
{
|
|
||||||
ports = new Port[3];
|
ports = new Port[3];
|
||||||
ports[0] = new Port(7, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
ports[0] = new Port(7, 47, Port.TYPE_INPUT, 12, Port.ROT_DOWN, this);
|
||||||
ports[1] = new Port(23, 43, Port.TYPE_INPUT, 8, Port.ROT_DOWN, this);
|
ports[1] = new Port(23, 43, Port.TYPE_INPUT, 8, Port.ROT_DOWN, this);
|
||||||
ports[2] = new Port(12, 2, Port.TYPE_OUTPUT, 16, Port.ROT_UP, this);
|
ports[2] = new Port(12, 2, Port.TYPE_OUTPUT, 16, Port.ROT_UP, this);
|
||||||
if (rotation > 0)
|
if (rotation > 0) {
|
||||||
{
|
|
||||||
int rot = rotation;
|
int rot = rotation;
|
||||||
if (rotation%2==1)
|
if (rotation % 2 == 1) {
|
||||||
{
|
|
||||||
int temp = width;
|
int temp = width;
|
||||||
width = height;
|
width = height;
|
||||||
height = temp;
|
height = temp;
|
||||||
}
|
}
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
for (int r=0; r<rot; r++)
|
for (int r = 0; r < rot; r++) {
|
||||||
rotate(1);
|
rotate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
goesInToolbox = true;
|
goesInToolbox = true;
|
||||||
images = new ImageIcon[8];
|
images = new ImageIcon[8];
|
||||||
int w; int h;
|
int w;
|
||||||
if (rotation%2==0)
|
int h;
|
||||||
{w=width; h=height;}
|
if (rotation % 2 == 0) {
|
||||||
else
|
w = width;
|
||||||
{w=height; h=width;}
|
h = height;
|
||||||
for (int v=0; v<2; v++)
|
}
|
||||||
for (int r=0; r<4; r++)
|
else {
|
||||||
{
|
w = height;
|
||||||
|
h = width;
|
||||||
|
}
|
||||||
|
for (int v = 0; v < 2; v++) {
|
||||||
|
for (int r = 0; r < 4; r++) {
|
||||||
int a = r + v * 4;
|
int a = r + v * 4;
|
||||||
if (r%2==0)
|
if (r % 2 == 0) {
|
||||||
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(h, w, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
try
|
}
|
||||||
{
|
try {
|
||||||
g = images[a].getImage().getGraphics();
|
g = images[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to Device Image");
|
System.out.println("Could not get Graphics pointer to Device Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -92,12 +90,13 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
if (v==0)
|
if (v == 0) {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
switch(r)
|
}
|
||||||
{
|
switch (r) {
|
||||||
case 0: // Up
|
case 0: // Up
|
||||||
g.fillRect(8, 18, 12, 2);
|
g.fillRect(8, 18, 12, 2);
|
||||||
g.fillRect(8, 18, 4, 4);
|
g.fillRect(8, 18, 4, 4);
|
||||||
@@ -150,32 +149,41 @@ public void GenerateIcons()
|
|||||||
g.fillRect(28, 8, 2, 12);
|
g.fillRect(28, 8, 2, 12);
|
||||||
g.fillRect(32, 8, 2, 12);
|
g.fillRect(32, 8, 2, 12);
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentIcon = icons[rotation % 2].getImage();
|
currentIcon = icons[rotation % 2].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Function()
|
public boolean Function() {
|
||||||
{
|
|
||||||
ports[2].value = ports[0].value ^ ports[1].value;
|
ports[2].value = ports[0].value ^ ports[1].value;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flip()
|
public void flip() {
|
||||||
{
|
|
||||||
Wire wire1 = ports[0].myWire;
|
Wire wire1 = ports[0].myWire;
|
||||||
Wire wire2 = ports[1].myWire;
|
Wire wire2 = ports[1].myWire;
|
||||||
if (wire1 != null)
|
if (wire1 != null) {
|
||||||
{
|
if (wire1.fromPort == ports[0]) {
|
||||||
if (wire1.fromPort == ports[0]) wire1.fromPort = ports[1];
|
wire1.fromPort = ports[1];
|
||||||
if (wire1.toPort == ports[0]) wire1.toPort = ports[1];
|
}
|
||||||
if (wire1.inPort == ports[0]) wire1.inPort = ports[1];
|
if (wire1.toPort == ports[0]) {
|
||||||
|
wire1.toPort = ports[1];
|
||||||
|
}
|
||||||
|
if (wire1.inPort == ports[0]) {
|
||||||
|
wire1.inPort = ports[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wire2 != null) {
|
||||||
|
if (wire2.fromPort == ports[1]) {
|
||||||
|
wire2.fromPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.toPort == ports[1]) {
|
||||||
|
wire2.toPort = ports[0];
|
||||||
|
}
|
||||||
|
if (wire2.inPort == ports[1]) {
|
||||||
|
wire2.inPort = ports[0];
|
||||||
}
|
}
|
||||||
if (wire2 != null)
|
|
||||||
{
|
|
||||||
if (wire2.fromPort == ports[1]) wire2.fromPort = ports[0];
|
|
||||||
if (wire2.toPort == ports[1]) wire2.toPort = ports[0];
|
|
||||||
if (wire2.inPort == ports[1]) wire2.inPort = ports[0];
|
|
||||||
}
|
}
|
||||||
ports[0].myWire = wire2;
|
ports[0].myWire = wire2;
|
||||||
ports[1].myWire = wire1;
|
ports[1].myWire = wire1;
|
||||||
|
|||||||
@@ -1,20 +1,15 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class AmpireBot extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
int animationState=0; // 0-4
|
import java.awt.image.BufferedImage;
|
||||||
boolean alive=true;
|
|
||||||
int behaviorState=0;
|
public class AmpireBot extends Item {
|
||||||
|
private int animationState = 0; // 0-4
|
||||||
|
private boolean alive = true;
|
||||||
|
private int behaviorState = 0;
|
||||||
// 0=Wait for Player
|
// 0=Wait for Player
|
||||||
// 1=Patrol Init
|
// 1=Patrol Init
|
||||||
// 2=Patrol Left
|
// 2=Patrol Left
|
||||||
@@ -23,20 +18,21 @@ int behaviorState=0;
|
|||||||
// 5=Patrol Down
|
// 5=Patrol Down
|
||||||
// 6=Pounce
|
// 6=Pounce
|
||||||
// 7=Drain
|
// 7=Drain
|
||||||
int previousBehavior; // Used to return from Attack
|
private int previousBehavior; // Used to return from Attack
|
||||||
Item target;
|
private Item target;
|
||||||
|
|
||||||
public AmpireBot(int X, int Y, Room r)
|
public AmpireBot(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
width=26;height=32;
|
width = 26;
|
||||||
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[6];
|
icons = new ImageIcon[6];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -49,12 +45,10 @@ public void GenerateIcons()
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// 0= blue 1
|
// 0= blue 1
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -76,12 +70,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(2, 6, 8, 2);
|
g.fillRect(2, 6, 8, 2);
|
||||||
|
|
||||||
// 1= blue 2
|
// 1= blue 2
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -104,12 +96,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(8, 6, 8, 2);
|
g.fillRect(8, 6, 8, 2);
|
||||||
|
|
||||||
// 2= blue 3
|
// 2= blue 3
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[2].getImage().getGraphics();
|
g = icons[2].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -134,12 +124,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(18, 6, 8, 2);
|
g.fillRect(18, 6, 8, 2);
|
||||||
|
|
||||||
// 3= green 1
|
// 3= green 1
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[3].getImage().getGraphics();
|
g = icons[3].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -161,12 +149,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(2, 6, 8, 2);
|
g.fillRect(2, 6, 8, 2);
|
||||||
|
|
||||||
// 4= orange 2
|
// 4= orange 2
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[4].getImage().getGraphics();
|
g = icons[4].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -189,12 +175,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(8, 6, 8, 2);
|
g.fillRect(8, 6, 8, 2);
|
||||||
|
|
||||||
// 5= green 3
|
// 5= green 3
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[5].getImage().getGraphics();
|
g = icons[5].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -218,122 +202,161 @@ public void GenerateIcons()
|
|||||||
g.setColor(Color.green);
|
g.setColor(Color.green);
|
||||||
g.fillRect(18, 6, 8, 2);
|
g.fillRect(18, 6, 8, 2);
|
||||||
|
|
||||||
if (animationState==4) animationState=0;
|
if (animationState == 4) {
|
||||||
|
animationState = 0;
|
||||||
|
}
|
||||||
int frame = animationState;
|
int frame = animationState;
|
||||||
if (animationState==3) frame=1;
|
if (animationState == 3) {
|
||||||
if (!alive) frame +=3;
|
frame = 1;
|
||||||
|
}
|
||||||
|
if (!alive) {
|
||||||
|
frame += 3;
|
||||||
|
}
|
||||||
currentIcon = icons[frame].getImage();
|
currentIcon = icons[frame].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
animationState++;
|
animationState++;
|
||||||
if (animationState==4) animationState=0;
|
if (animationState == 4) {
|
||||||
|
animationState = 0;
|
||||||
|
}
|
||||||
int frame = animationState;
|
int frame = animationState;
|
||||||
if (animationState==3) frame=1;
|
if (animationState == 3) {
|
||||||
if (!alive) frame +=3;
|
frame = 1;
|
||||||
|
}
|
||||||
|
if (!alive) {
|
||||||
|
frame += 3;
|
||||||
|
}
|
||||||
currentIcon = icons[frame].getImage();
|
currentIcon = icons[frame].getImage();
|
||||||
|
|
||||||
if (alive)
|
if (alive) {
|
||||||
{
|
if (behaviorState < 6) {
|
||||||
if (behaviorState<6)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0;a<level.items.size(); a++)
|
target = level.items.elementAt(a);
|
||||||
{
|
if (target.room == room) {
|
||||||
target = (Item) level.items.elementAt(a);
|
if (target.charge > 0) {
|
||||||
if (target.room == room)
|
|
||||||
if (target.charge>0)
|
|
||||||
{
|
|
||||||
previousBehavior = behaviorState;
|
previousBehavior = behaviorState;
|
||||||
behaviorState = 6;
|
behaviorState = 6;
|
||||||
a = level.items.size();
|
a = level.items.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (behaviorState)
|
}
|
||||||
{
|
}
|
||||||
|
switch (behaviorState) {
|
||||||
case 0:
|
case 0:
|
||||||
if (level.player.room == room) behaviorState=1;
|
if (level.player.room == room) {
|
||||||
|
behaviorState = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (y>=192)
|
if (y >= 192) {
|
||||||
behaviorState = 2;
|
behaviorState = 2;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
MoveDown( 8);
|
moveDown(8);
|
||||||
if (x<280) MoveRight(8);
|
if (x < 280) {
|
||||||
if (x>280) MoveLeft(8);
|
moveRight(8);
|
||||||
|
}
|
||||||
|
if (x > 280) {
|
||||||
|
moveLeft(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (room==(Room) level.rooms.elementAt(18) && x<=280)
|
if (room == level.rooms.elementAt(18) && x <= 280) {
|
||||||
behaviorState = 3;
|
behaviorState = 3;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
MoveLeft( 8);
|
moveLeft(8);
|
||||||
if (y<192) MoveDown(8);
|
if (y < 192) {
|
||||||
if (y>192) MoveUp(8);
|
moveDown(8);
|
||||||
|
}
|
||||||
|
if (y > 192) {
|
||||||
|
moveUp(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (room==(Room) level.rooms.elementAt(19) && y<=192)
|
if (room == level.rooms.elementAt(19) && y <= 192) {
|
||||||
behaviorState = 4;
|
behaviorState = 4;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
MoveUp( 8);
|
moveUp(8);
|
||||||
if (x<280) MoveRight(8);
|
if (x < 280) {
|
||||||
if (x>280) MoveLeft(8);
|
moveRight(8);
|
||||||
|
}
|
||||||
|
if (x > 280) {
|
||||||
|
moveLeft(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (room==(Room) level.rooms.elementAt(15) && x>=280)
|
if (room == level.rooms.elementAt(15) && x >= 280) {
|
||||||
behaviorState = 5;
|
behaviorState = 5;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
MoveRight( 8);
|
moveRight(8);
|
||||||
if (y<192) MoveDown(8);
|
if (y < 192) {
|
||||||
if (y>192) MoveUp(8);
|
moveDown(8);
|
||||||
|
}
|
||||||
|
if (y > 192) {
|
||||||
|
moveUp(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (room==(Room) level.rooms.elementAt(16) && y>=192)
|
if (room == level.rooms.elementAt(16) && y >= 192) {
|
||||||
behaviorState = 2;
|
behaviorState = 2;
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
MoveDown( 8);
|
moveDown(8);
|
||||||
if (x<280) MoveRight(8);
|
if (x < 280) {
|
||||||
if (x>280) MoveLeft(8);
|
moveRight(8);
|
||||||
|
}
|
||||||
|
if (x > 280) {
|
||||||
|
moveLeft(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (target.room != room)
|
if (target.room != room) {
|
||||||
behaviorState = previousBehavior;
|
behaviorState = previousBehavior;
|
||||||
if (Overlaps(target))
|
}
|
||||||
{
|
if (Overlaps(target)) {
|
||||||
behaviorState = 7;
|
behaviorState = 7;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Dimension d = target.GetXY();
|
Dimension d = target.GetXY();
|
||||||
if (d.width<x) MoveLeft(false);
|
if (d.width < x) {
|
||||||
if (d.width>x) MoveRight(false);
|
moveLeft(false);
|
||||||
if (d.height<y) MoveUp(false);
|
}
|
||||||
if (d.height>y) MoveDown(false);
|
if (d.width > x) {
|
||||||
|
moveRight(false);
|
||||||
|
}
|
||||||
|
if (d.height < y) {
|
||||||
|
moveUp(false);
|
||||||
|
}
|
||||||
|
if (d.height > y) {
|
||||||
|
moveDown(false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (target.room != room)
|
if (target.room != room) {
|
||||||
{
|
|
||||||
behaviorState = previousBehavior;
|
behaviorState = previousBehavior;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (target.charge>0 && Overlaps(target))
|
if (target.charge > 0 && Overlaps(target)) {
|
||||||
{
|
if (target.getClass().toString().endsWith("BlackCrystal")) {
|
||||||
if (target.getClass().toString().endsWith("BlackCrystal"))
|
|
||||||
alive = false;
|
alive = false;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
target.charge -= 3125;
|
target.charge -= 3125;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
behaviorState = 6;
|
behaviorState = 6;
|
||||||
if (target.charge <=0)
|
}
|
||||||
{
|
if (target.charge <= 0) {
|
||||||
target.charge = 0;
|
target.charge = 0;
|
||||||
behaviorState = previousBehavior;
|
behaviorState = previousBehavior;
|
||||||
}
|
}
|
||||||
@@ -342,8 +365,7 @@ public void Animate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +1,42 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.Wire;
|
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.devices.Device;
|
import com.droidquest.devices.Device;
|
||||||
import com.droidquest.devices.PortDevice;
|
import com.droidquest.devices.PortDevice;
|
||||||
import com.droidquest.devices.PrototypeChip;
|
import com.droidquest.devices.PrototypeChip;
|
||||||
import com.droidquest.devices.SmallChip;
|
import com.droidquest.devices.SmallChip;
|
||||||
|
|
||||||
public class AutoWire extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
int animation; // 0=Wait to Wire
|
import java.awt.image.BufferedImage;
|
||||||
// 1-8 = Wiring/Unwiring Port 1-8
|
|
||||||
Device chip;
|
|
||||||
PortDevice[] portdevices = new PortDevice[8];
|
|
||||||
|
|
||||||
public AutoWire(int X, int Y, Room r)
|
public class AutoWire extends Item {
|
||||||
{
|
private int animation; // 0=Wait to Wire
|
||||||
x=X; y=Y; room=r;
|
// 1-8 = Wiring/Unwiring Port 1-8
|
||||||
width=28; height=30;
|
private Device chip;
|
||||||
|
private PortDevice[] portdevices = new PortDevice[8];
|
||||||
|
|
||||||
|
public AutoWire(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 30;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
Graphics2D g2;
|
|
||||||
Color transparent = new Color(0,0,0,0);
|
|
||||||
|
|
||||||
// 0 = Off
|
// 0 = Off
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,12 +50,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(8, 12, 12, 6);
|
g.fillRect(8, 12, 12, 6);
|
||||||
|
|
||||||
// 1 = On
|
// 1 = On
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,53 +70,52 @@ public void GenerateIcons()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
if (animation != 0) {
|
||||||
if (animation!=0) return false;
|
return false;
|
||||||
|
}
|
||||||
// Find the Item that has inTester set true;
|
// Find the Item that has inTester set true;
|
||||||
chip = null;
|
chip = null;
|
||||||
int pdcount = 0;
|
int pdcount = 0;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item instanceof PrototypeChip) {
|
||||||
if (item.getClass().toString().endsWith("PrototypeChip"))
|
|
||||||
{
|
|
||||||
PrototypeChip pc = (PrototypeChip) item;
|
PrototypeChip pc = (PrototypeChip) item;
|
||||||
if (pc.inTester) chip = pc;
|
if (pc.inTester) {
|
||||||
|
chip = pc;
|
||||||
}
|
}
|
||||||
if (item.getClass().toString().endsWith("SmallChip"))
|
}
|
||||||
{
|
if (item instanceof SmallChip) {
|
||||||
SmallChip sc = (SmallChip) item;
|
SmallChip sc = (SmallChip) item;
|
||||||
if (sc.inTester) chip = sc;
|
if (sc.inTester) {
|
||||||
|
chip = sc;
|
||||||
}
|
}
|
||||||
if (item.getClass().toString().endsWith("PortDevice"))
|
}
|
||||||
{
|
if (item instanceof PortDevice) {
|
||||||
if (item.room == room)
|
if (item.room == room) {
|
||||||
{
|
|
||||||
portdevices[pdcount] = (PortDevice) item;
|
portdevices[pdcount] = (PortDevice) item;
|
||||||
pdcount++;
|
pdcount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chip==null) return false;
|
if (chip == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
animation = 1;
|
animation = 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (animation == 0) {
|
||||||
if (animation==0) return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (animation==1)
|
if (animation == 1) {
|
||||||
{
|
if (portdevices[0].ports[0].myWire == null) { // Wiring
|
||||||
if (portdevices[0].ports[0].myWire==null)
|
|
||||||
{ // Wiring
|
|
||||||
portdevices[0].ports[0].type = Port.TYPE_UNDEFINED;
|
portdevices[0].ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
portdevices[0].ports[0].value = false;
|
portdevices[0].ports[0].value = false;
|
||||||
Wire wire = new Wire(portdevices[0].ports[0], chip.ports[0]);
|
|
||||||
}
|
}
|
||||||
else
|
else { // Unwiring
|
||||||
{ // Unwiring
|
|
||||||
portdevices[0].ports[0].myWire.Remove();
|
portdevices[0].ports[0].myWire.Remove();
|
||||||
portdevices[0].ports[0].type = Port.TYPE_UNDEFINED;
|
portdevices[0].ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
portdevices[0].ports[0].value = false;
|
portdevices[0].ports[0].value = false;
|
||||||
@@ -136,21 +125,15 @@ public void Animate()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animation>=2 && animation <=8)
|
if (animation >= 2 && animation <= 8) {
|
||||||
{
|
if (portdevices[0].ports[0].myWire != null) { // Wiring
|
||||||
if (portdevices[0].ports[0].myWire!=null)
|
if (portdevices[animation - 1].ports[0].myWire == null) {
|
||||||
{ // Wiring
|
|
||||||
if (portdevices[animation-1].ports[0].myWire==null)
|
|
||||||
{
|
|
||||||
portdevices[animation - 1].ports[0].type = Port.TYPE_UNDEFINED;
|
portdevices[animation - 1].ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
portdevices[animation - 1].ports[0].value = false;
|
portdevices[animation - 1].ports[0].value = false;
|
||||||
Wire wire = new Wire(portdevices[animation-1].ports[0], chip.ports[animation-1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else { // Unwiring
|
||||||
{ // Unwiring
|
if (portdevices[animation - 1].ports[0].myWire != null) {
|
||||||
if (portdevices[animation-1].ports[0].myWire!=null)
|
|
||||||
{
|
|
||||||
portdevices[animation - 1].ports[0].myWire.Remove();
|
portdevices[animation - 1].ports[0].myWire.Remove();
|
||||||
portdevices[animation - 1].ports[0].type = Port.TYPE_UNDEFINED;
|
portdevices[animation - 1].ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
portdevices[animation - 1].ports[0].value = false;
|
portdevices[animation - 1].ports[0].value = false;
|
||||||
@@ -159,16 +142,14 @@ public void Animate()
|
|||||||
animation++;
|
animation++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animation==9)
|
if (animation == 9) {
|
||||||
{
|
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
animation = 0;
|
animation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
chip = null;
|
chip = null;
|
||||||
portdevices = null;
|
portdevices = null;
|
||||||
|
|||||||
@@ -1,34 +1,29 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class BinaryKey extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public BinaryKey (int X, int Y, Room r)
|
import java.awt.image.BufferedImage;
|
||||||
{
|
|
||||||
x=X; y=Y; room=r;
|
public class BinaryKey extends Item {
|
||||||
width=26; height=28;
|
public BinaryKey(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 26;
|
||||||
|
height = 28;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,12 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class BlackCrystal extends Crystal
|
public class BlackCrystal extends Crystal {
|
||||||
{
|
public BlackCrystal(int X, int Y, Room r) {
|
||||||
public BlackCrystal(int X, int Y, Room r)
|
|
||||||
{
|
|
||||||
super(X, Y, r, 10);
|
super(X, Y, r, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
@@ -25,12 +22,10 @@ public void GenerateIcons()
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// 0 = blue
|
// 0 = blue
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -49,6 +44,7 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate() {}
|
public void Decorate() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.devices.Antenna;
|
import com.droidquest.devices.Antenna;
|
||||||
@@ -10,13 +7,13 @@ import com.droidquest.devices.Bumper;
|
|||||||
import com.droidquest.devices.Grabber;
|
import com.droidquest.devices.Grabber;
|
||||||
import com.droidquest.devices.Thruster;
|
import com.droidquest.devices.Thruster;
|
||||||
|
|
||||||
public class BlueRobot extends GenericRobot
|
import java.awt.*;
|
||||||
{
|
|
||||||
|
public class BlueRobot extends GenericRobot {
|
||||||
private int scan;
|
private int scan;
|
||||||
private int scandir;
|
private int scandir;
|
||||||
|
|
||||||
public BlueRobot(int X, int Y, Room r)
|
public BlueRobot(int X, int Y, Room r) {
|
||||||
{
|
|
||||||
super(X, Y, r, Color.blue);
|
super(X, Y, r, Color.blue);
|
||||||
scan = 0;
|
scan = 0;
|
||||||
scandir = 2;
|
scandir = 2;
|
||||||
@@ -31,29 +28,28 @@ public BlueRobot(int X, int Y, Room r)
|
|||||||
devices[7] = new Bumper(28, 134, InternalRoom, Port.ROT_LEFT, Color.white);
|
devices[7] = new Bumper(28, 134, InternalRoom, Port.ROT_LEFT, Color.white);
|
||||||
devices[8] = new Antenna(64, 70, InternalRoom, Color.white);
|
devices[8] = new Antenna(64, 70, InternalRoom, Color.white);
|
||||||
devices[9] = new Grabber(126, 44, InternalRoom, Color.white);
|
devices[9] = new Grabber(126, 44, InternalRoom, Color.white);
|
||||||
for (int a=0; a<10; a++)
|
for (int a = 0; a < 10; a++) {
|
||||||
level.items.addElement(devices[a]);
|
level.items.addElement(devices[a]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
g.fillRect(22, 44, 42, 4);
|
g.fillRect(22, 44, 42, 4);
|
||||||
|
|
||||||
if (scan+scandir>36 || scan+scandir<0)
|
if (scan + scandir > 36 || scan + scandir < 0) {
|
||||||
scandir = -scandir;
|
scandir = -scandir;
|
||||||
|
}
|
||||||
scan = scan + scandir;
|
scan = scan + scandir;
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
g.fillRect(22 + scan, 44, 6, 4);
|
g.fillRect(22 + scan, 44, 6, 4);
|
||||||
|
|||||||
@@ -2,50 +2,40 @@ package com.droidquest.items;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.Wire;
|
|
||||||
import com.droidquest.chipstuff.ChipCompiler;
|
import com.droidquest.chipstuff.ChipCompiler;
|
||||||
import com.droidquest.chipstuff.Gate;
|
|
||||||
import com.droidquest.chipstuff.Signal;
|
|
||||||
import com.droidquest.devices.Device;
|
|
||||||
import com.droidquest.devices.FlipFlop;
|
|
||||||
import com.droidquest.devices.PrototypeChip;
|
import com.droidquest.devices.PrototypeChip;
|
||||||
import com.droidquest.devices.SmallChip;
|
import com.droidquest.devices.SmallChip;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class Burner extends Item
|
public class Burner extends Item {
|
||||||
{
|
private int burning;
|
||||||
int burning;
|
private int animation;
|
||||||
int animation;
|
|
||||||
|
|
||||||
public Burner(int X, int Y, Room r)
|
public Burner(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=30;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 30;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
Graphics2D g2;
|
|
||||||
Color transparent = new Color(0,0,0,0);
|
|
||||||
|
|
||||||
// 0 = Off
|
// 0 = Off
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -59,12 +49,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(8, 12, 12, 6);
|
g.fillRect(8, 12, 12, 6);
|
||||||
|
|
||||||
// 1 = On
|
// 1 = On
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -81,30 +69,35 @@ public void GenerateIcons()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
|
||||||
// Find the SmallChip and Erase it
|
// Find the SmallChip and Erase it
|
||||||
Item sc = null;
|
Item sc = null;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.getClass().toString().endsWith("SmallChip")) {
|
||||||
if (item.getClass().toString().endsWith("SmallChip"))
|
if (((SmallChip) item).inBurner) {
|
||||||
if (((SmallChip)item).inBurner)
|
sc = item;
|
||||||
sc = (SmallChip) item;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sc == null) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (sc==null) return false;
|
|
||||||
((SmallChip) sc).Empty();
|
((SmallChip) sc).Empty();
|
||||||
|
|
||||||
// Find the PrototypeChip
|
// Find the PrototypeChip
|
||||||
Item pc = null;
|
Item pc = null;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.getClass().toString().endsWith("PrototypeChip")) {
|
||||||
if (item.getClass().toString().endsWith("PrototypeChip"))
|
if (((PrototypeChip) item).inBurner) {
|
||||||
if (((PrototypeChip)item).inBurner)
|
pc = item;
|
||||||
pc = (PrototypeChip) item;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pc == null) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (pc==null) return false;
|
|
||||||
|
|
||||||
// Start the ChipCompiler thread
|
// Start the ChipCompiler thread
|
||||||
ChipCompiler cc = new ChipCompiler((PrototypeChip) pc, (SmallChip) sc);
|
ChipCompiler cc = new ChipCompiler((PrototypeChip) pc, (SmallChip) sc);
|
||||||
@@ -115,17 +108,16 @@ public boolean CanBePickedUp(Item i)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (burning > 0) {
|
||||||
if (burning>0)
|
|
||||||
{
|
|
||||||
animation = 1 - animation;
|
animation = 1 - animation;
|
||||||
currentIcon = icons[animation].getImage();
|
currentIcon = icons[animation].getImage();
|
||||||
burning--;
|
burning--;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,29 +9,27 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Button extends Item
|
public class Button extends Item {
|
||||||
{
|
private Color color;
|
||||||
Color color;
|
|
||||||
|
|
||||||
public Button(int X, int Y, Room r, Color c)
|
public Button(int X, int Y, Room r, Color c) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=26;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 26;
|
||||||
color = c;
|
color = c;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,36 +6,32 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.decorations.TextBox;
|
import com.droidquest.decorations.TextBox;
|
||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
public class CamDisk extends Disk
|
public class CamDisk extends Disk {
|
||||||
{
|
private transient SpyCam spycam = null;
|
||||||
transient SpyCam spycam=null;
|
|
||||||
|
|
||||||
public CamDisk(int X, int Y, Room r)
|
public CamDisk(int X, int Y, Room r) {
|
||||||
{
|
|
||||||
super(X, Y, r, Color.white, 0);
|
super(X, Y, r, Color.white, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
if (spycam == null) {
|
||||||
if (spycam==null)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
Item item = level.items.elementAt(a);
|
||||||
{
|
if (item.getClass().toString().endsWith("SpyCam")) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (item.getClass().toString().endsWith("SpyCam"))
|
|
||||||
spycam = (SpyCam) item;
|
spycam = (SpyCam) item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
int bigX = (x + width / 2) / 28;
|
int bigX = (x + width / 2) / 28;
|
||||||
int bigY = (y + height / 2) / 32;
|
int bigY = (y + height / 2) / 32;
|
||||||
Material mat = room.MaterialArray[bigY][bigX];
|
Material mat = room.MaterialArray[bigY][bigX];
|
||||||
if (mat.getClass().toString().endsWith("Monitor"))
|
if (mat.getClass().toString().endsWith("Monitor")) {
|
||||||
{
|
|
||||||
level.currentViewer = spycam;
|
level.currentViewer = spycam;
|
||||||
level.player = spycam;
|
level.player = spycam;
|
||||||
spycam.room = room;
|
spycam.room = room;
|
||||||
for (int a=5; a<60; a++)
|
for (int a = 5; a < 60; a++) {
|
||||||
{
|
Room r = level.rooms.elementAt(a);
|
||||||
Room r = (Room) level.rooms.elementAt(a);
|
TextBox tb = r.textBoxes.elementAt(0);
|
||||||
TextBox tb = (TextBox) r.textBoxes.elementAt(0);
|
|
||||||
tb.y -= 500;
|
tb.y -= 500;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,133 +1,108 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import com.droidquest.Wire;
|
import com.droidquest.Wire;
|
||||||
import com.droidquest.chipstuff.Gate;
|
import com.droidquest.chipstuff.Gate;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.chipstuff.Signal;
|
import com.droidquest.chipstuff.Signal;
|
||||||
import com.droidquest.devices.ANDGate;
|
import com.droidquest.devices.*;
|
||||||
import com.droidquest.devices.Device;
|
|
||||||
import com.droidquest.devices.FlipFlop;
|
|
||||||
import com.droidquest.devices.NOTGate;
|
|
||||||
import com.droidquest.devices.Node;
|
|
||||||
import com.droidquest.devices.ORGate;
|
|
||||||
import com.droidquest.devices.PortDevice;
|
|
||||||
import com.droidquest.devices.PrototypeChip;
|
|
||||||
import com.droidquest.devices.SmallChip;
|
|
||||||
import com.droidquest.devices.XORGate;
|
|
||||||
|
|
||||||
public class ChipDecompiler extends Thread
|
import java.util.Vector;
|
||||||
{
|
|
||||||
public ChipDecompiler(PrototypeChip pc, SmallChip sc)
|
class ChipDecompiler extends Thread {
|
||||||
{
|
public ChipDecompiler(PrototypeChip pc, SmallChip sc) {
|
||||||
Vector deviceList = new Vector();
|
Vector<Device> deviceList = new Vector<Device>();
|
||||||
pc.grabbable = false;
|
pc.grabbable = false;
|
||||||
sc.grabbable = false;
|
sc.grabbable = false;
|
||||||
|
|
||||||
// Remove all wires and devices from Prototype Chip, expect for PortDevices
|
// Remove all wires and devices from Prototype Chip, expect for PortDevices
|
||||||
for (int a=pc.InternalRoom.wires.size()-1; a>=0; a--)
|
for (int a = pc.InternalRoom.wires.size() - 1; a >= 0; a--) {
|
||||||
{
|
Wire wire = pc.InternalRoom.wires.elementAt(a);
|
||||||
Wire wire = (Wire)pc.InternalRoom.wires.elementAt(a);
|
|
||||||
wire.Remove();
|
wire.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
pc.portdevices[a].ports[0].type = Port.TYPE_UNDEFINED;
|
pc.portdevices[a].ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
pc.ports[a].type = Port.TYPE_UNDEFINED;
|
pc.ports[a].type = Port.TYPE_UNDEFINED;
|
||||||
pc.ports[a].value = false;
|
pc.ports[a].value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<pc.level.items.size(); a++)
|
for (int a = 0; a < pc.level.items.size(); a++) {
|
||||||
{
|
Item item = pc.level.items.elementAt(a);
|
||||||
Item item = (Item) pc.level.items.elementAt(a);
|
|
||||||
if (item.room == pc.InternalRoom
|
if (item.room == pc.InternalRoom
|
||||||
&& item instanceof Device
|
&& item instanceof Device
|
||||||
&& !(item instanceof PortDevice))
|
&& !(item instanceof PortDevice)) {
|
||||||
{
|
|
||||||
pc.level.items.removeElement(item);
|
pc.level.items.removeElement(item);
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the PortDevice types to match the SC PortSignal types
|
// Set the PortDevice types to match the SC PortSignal types
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
if (sc.portSignals[a].type != Port.TYPE_UNDEFINED) {
|
||||||
if (sc.portSignals[a].type != Port.TYPE_UNDEFINED)
|
|
||||||
pc.portdevices[a].ports[0].type = 1 - sc.portSignals[a].type;
|
pc.portdevices[a].ports[0].type = 1 - sc.portSignals[a].type;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
pc.portdevices[a].ports[0].type = Port.TYPE_UNDEFINED;
|
pc.portdevices[a].ports[0].type = Port.TYPE_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add a corresponding Device for every Gate in the SmallChip
|
// Add a corresponding Device for every Gate in the SmallChip
|
||||||
for (int a=0; a<sc.gates.size(); a++)
|
for (int a = 0; a < sc.gates.size(); a++) {
|
||||||
{
|
Gate gate = sc.gates.elementAt(a);
|
||||||
Gate gate = (Gate) sc.gates.elementAt(a);
|
if (gate.type.equalsIgnoreCase("AND")) {
|
||||||
if (gate.type.equalsIgnoreCase("AND"))
|
|
||||||
{
|
|
||||||
ANDGate andGate = new ANDGate(10 * 28, 6 * 32, pc.InternalRoom);
|
ANDGate andGate = new ANDGate(10 * 28, 6 * 32, pc.InternalRoom);
|
||||||
deviceList.addElement(andGate);
|
deviceList.addElement(andGate);
|
||||||
pc.level.items.addElement(andGate);
|
pc.level.items.addElement(andGate);
|
||||||
}
|
}
|
||||||
if (gate.type.equalsIgnoreCase("OR"))
|
if (gate.type.equalsIgnoreCase("OR")) {
|
||||||
{
|
|
||||||
ORGate orGate = new ORGate(10 * 28, 6 * 32, pc.InternalRoom);
|
ORGate orGate = new ORGate(10 * 28, 6 * 32, pc.InternalRoom);
|
||||||
deviceList.addElement(orGate);
|
deviceList.addElement(orGate);
|
||||||
pc.level.items.addElement(orGate);
|
pc.level.items.addElement(orGate);
|
||||||
}
|
}
|
||||||
if (gate.type.equalsIgnoreCase("NOT"))
|
if (gate.type.equalsIgnoreCase("NOT")) {
|
||||||
{
|
|
||||||
NOTGate notGate = new NOTGate(10 * 28, 6 * 32, pc.InternalRoom);
|
NOTGate notGate = new NOTGate(10 * 28, 6 * 32, pc.InternalRoom);
|
||||||
deviceList.addElement(notGate);
|
deviceList.addElement(notGate);
|
||||||
pc.level.items.addElement(notGate);
|
pc.level.items.addElement(notGate);
|
||||||
}
|
}
|
||||||
if (gate.type.equalsIgnoreCase("XOR"))
|
if (gate.type.equalsIgnoreCase("XOR")) {
|
||||||
{
|
|
||||||
XORGate xorGate = new XORGate(10 * 28, 6 * 32, pc.InternalRoom);
|
XORGate xorGate = new XORGate(10 * 28, 6 * 32, pc.InternalRoom);
|
||||||
deviceList.addElement(xorGate);
|
deviceList.addElement(xorGate);
|
||||||
pc.level.items.addElement(xorGate);
|
pc.level.items.addElement(xorGate);
|
||||||
}
|
}
|
||||||
if (gate.type.equalsIgnoreCase("FF"))
|
if (gate.type.equalsIgnoreCase("FF")) {
|
||||||
{
|
|
||||||
FlipFlop flipflop = new FlipFlop(10 * 28, 6 * 32, pc.InternalRoom);
|
FlipFlop flipflop = new FlipFlop(10 * 28, 6 * 32, pc.InternalRoom);
|
||||||
deviceList.addElement(flipflop);
|
deviceList.addElement(flipflop);
|
||||||
pc.level.items.addElement(flipflop);
|
pc.level.items.addElement(flipflop);
|
||||||
flipflop.state = gate.state;
|
flipflop.state = gate.state;
|
||||||
}
|
}
|
||||||
if (gate.type.equalsIgnoreCase("Chip"))
|
if (gate.type.equalsIgnoreCase("Chip")) {
|
||||||
{
|
|
||||||
SmallChip smallchip = new SmallChip(10 * 28, 6 * 32, pc.InternalRoom, "X");
|
SmallChip smallchip = new SmallChip(10 * 28, 6 * 32, pc.InternalRoom, "X");
|
||||||
deviceList.addElement(smallchip);
|
deviceList.addElement(smallchip);
|
||||||
pc.level.items.addElement(smallchip);
|
pc.level.items.addElement(smallchip);
|
||||||
smallchip.speed = gate.speed;
|
smallchip.speed = gate.speed;
|
||||||
|
|
||||||
for (int b=0; b<gate.mySignals.size(); b++)
|
for (int b = 0; b < gate.mySignals.size(); b++) {
|
||||||
{
|
|
||||||
Signal newsig = new Signal();
|
Signal newsig = new Signal();
|
||||||
Signal oldsig = (Signal) gate.mySignals.elementAt(b);
|
Signal oldsig = gate.mySignals.elementAt(b);
|
||||||
newsig.Set(oldsig.Get());
|
newsig.Set(oldsig.Get());
|
||||||
newsig.working = oldsig.working;
|
newsig.working = oldsig.working;
|
||||||
smallchip.signals.addElement(newsig);
|
smallchip.signals.addElement(newsig);
|
||||||
}
|
}
|
||||||
for (int b=0; b<gate.myGates.size(); b++)
|
for (int b = 0; b < gate.myGates.size(); b++) {
|
||||||
{
|
Gate oldgate = gate.myGates.elementAt(b);
|
||||||
Gate oldgate = (Gate) gate.myGates.elementAt(b);
|
|
||||||
Gate newgate = new Gate(oldgate);
|
Gate newgate = new Gate(oldgate);
|
||||||
smallchip.gates.addElement(newgate);
|
smallchip.gates.addElement(newgate);
|
||||||
for (int c=0; c<8; c++)
|
for (int c = 0; c < 8; c++) {
|
||||||
if (oldgate.portSignals[c].externalSignal != null)
|
if (oldgate.portSignals[c].externalSignal != null) {
|
||||||
{
|
|
||||||
int sigIndex = gate.mySignals.indexOf(oldgate.portSignals[c].externalSignal);
|
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++)
|
}
|
||||||
{
|
for (int b = 0; b < 8; b++) {
|
||||||
if (gate.portSignals[b].internalSignal != null)
|
if (gate.portSignals[b].internalSignal != null) {
|
||||||
{
|
|
||||||
int sigIndex = gate.mySignals.indexOf(gate.portSignals[b].internalSignal);
|
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.portSignals[b].type = gate.portSignals[b].type;
|
||||||
smallchip.ports[b].type = gate.portSignals[b].type;
|
smallchip.ports[b].type = gate.portSignals[b].type;
|
||||||
@@ -137,41 +112,44 @@ public ChipDecompiler(PrototypeChip pc, SmallChip sc)
|
|||||||
|
|
||||||
|
|
||||||
// Wire Devices according to the way the Gates are linked to Signals
|
// Wire Devices according to the way the Gates are linked to Signals
|
||||||
for (int a=0; a<sc.signals.size(); a++)
|
for (int a = 0; a < sc.signals.size(); a++) {
|
||||||
{
|
Signal sig = sc.signals.elementAt(a);
|
||||||
Signal sig = (Signal) sc.signals.elementAt(a);
|
if (sig.working) {
|
||||||
if (sig.working)
|
|
||||||
{
|
|
||||||
int numConnections = 0;
|
int numConnections = 0;
|
||||||
for (int b=0; b<8; b++)
|
for (int b = 0; b < 8; b++) {
|
||||||
if (sc.portSignals[b].internalSignal == sig)
|
if (sc.portSignals[b].internalSignal == sig) {
|
||||||
numConnections++;
|
numConnections++;
|
||||||
for (int b=0; b<sc.gates.size(); b++)
|
}
|
||||||
{
|
}
|
||||||
Gate thisGate = (Gate) sc.gates.elementAt(b);
|
for (int b = 0; b < sc.gates.size(); b++) {
|
||||||
for (int c=0; c<8; c++)
|
Gate thisGate = sc.gates.elementAt(b);
|
||||||
if (thisGate.portSignals[c].externalSignal == sig)
|
for (int c = 0; c < 8; c++) {
|
||||||
|
if (thisGate.portSignals[c].externalSignal == sig) {
|
||||||
numConnections++;
|
numConnections++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (numConnections == 2) // Simple wire from A to B
|
if (numConnections == 2) // Simple wire from A to B
|
||||||
{
|
{
|
||||||
Port port1 = FindPort(sig, 1, pc, sc, deviceList);
|
Port port1 = FindPort(sig, 1, pc, sc, deviceList);
|
||||||
Port port2 = FindPort(sig, 2, pc, sc, deviceList);
|
Port port2 = FindPort(sig, 2, pc, sc, deviceList);
|
||||||
if (port1!=null && port2 != null)
|
if (port1 != null && port2 != null) {
|
||||||
{
|
|
||||||
Wire dummy = new Wire(port1, port2);
|
Wire dummy = new Wire(port1, port2);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
System.out.println("Could not make connection for Signal " + a);
|
System.out.println("Could not make connection for Signal " + a);
|
||||||
if (port1==null)
|
if (port1 == null) {
|
||||||
System.out.println("port1=null");
|
System.out.println("port1=null");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
System.out.println("port1 is in " + port1.myDevice.getClass());
|
System.out.println("port1 is in " + port1.myDevice.getClass());
|
||||||
if (port2==null)
|
}
|
||||||
|
if (port2 == null) {
|
||||||
System.out.println("port2=null");
|
System.out.println("port2=null");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
System.out.println("port2 is in " + port2.myDevice.getClass());
|
System.out.println("port2 is in " + port2.myDevice.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,38 +162,32 @@ public ChipDecompiler(PrototypeChip pc, SmallChip sc)
|
|||||||
Node node = new Node(10 * 28, 6 * 32, pc.InternalRoom, Node.TYPE_STRAIGHT);
|
Node node = new Node(10 * 28, 6 * 32, pc.InternalRoom, Node.TYPE_STRAIGHT);
|
||||||
pc.level.items.addElement(node);
|
pc.level.items.addElement(node);
|
||||||
deviceList.addElement(node);
|
deviceList.addElement(node);
|
||||||
if (port1.type == Port.TYPE_OUTPUT)
|
if (port1.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port1, node.ports[0]);
|
Wire dummy1 = new Wire(port1, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port2, node.ports[1]);
|
Wire dummy2 = new Wire(port2, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
}
|
}
|
||||||
else if (port2.type == Port.TYPE_OUTPUT)
|
else if (port2.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port2, node.ports[0]);
|
Wire dummy1 = new Wire(port2, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
}
|
}
|
||||||
else if (port3.type == Port.TYPE_OUTPUT)
|
else if (port3.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port3, node.ports[0]);
|
Wire dummy1 = new Wire(port3, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port2, node.ports[2]);
|
Wire dummy3 = new Wire(port2, node.ports[2]);
|
||||||
}
|
}
|
||||||
else if (port1.type == Port.TYPE_UNDEFINED)
|
else if (port1.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port1, node.ports[0]);
|
Wire dummy1 = new Wire(port1, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port2, node.ports[1]);
|
Wire dummy2 = new Wire(port2, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
}
|
}
|
||||||
else if (port2.type == Port.TYPE_UNDEFINED)
|
else if (port2.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port2, node.ports[0]);
|
Wire dummy1 = new Wire(port2, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
}
|
}
|
||||||
else if (port3.type == Port.TYPE_UNDEFINED)
|
else if (port3.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port3, node.ports[0]);
|
Wire dummy1 = new Wire(port3, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port2, node.ports[2]);
|
Wire dummy3 = new Wire(port2, node.ports[2]);
|
||||||
@@ -231,57 +203,49 @@ public ChipDecompiler(PrototypeChip pc, SmallChip sc)
|
|||||||
Node node = new Node(10 * 28, 6 * 32, pc.InternalRoom, Node.TYPE_THREE);
|
Node node = new Node(10 * 28, 6 * 32, pc.InternalRoom, Node.TYPE_THREE);
|
||||||
pc.level.items.addElement(node);
|
pc.level.items.addElement(node);
|
||||||
deviceList.addElement(node);
|
deviceList.addElement(node);
|
||||||
if (port1.type == Port.TYPE_OUTPUT)
|
if (port1.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port1, node.ports[0]);
|
Wire dummy1 = new Wire(port1, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port2, node.ports[1]);
|
Wire dummy2 = new Wire(port2, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
Wire dummy4 = new Wire(port4, node.ports[3]);
|
Wire dummy4 = new Wire(port4, node.ports[3]);
|
||||||
}
|
}
|
||||||
else if (port2.type == Port.TYPE_OUTPUT)
|
else if (port2.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port2, node.ports[0]);
|
Wire dummy1 = new Wire(port2, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
Wire dummy4 = new Wire(port4, node.ports[3]);
|
Wire dummy4 = new Wire(port4, node.ports[3]);
|
||||||
}
|
}
|
||||||
else if (port3.type == Port.TYPE_OUTPUT)
|
else if (port3.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port3, node.ports[0]);
|
Wire dummy1 = new Wire(port3, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port2, node.ports[2]);
|
Wire dummy3 = new Wire(port2, node.ports[2]);
|
||||||
Wire dummy4 = new Wire(port4, node.ports[3]);
|
Wire dummy4 = new Wire(port4, node.ports[3]);
|
||||||
}
|
}
|
||||||
else if (port4.type == Port.TYPE_OUTPUT)
|
else if (port4.type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port4, node.ports[0]);
|
Wire dummy1 = new Wire(port4, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port2, node.ports[2]);
|
Wire dummy3 = new Wire(port2, node.ports[2]);
|
||||||
Wire dummy4 = new Wire(port3, node.ports[3]);
|
Wire dummy4 = new Wire(port3, node.ports[3]);
|
||||||
}
|
}
|
||||||
else if (port1.type == Port.TYPE_UNDEFINED)
|
else if (port1.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port1, node.ports[0]);
|
Wire dummy1 = new Wire(port1, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port2, node.ports[1]);
|
Wire dummy2 = new Wire(port2, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
Wire dummy4 = new Wire(port4, node.ports[3]);
|
Wire dummy4 = new Wire(port4, node.ports[3]);
|
||||||
}
|
}
|
||||||
else if (port2.type == Port.TYPE_UNDEFINED)
|
else if (port2.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port2, node.ports[0]);
|
Wire dummy1 = new Wire(port2, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port3, node.ports[2]);
|
Wire dummy3 = new Wire(port3, node.ports[2]);
|
||||||
Wire dummy4 = new Wire(port4, node.ports[3]);
|
Wire dummy4 = new Wire(port4, node.ports[3]);
|
||||||
}
|
}
|
||||||
else if (port3.type == Port.TYPE_UNDEFINED)
|
else if (port3.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port3, node.ports[0]);
|
Wire dummy1 = new Wire(port3, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port2, node.ports[2]);
|
Wire dummy3 = new Wire(port2, node.ports[2]);
|
||||||
Wire dummy4 = new Wire(port4, node.ports[3]);
|
Wire dummy4 = new Wire(port4, node.ports[3]);
|
||||||
}
|
}
|
||||||
else if (port4.type == Port.TYPE_UNDEFINED)
|
else if (port4.type == Port.TYPE_UNDEFINED) {
|
||||||
{
|
|
||||||
Wire dummy1 = new Wire(port4, node.ports[0]);
|
Wire dummy1 = new Wire(port4, node.ports[0]);
|
||||||
Wire dummy2 = new Wire(port1, node.ports[1]);
|
Wire dummy2 = new Wire(port1, node.ports[1]);
|
||||||
Wire dummy3 = new Wire(port2, node.ports[2]);
|
Wire dummy3 = new Wire(port2, node.ports[2]);
|
||||||
@@ -292,118 +256,119 @@ public ChipDecompiler(PrototypeChip pc, SmallChip sc)
|
|||||||
else if (numConnections > 4) // Need many nodes
|
else if (numConnections > 4) // Need many nodes
|
||||||
{
|
{
|
||||||
Port[] ports = new Port[numConnections];
|
Port[] ports = new Port[numConnections];
|
||||||
for (int b=0; b<numConnections; b++)
|
for (int b = 0; b < numConnections; b++) {
|
||||||
ports[b] = FindPort(sig, b + 1, pc, sc, deviceList);
|
ports[b] = FindPort(sig, b + 1, pc, sc, deviceList);
|
||||||
|
}
|
||||||
|
|
||||||
Node[] nodes = new Node[numConnections - 2];
|
Node[] nodes = new Node[numConnections - 2];
|
||||||
for (int b=0; b<numConnections-2; b++)
|
for (int b = 0; b < numConnections - 2; b++) {
|
||||||
{
|
|
||||||
nodes[b] = new Node(10 * 28, 6 * 32, pc.InternalRoom, Node.TYPE_STRAIGHT);
|
nodes[b] = new Node(10 * 28, 6 * 32, pc.InternalRoom, Node.TYPE_STRAIGHT);
|
||||||
pc.level.items.addElement(nodes[b]);
|
pc.level.items.addElement(nodes[b]);
|
||||||
deviceList.addElement(nodes[b]);
|
deviceList.addElement(nodes[b]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int b=1; b<numConnections-2; b++)
|
for (int b = 1; b < numConnections - 2; b++) {
|
||||||
{
|
|
||||||
Wire dummy = new Wire(nodes[b - 1].ports[2], nodes[b].ports[0]);
|
Wire dummy = new Wire(nodes[b - 1].ports[2], nodes[b].ports[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nodecounter = 0;
|
int nodecounter = 0;
|
||||||
boolean inputfound = false;
|
boolean inputfound = false;
|
||||||
for (int b=0; b<numConnections; b++)
|
for (int b = 0; b < numConnections; b++) {
|
||||||
{
|
if (ports[b].type == Port.TYPE_OUTPUT) {
|
||||||
if (ports[b].type == Port.TYPE_OUTPUT)
|
|
||||||
{
|
|
||||||
Wire dummy = new Wire(nodes[0].ports[0], ports[b]);
|
Wire dummy = new Wire(nodes[0].ports[0], ports[b]);
|
||||||
inputfound = true;
|
inputfound = true;
|
||||||
}
|
}
|
||||||
else if (ports[b].type == Port.TYPE_INPUT)
|
else if (ports[b].type == Port.TYPE_INPUT) {
|
||||||
{
|
if (nodecounter < nodes.length) {
|
||||||
if (nodecounter<nodes.length)
|
|
||||||
{
|
|
||||||
Wire dummy = new Wire(nodes[nodecounter].ports[1], ports[b]);
|
Wire dummy = new Wire(nodes[nodecounter].ports[1], ports[b]);
|
||||||
nodecounter++;
|
nodecounter++;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
Wire dummy = new Wire(nodes[nodecounter - 1].ports[2], ports[b]);
|
Wire dummy = new Wire(nodes[nodecounter - 1].ports[2], ports[b]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
System.out.println(ports[b].myDevice.getClass()
|
System.out.println(ports[b].myDevice.getClass()
|
||||||
+ " port " + b + " id undefined.");
|
+ " port " + b + " id undefined.");
|
||||||
}
|
}
|
||||||
if (!inputfound)
|
}
|
||||||
for (int b=0; b<numConnections; b++)
|
if (!inputfound) {
|
||||||
if (ports[b].type == Port.TYPE_UNDEFINED)
|
for (int b = 0; b < numConnections; b++) {
|
||||||
{
|
if (ports[b].type == Port.TYPE_UNDEFINED) {
|
||||||
Wire dummy = new Wire(nodes[0].ports[0], ports[b]);
|
Wire dummy = new Wire(nodes[0].ports[0], ports[b]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Routing: Move the devices around based on what they are connected to.
|
// Routing: Move the devices around based on what they are connected to.
|
||||||
for (int a=0; a<10; a++)
|
for (int a = 0; a < 10; a++) {
|
||||||
{
|
for (int b = 0; b < deviceList.size(); b++) {
|
||||||
for (int b=0; b<deviceList.size(); b++)
|
Device device = deviceList.elementAt(b);
|
||||||
{
|
|
||||||
Device device = (Device) deviceList.elementAt(b);
|
|
||||||
int numConnections = 1;
|
int numConnections = 1;
|
||||||
int x=device.x; int y=device.y;
|
int x = device.x;
|
||||||
for (int c=0; c<device.ports.length; c++)
|
int y = device.y;
|
||||||
if (device.ports[c].myWire != null)
|
for (int c = 0; c < device.ports.length; c++) {
|
||||||
{
|
if (device.ports[c].myWire != null) {
|
||||||
if (device.ports[c].type == Port.TYPE_INPUT)
|
if (device.ports[c].type == Port.TYPE_INPUT) {
|
||||||
{
|
|
||||||
x += device.ports[c].myWire.outPort.myDevice.x;
|
x += device.ports[c].myWire.outPort.myDevice.x;
|
||||||
y += device.ports[c].myWire.outPort.myDevice.y;
|
y += device.ports[c].myWire.outPort.myDevice.y;
|
||||||
}
|
}
|
||||||
else if (device.ports[c].type == Port.TYPE_OUTPUT)
|
else if (device.ports[c].type == Port.TYPE_OUTPUT) {
|
||||||
{
|
|
||||||
x += device.ports[c].myWire.inPort.myDevice.x;
|
x += device.ports[c].myWire.inPort.myDevice.x;
|
||||||
y += device.ports[c].myWire.inPort.myDevice.y;
|
y += device.ports[c].myWire.inPort.myDevice.y;
|
||||||
}
|
}
|
||||||
numConnections++;
|
numConnections++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
device.x = x / numConnections;
|
device.x = x / numConnections;
|
||||||
device.y = y / numConnections;
|
device.y = y / numConnections;
|
||||||
if (device.x < 56) device.x = 56;
|
if (device.x < 56) {
|
||||||
if (device.x > 504) device.x = 504;
|
device.x = 56;
|
||||||
if (device.y < 32) device.y = 32;
|
}
|
||||||
if (device.y > 320) device.y = 320;
|
if (device.x > 504) {
|
||||||
|
device.x = 504;
|
||||||
|
}
|
||||||
|
if (device.y < 32) {
|
||||||
|
device.y = 32;
|
||||||
|
}
|
||||||
|
if (device.y > 320) {
|
||||||
|
device.y = 320;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rotate devices to point to the "next" device. AND, OR, NOT, XOR only
|
// Rotate devices to point to the "next" device. AND, OR, NOT, XOR only
|
||||||
for (int a=0; a<deviceList.size(); a++)
|
for (int a = 0; a < deviceList.size(); a++) {
|
||||||
{
|
Device device = deviceList.elementAt(a);
|
||||||
Device device = (Device) deviceList.elementAt(a);
|
|
||||||
if (!(device instanceof SmallChip
|
if (!(device instanceof SmallChip
|
||||||
|| device instanceof Node
|
|| device instanceof Node
|
||||||
|| device instanceof FlipFlop))
|
|| device instanceof FlipFlop)) {
|
||||||
{
|
|
||||||
Port port;
|
Port port;
|
||||||
if (device instanceof NOTGate)
|
if (device instanceof NOTGate) {
|
||||||
port = device.ports[1];
|
port = device.ports[1];
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
port = device.ports[2];
|
port = device.ports[2];
|
||||||
if (port.myWire != null)
|
}
|
||||||
{
|
if (port.myWire != null) {
|
||||||
Port otherPort = port.myWire.otherPort(port);
|
Port otherPort = port.myWire.otherPort(port);
|
||||||
Device otherDevice = (Device) otherPort.myDevice;
|
Device otherDevice = (Device) otherPort.myDevice;
|
||||||
int dx = otherDevice.x - device.x;
|
int dx = otherDevice.x - device.x;
|
||||||
int dy = otherDevice.y - device.y;
|
int dy = otherDevice.y - device.y;
|
||||||
if (Math.abs(dx)>Math.abs(dy))
|
if (Math.abs(dx) > Math.abs(dy)) {
|
||||||
{
|
if (dx < 0) {
|
||||||
if (dx<0) device.rotate(-1);
|
device.rotate(-1);
|
||||||
else device.rotate(1);
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
device.rotate(1);
|
||||||
if (dy>0)
|
}
|
||||||
{
|
}
|
||||||
|
else {
|
||||||
|
if (dy > 0) {
|
||||||
device.rotate(1);
|
device.rotate(1);
|
||||||
device.rotate(1);
|
device.rotate(1);
|
||||||
}
|
}
|
||||||
@@ -418,32 +383,31 @@ public ChipDecompiler(PrototypeChip pc, SmallChip sc)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Port FindPort(Signal sig, int num, PrototypeChip pc, SmallChip sc, Vector deviceList)
|
Port FindPort(Signal sig, int num, PrototypeChip pc, SmallChip sc, Vector<Device> deviceList) {
|
||||||
{
|
|
||||||
// Find Nth port that this signal attaches to in given SmallChip.
|
// Find Nth port that this signal attaches to in given SmallChip.
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
if (sc.portSignals[a].internalSignal == sig)
|
if (sc.portSignals[a].internalSignal == sig) {
|
||||||
{
|
|
||||||
n++;
|
n++;
|
||||||
if (n==num) return pc.portdevices[a].ports[0];
|
if (n == num) {
|
||||||
|
return pc.portdevices[a].ports[0];
|
||||||
}
|
}
|
||||||
for (int a=0; a<sc.gates.size(); a++)
|
}
|
||||||
{
|
}
|
||||||
Gate thisgate = (Gate) sc.gates.elementAt(a);
|
for (int a = 0; a < sc.gates.size(); a++) {
|
||||||
for (int b=0; b<8; b++)
|
Gate thisgate = sc.gates.elementAt(a);
|
||||||
if (thisgate.portSignals[b].externalSignal == sig)
|
for (int b = 0; b < 8; b++) {
|
||||||
{
|
if (thisgate.portSignals[b].externalSignal == sig) {
|
||||||
n++;
|
n++;
|
||||||
if (n==num)
|
if (n == num) {
|
||||||
{
|
Device device = deviceList.elementAt(a);
|
||||||
Device device = (Device) deviceList.elementAt(a);
|
|
||||||
return device.ports[b];
|
return device.ports[b];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,22 +9,22 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Crystal extends Item
|
public class Crystal extends Item {
|
||||||
{
|
private int color = 0; // 0 = blue; 1 = orange
|
||||||
int color = 0; // 0 = blue; 1 = orange
|
|
||||||
|
|
||||||
public Crystal(int X, int Y, Room r, int ch)
|
public Crystal(int X, int Y, Room r, int ch) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
charge = ch;
|
charge = ch;
|
||||||
width=28; height=24;
|
width = 28;
|
||||||
|
height = 24;
|
||||||
editable = true;
|
editable = true;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[3];
|
icons = new ImageIcon[3];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -34,12 +34,10 @@ public void GenerateIcons()
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// 0 = blue
|
// 0 = blue
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -57,12 +55,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(24, 18, 4, 2);
|
g.fillRect(24, 18, 4, 2);
|
||||||
|
|
||||||
// 1 = orange
|
// 1 = orange
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,12 +76,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(24, 18, 4, 2);
|
g.fillRect(24, 18, 4, 2);
|
||||||
|
|
||||||
// 2 = white
|
// 2 = white
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[2].getImage().getGraphics();
|
g = icons[2].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -103,20 +97,20 @@ public void GenerateIcons()
|
|||||||
g.fillRect(24, 18, 4, 2);
|
g.fillRect(24, 18, 4, 2);
|
||||||
|
|
||||||
currentIcon = icons[color].getImage();
|
currentIcon = icons[color].getImage();
|
||||||
if (charge==0)
|
if (charge == 0) {
|
||||||
currentIcon = icons[2].getImage();
|
currentIcon = icons[2].getImage();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
if (charge > 0) {
|
||||||
if (charge>0)
|
|
||||||
{
|
|
||||||
color = 1 - color;
|
color = 1 - color;
|
||||||
currentIcon = icons[color].getImage();
|
currentIcon = icons[color].getImage();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
currentIcon = icons[2].getImage();
|
currentIcon = icons[2].getImage();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +1,40 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
import com.droidquest.Room;
|
||||||
import java.awt.Graphics;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
public class Disk extends Item {
|
||||||
|
private transient Room helpRoom = null;
|
||||||
|
private Color color;
|
||||||
|
private transient Room helpCamRoom = null;
|
||||||
|
|
||||||
import com.droidquest.Room;
|
public Disk(int X, int Y, Room r, Color col, int hr) {
|
||||||
import com.droidquest.decorations.TextBox;
|
x = X;
|
||||||
import com.droidquest.materials.Material;
|
y = Y;
|
||||||
|
room = r;
|
||||||
public class Disk extends Item
|
|
||||||
{
|
|
||||||
transient Room helpRoom = null;
|
|
||||||
Color color;
|
|
||||||
transient Room helpCamRoom = null;
|
|
||||||
|
|
||||||
public Disk(int X, int Y, Room r, Color col, int hr)
|
|
||||||
{
|
|
||||||
x=X; y=Y; room=r;
|
|
||||||
color = col;
|
color = col;
|
||||||
width=28; height=24;
|
width = 28;
|
||||||
|
height = 24;
|
||||||
grabbable = true;
|
grabbable = true;
|
||||||
helpRoom = (Room) level.rooms.elementAt(hr);
|
helpRoom = level.rooms.elementAt(hr);
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -55,26 +50,22 @@ public void GenerateIcons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void writeRef(ObjectOutputStream s) throws IOException
|
public void writeRef(ObjectOutputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.writeRef(s);
|
super.writeRef(s);
|
||||||
s.writeInt(level.rooms.indexOf(helpRoom));
|
s.writeInt(level.rooms.indexOf(helpRoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readRef(ObjectInputStream s) throws IOException
|
public void readRef(ObjectInputStream s) throws IOException {
|
||||||
{
|
|
||||||
super.readRef(s);
|
super.readRef(s);
|
||||||
helpRoom = (Room) level.FindRoom(s.readInt());
|
helpRoom = level.FindRoom(s.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
|
||||||
|
|
||||||
int bigX = (x + width / 2) / 28;
|
int bigX = (x + width / 2) / 28;
|
||||||
int bigY = (y + height / 2) / 32;
|
int bigY = (y + height / 2) / 32;
|
||||||
Material mat = room.MaterialArray[bigY][bigX];
|
Material mat = room.MaterialArray[bigY][bigX];
|
||||||
if (mat.getClass().toString().endsWith("Monitor"))
|
if (mat.getClass().toString().endsWith("Monitor")) {
|
||||||
{
|
|
||||||
helpCamRoom = level.helpCam.room; // Temporary storage
|
helpCamRoom = level.helpCam.room; // Temporary storage
|
||||||
level.helpCam.room = helpRoom;
|
level.helpCam.room = helpRoom;
|
||||||
level.currentViewer = level.helpCam;
|
level.currentViewer = level.helpCam;
|
||||||
@@ -82,10 +73,10 @@ public void IsDropped()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
if (level.helpCam.room == room) {
|
||||||
if (level.helpCam.room == room)
|
|
||||||
level.helpCam.room = helpCamRoom;
|
level.helpCam.room = helpCamRoom;
|
||||||
|
}
|
||||||
level.currentViewer = level.player;
|
level.currentViewer = level.player;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,29 +8,27 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class ElevatorKey extends Item
|
public class ElevatorKey extends Item {
|
||||||
{
|
private boolean jumping = true;
|
||||||
boolean jumping=true;
|
|
||||||
|
|
||||||
public ElevatorKey(int X, int Y, Room r)
|
public ElevatorKey(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=32;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 32;
|
||||||
grabbable = true;
|
grabbable = true;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -48,13 +46,12 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (carriedBy != null) {
|
||||||
if (carriedBy!=null)
|
|
||||||
jumping = false;
|
jumping = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (jumping==true)
|
if (jumping) {
|
||||||
{
|
|
||||||
x = level.random.nextInt(8 * 28) + 28;
|
x = level.random.nextInt(8 * 28) + 28;
|
||||||
y = level.random.nextInt(2 * 32) + (8 * 32);
|
y = level.random.nextInt(2 * 32) + (8 * 32);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,35 +5,33 @@ import com.droidquest.decorations.Arrow;
|
|||||||
import com.droidquest.materials.ElevatorOutPortal;
|
import com.droidquest.materials.ElevatorOutPortal;
|
||||||
import com.droidquest.materials.Switch;
|
import com.droidquest.materials.Switch;
|
||||||
|
|
||||||
public class ElevatorSwitch extends Switch
|
public class ElevatorSwitch extends Switch {
|
||||||
{
|
private int animationState = 0;
|
||||||
int animationState=0;
|
|
||||||
// 0=open
|
// 0=open
|
||||||
// 1=closing
|
// 1=closing
|
||||||
// 2=closing
|
// 2=closing
|
||||||
// 3=switch arrow, switch outRoom
|
// 3=switch arrow, switch outRoom
|
||||||
// 4=opening
|
// 4=opening
|
||||||
// 5=opening
|
// 5=opening
|
||||||
transient static Room room;
|
private transient static Room room;
|
||||||
|
|
||||||
public ElevatorSwitch()
|
public ElevatorSwitch() {
|
||||||
{
|
|
||||||
super(Switch.ROT_LEFT);
|
super(Switch.ROT_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TouchedByItem(Item item)
|
public void TouchedByItem(Item item) {
|
||||||
{
|
|
||||||
room = item.room;
|
room = item.room;
|
||||||
if (animationState==0)
|
if (animationState == 0) {
|
||||||
animationState = 1;
|
animationState = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
super.Animate();
|
super.Animate();
|
||||||
switch (animationState)
|
switch (animationState) {
|
||||||
{
|
case 0:
|
||||||
case 0: value =false; break;
|
value = false;
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Play sound
|
// Play sound
|
||||||
value = true;
|
value = true;
|
||||||
@@ -47,21 +45,17 @@ public void Animate()
|
|||||||
animationState++;
|
animationState++;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (ElevatorOutPortal.outRoom == (Room) level.rooms.elementAt(11))
|
if (ElevatorOutPortal.outRoom == level.rooms.elementAt(11)) {
|
||||||
{
|
for (int a = 0; a < room.arrows.size(); a++) {
|
||||||
for (int a=0; a<room.arrows.size(); a++)
|
Arrow arrow = room.arrows.elementAt(a);
|
||||||
{
|
|
||||||
Arrow arrow = (Arrow) room.arrows.elementAt(a);
|
|
||||||
arrow.direction = Arrow.DIR_UP;
|
arrow.direction = Arrow.DIR_UP;
|
||||||
arrow.y = 66;
|
arrow.y = 66;
|
||||||
}
|
}
|
||||||
ElevatorOutPortal.SetOutRoom(9);
|
ElevatorOutPortal.SetOutRoom(9);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
for (int a = 0; a < room.arrows.size(); a++) {
|
||||||
for (int a=0; a<room.arrows.size(); a++)
|
Arrow arrow = room.arrows.elementAt(a);
|
||||||
{
|
|
||||||
Arrow arrow = (Arrow) room.arrows.elementAt(a);
|
|
||||||
arrow.direction = Arrow.DIR_DOWN;
|
arrow.direction = Arrow.DIR_DOWN;
|
||||||
arrow.y = 94;
|
arrow.y = 94;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,43 @@ package com.droidquest.items;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class EndAnimation extends HiddenCamera
|
public class EndAnimation extends HiddenCamera {
|
||||||
{
|
|
||||||
|
|
||||||
int animationState=0;
|
private int animationState = 0;
|
||||||
transient boolean playsong = false;
|
private transient boolean playsong = false;
|
||||||
|
|
||||||
public EndAnimation(Room r)
|
public EndAnimation(Room r) {
|
||||||
{
|
|
||||||
super(r);
|
super(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (!playsong) {
|
||||||
if (playsong==false)
|
|
||||||
{
|
|
||||||
level.PlaySound(room, Level.ENDMUSICSOUND);
|
level.PlaySound(room, Level.ENDMUSICSOUND);
|
||||||
playsong = true;
|
playsong = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
animationState = 1 - animationState;
|
animationState = 1 - animationState;
|
||||||
for(int a=0; a<20; a++)
|
for (int a = 0; a < 20; a++) {
|
||||||
if (a%2==animationState)
|
if (a % 2 == animationState) {
|
||||||
{
|
|
||||||
room.SetMaterial(a, 0, 0);
|
room.SetMaterial(a, 0, 0);
|
||||||
room.SetMaterial(a, 11, 1);
|
room.SetMaterial(a, 11, 1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
room.SetMaterial(a, 0, 1);
|
room.SetMaterial(a, 0, 1);
|
||||||
room.SetMaterial(a, 11, 0);
|
room.SetMaterial(a, 11, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int a=0; a<12; a++)
|
for (int a = 0; a < 12; a++) {
|
||||||
if (a%2==animationState)
|
if (a % 2 == animationState) {
|
||||||
{
|
|
||||||
room.SetMaterial(0, a, 0);
|
room.SetMaterial(0, a, 0);
|
||||||
room.SetMaterial(19, a, 1);
|
room.SetMaterial(19, a, 1);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
room.SetMaterial(0, a, 1);
|
room.SetMaterial(0, a, 1);
|
||||||
room.SetMaterial(19, a, 0);
|
room.SetMaterial(19, a, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,36 +4,34 @@ import java.awt.Color;
|
|||||||
|
|
||||||
import com.droidquest.decorations.TextBox;
|
import com.droidquest.decorations.TextBox;
|
||||||
|
|
||||||
public class EnergyButton extends Button
|
public class EnergyButton extends Button {
|
||||||
{
|
|
||||||
transient NotAButton nb = null;
|
transient NotAButton nb = null;
|
||||||
int animationState=0;
|
private int animationState = 0;
|
||||||
|
|
||||||
public EnergyButton()
|
public EnergyButton() {
|
||||||
{
|
|
||||||
super(0, 0, null, new Color(255, 128, 0));
|
super(0, 0, null, new Color(255, 128, 0));
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (animationState == 0) {
|
||||||
if (animationState==0)
|
if (room != null) {
|
||||||
if (room != null)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
Item item = level.items.elementAt(a);
|
||||||
{
|
if (Overlaps(item)) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (Overlaps(item))
|
|
||||||
{
|
|
||||||
animationState = 1;
|
animationState = 1;
|
||||||
nb.animationState = 51;
|
nb.animationState = 51;
|
||||||
for (int b=1; b<19; b++)
|
for (int b = 1; b < 19; b++) {
|
||||||
room.downRoom.SetMaterial(b, 4, 0);
|
room.downRoom.SetMaterial(b, 4, 0);
|
||||||
TextBox line = (TextBox) room.downRoom.textBoxes.elementAt(1);
|
}
|
||||||
|
TextBox line = room.downRoom.textBoxes.elementAt(1);
|
||||||
line.textString = " ";
|
line.textString = " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,29 +8,26 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class F12Form extends Item
|
public class F12Form extends Item {
|
||||||
{
|
private transient GateKeeper gk = null;
|
||||||
transient GateKeeper gk=null;
|
|
||||||
|
|
||||||
public F12Form(int X, int Y, Room r)
|
public F12Form(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
room = r;
|
room = r;
|
||||||
width = 28; height = 32;
|
width = 28;
|
||||||
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -50,22 +47,21 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
Item item = level.items.elementAt(a);
|
||||||
{
|
if (item.getClass().toString().endsWith("GateKeeper")) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (item.getClass().toString().endsWith("GateKeeper"))
|
|
||||||
gk = (GateKeeper) item;
|
gk = (GateKeeper) item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gk != null)
|
if (gk != null) {
|
||||||
if (Overlaps(gk))
|
if (Overlaps(gk)) {
|
||||||
{
|
|
||||||
gk.PicksUp(this);
|
gk.PicksUp(this);
|
||||||
gk.behavior = 1;
|
gk.behavior = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,38 +4,30 @@ import java.awt.Color;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class FFButton extends Button
|
public class FFButton extends Button {
|
||||||
{
|
private transient GenericRobot[] robots = null;
|
||||||
transient GenericRobot[] robots = null;
|
|
||||||
|
|
||||||
public FFButton(int X, int Y, Room r)
|
public FFButton(int X, int Y, Room r) {
|
||||||
{
|
|
||||||
super(X, Y, r, Color.white);
|
super(X, Y, r, Color.white);
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (robots == null) {
|
||||||
if (robots==null)
|
|
||||||
{
|
|
||||||
robots = new GenericRobot[3];
|
robots = new GenericRobot[3];
|
||||||
int rcount = 0;
|
int rcount = 0;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item instanceof GenericRobot) {
|
||||||
if (item instanceof GenericRobot)
|
|
||||||
{
|
|
||||||
robots[rcount] = (GenericRobot) item;
|
robots[rcount] = (GenericRobot) item;
|
||||||
rcount++;
|
rcount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
for (int a = 0; a < 3; a++) {
|
||||||
for (int a=0; a<3; a++)
|
if (robots[a] != null) {
|
||||||
if (robots[a]!=null)
|
if (Overlaps(robots[a])) {
|
||||||
if (Overlaps(robots[a]))
|
|
||||||
{
|
|
||||||
room.SetMaterial(0, 4, 0);
|
room.SetMaterial(0, 4, 0);
|
||||||
room.SetMaterial(0, 5, 0);
|
room.SetMaterial(0, 5, 0);
|
||||||
room.SetMaterial(0, 6, 0);
|
room.SetMaterial(0, 6, 0);
|
||||||
@@ -51,5 +43,7 @@ public void Animate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.devices.PrototypeChip;
|
import com.droidquest.devices.PrototypeChip;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class Factory extends Item
|
public class Factory extends Item {
|
||||||
{
|
private Item target;
|
||||||
Item target;
|
|
||||||
|
|
||||||
public Factory (int X, int Y, Room r, Item t)
|
public Factory(int X, int Y, Room r, Item t) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
target = t;
|
target = t;
|
||||||
width=28; height=26;
|
width = 28;
|
||||||
|
height = 26;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
target.GenerateIcons();
|
target.GenerateIcons();
|
||||||
target.Decorate();
|
target.Decorate();
|
||||||
width = Math.max(((BufferedImage) target.currentIcon).getWidth() + 8, 18);
|
width = Math.max(((BufferedImage) target.currentIcon).getWidth() + 8, 18);
|
||||||
@@ -32,12 +32,10 @@ public void GenerateIcons()
|
|||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -55,13 +53,14 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
|
||||||
Item item;
|
Item item;
|
||||||
if (target instanceof PrototypeChip)
|
if (target instanceof PrototypeChip) {
|
||||||
item = new PrototypeChip(0, 0, null);
|
item = new PrototypeChip(0, 0, null);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
item = (Item) target.clone();
|
item = (Item) target.clone();
|
||||||
|
}
|
||||||
item.GenerateIcons();
|
item.GenerateIcons();
|
||||||
item.x = (560 - item.width) / 2;
|
item.x = (560 - item.width) / 2;
|
||||||
item.y = (384 - item.height) / 2;
|
item.y = (384 - item.height) / 2;
|
||||||
|
|||||||
@@ -1,44 +1,38 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.devices.StormShield;
|
import com.droidquest.devices.StormShield;
|
||||||
|
|
||||||
public class GateKeeper extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class GateKeeper extends Item {
|
||||||
int behavior = 0;
|
int behavior = 0;
|
||||||
// 0= pause
|
// 0= pause
|
||||||
// 1= Go to trash, delete F-12, delete StormShield
|
// 1= Go to trash, delete F-12, delete StormShield
|
||||||
|
|
||||||
int goToX=2*28+14;
|
private int goToX = 2 * 28 + 14;
|
||||||
int goToY=8*32;
|
private int goToY = 8 * 32;
|
||||||
|
|
||||||
public GateKeeper(int X, int Y, Room r)
|
public GateKeeper(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
room = r;
|
room = r;
|
||||||
width=52; height=38;
|
width = 52;
|
||||||
|
height = 38;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -68,41 +62,38 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (behavior == 1) {
|
||||||
if (behavior ==1)
|
if (x != goToX && y != goToY) {
|
||||||
{
|
if (x != goToX) {
|
||||||
if (x != goToX && y != goToY)
|
|
||||||
{
|
|
||||||
if (x != goToX)
|
|
||||||
{
|
|
||||||
int diff = Math.abs(goToX - x);
|
int diff = Math.abs(goToX - x);
|
||||||
int dir = diff / (goToX - x);
|
int dir = diff / (goToX - x);
|
||||||
if (diff > 2) diff = 2;
|
if (diff > 2) {
|
||||||
MoveRight(diff * dir);
|
diff = 2;
|
||||||
}
|
}
|
||||||
if (y != goToY)
|
moveRight(diff * dir);
|
||||||
{
|
}
|
||||||
|
if (y != goToY) {
|
||||||
int diff = Math.abs(goToY - y);
|
int diff = Math.abs(goToY - y);
|
||||||
int dir = diff / (goToY - y);
|
int dir = diff / (goToY - y);
|
||||||
if (diff > 2) diff = 2;
|
if (diff > 2) {
|
||||||
MoveDown(diff * dir);
|
diff = 2;
|
||||||
|
}
|
||||||
|
moveDown(diff * dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
behavior = 0;
|
behavior = 0;
|
||||||
level.items.removeElement(carrying);
|
level.items.removeElement(carrying);
|
||||||
carrying = null;
|
carrying = null;
|
||||||
StormShield ss = null;
|
StormShield ss = null;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item.getClass().toString().endsWith("StormShield")) {
|
||||||
if (item.getClass().toString().endsWith("StormShield"))
|
|
||||||
ss = (StormShield) item;
|
ss = (StormShield) item;
|
||||||
}
|
}
|
||||||
if (ss!=null)
|
}
|
||||||
{
|
if (ss != null) {
|
||||||
ss.SetRoom(null); // Removes wires
|
ss.SetRoom(null); // Removes wires
|
||||||
level.items.removeElement(ss);
|
level.items.removeElement(ss);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,17 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.Port;
|
import com.droidquest.chipstuff.Port;
|
||||||
import com.droidquest.decorations.Spark;
|
import com.droidquest.decorations.Spark;
|
||||||
import com.droidquest.devices.Device;
|
import com.droidquest.devices.Device;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
import com.droidquest.materials.BatteryIn;
|
import com.droidquest.materials.*;
|
||||||
import com.droidquest.materials.BatteryOut;
|
|
||||||
import com.droidquest.materials.Material;
|
|
||||||
import com.droidquest.materials.PeriscopeDown;
|
|
||||||
import com.droidquest.materials.PeriscopeUp;
|
|
||||||
|
|
||||||
public class GenericRobot extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class GenericRobot extends Item {
|
||||||
public Device devices[] = new Device[10];
|
public Device devices[] = new Device[10];
|
||||||
public boolean topBumper;
|
public boolean topBumper;
|
||||||
public boolean bottomBumper;
|
public boolean bottomBumper;
|
||||||
@@ -35,29 +25,32 @@ public boolean rightThruster;
|
|||||||
public boolean antenna;
|
public boolean antenna;
|
||||||
public boolean broadcasting;
|
public boolean broadcasting;
|
||||||
public int grabber; // use Port.ROT_ for rotations.
|
public int grabber; // use Port.ROT_ for rotations.
|
||||||
Color color;
|
private Color color;
|
||||||
public boolean periscope;
|
public boolean periscope;
|
||||||
public int periscopeAnimation;
|
private int periscopeAnimation;
|
||||||
transient public boolean oldTopBumper;
|
private transient boolean oldTopBumper;
|
||||||
transient public boolean oldBottomBumper;
|
private transient boolean oldBottomBumper;
|
||||||
transient public boolean oldLeftBumper;
|
private transient boolean oldLeftBumper;
|
||||||
transient public boolean oldRightBumper;
|
private transient boolean oldRightBumper;
|
||||||
transient ImageIcon images[];
|
private transient ImageIcon[] images;
|
||||||
|
|
||||||
public GenericRobot(int X, int Y, Room r, Color c)
|
GenericRobot(int X, int Y, Room r, Color c) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
grabber = 1;
|
grabber = 1;
|
||||||
charge = 100000;
|
charge = 100000;
|
||||||
color = c;
|
color = c;
|
||||||
// orgX = 32; orgY = 24;
|
// orgX = 32; orgY = 24;
|
||||||
orgX = 14; orgY = 24;
|
orgX = 14;
|
||||||
|
orgY = 24;
|
||||||
// orgX = 14; orgY = 0;
|
// orgX = 14; orgY = 0;
|
||||||
width = 56; height = 42;
|
width = 56;
|
||||||
|
height = 42;
|
||||||
|
|
||||||
|
|
||||||
InternalRoom = new Room();
|
InternalRoom = new Room();
|
||||||
int[][] table = {
|
InternalRoom.RoomArray = new int[][]{
|
||||||
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
|
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
|
||||||
{0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0},
|
{0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0},
|
||||||
{0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
|
{0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
|
||||||
@@ -71,7 +64,6 @@ public GenericRobot(int X, int Y, Room r, Color c)
|
|||||||
{0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0},
|
{0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0},
|
||||||
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0}
|
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0}
|
||||||
};
|
};
|
||||||
InternalRoom.RoomArray = table;
|
|
||||||
|
|
||||||
Material mat1 = Material.FindSimiliar(new Material(color, false, true));
|
Material mat1 = Material.FindSimiliar(new Material(color, false, true));
|
||||||
int mat1Index = level.materials.indexOf(mat1);
|
int mat1Index = level.materials.indexOf(mat1);
|
||||||
@@ -86,9 +78,13 @@ public GenericRobot(int X, int Y, Room r, Color c)
|
|||||||
((BatteryIn) battIn).robot = this;
|
((BatteryIn) battIn).robot = this;
|
||||||
((BatteryOut) battOut).robot = this;
|
((BatteryOut) battOut).robot = this;
|
||||||
|
|
||||||
for (int rY=0; rY<12; rY++)
|
for (int rY = 0; rY < 12; rY++) {
|
||||||
for (int rX=0; rX<20; rX++)
|
for (int rX = 0; rX < 20; rX++) {
|
||||||
if (InternalRoom.RoomArray[rY][rX]==1) InternalRoom.RoomArray[rY][rX] = mat1Index;
|
if (InternalRoom.RoomArray[rY][rX] == 1) {
|
||||||
|
InternalRoom.RoomArray[rY][rX] = mat1Index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
InternalRoom.RoomArray[2][17] = perUpIndex;
|
InternalRoom.RoomArray[2][17] = perUpIndex;
|
||||||
InternalRoom.RoomArray[2][16] = perDownIndex;
|
InternalRoom.RoomArray[2][16] = perDownIndex;
|
||||||
InternalRoom.RoomArray[3][17] = perDownIndex;
|
InternalRoom.RoomArray[3][17] = perDownIndex;
|
||||||
@@ -116,12 +112,13 @@ public GenericRobot(int X, int Y, Room r, Color c)
|
|||||||
Animate();
|
Animate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
// orgX = 14; orgY = 24;
|
// orgX = 14; orgY = 24;
|
||||||
// width = 56; height = 42;
|
// width = 56; height = 42;
|
||||||
orgX = 14; orgY = 24;
|
orgX = 14;
|
||||||
width = 56; height = 44;
|
orgY = 24;
|
||||||
|
width = 56;
|
||||||
|
height = 44;
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
// icons[0]= new ImageIcon(new BufferedImage(122,92,BufferedImage.TYPE_4BYTE_ABGR));
|
// icons[0]= new ImageIcon(new BufferedImage(122,92,BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[0] = new ImageIcon(new BufferedImage(84, 84, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(84, 84, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -129,17 +126,14 @@ public void GenerateIcons()
|
|||||||
((BatteryIn) level.materials.elementAt(InternalRoom.RoomArray[9][3])).robot = this;
|
((BatteryIn) level.materials.elementAt(InternalRoom.RoomArray[9][3])).robot = this;
|
||||||
((BatteryOut) level.materials.elementAt(InternalRoom.RoomArray[9][2])).robot = this;
|
((BatteryOut) level.materials.elementAt(InternalRoom.RoomArray[9][2])).robot = this;
|
||||||
images = new ImageIcon[10];
|
images = new ImageIcon[10];
|
||||||
for (int a=0; a<10; a++)
|
for (int a = 0; a < 10; a++) {
|
||||||
{
|
|
||||||
// images[a] = new ImageIcon( new BufferedImage(122,92,BufferedImage.TYPE_4BYTE_ABGR));
|
// images[a] = new ImageIcon( new BufferedImage(122,92,BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
images[a] = new ImageIcon(new BufferedImage(84, 84, BufferedImage.TYPE_4BYTE_ABGR));
|
images[a] = new ImageIcon(new BufferedImage(84, 84, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = images[a].getImage().getGraphics();
|
g = images[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -149,8 +143,7 @@ public void GenerateIcons()
|
|||||||
// g2.clearRect(0,0,122,92);
|
// g2.clearRect(0,0,122,92);
|
||||||
g2.clearRect(0, 0, 84, 84);
|
g2.clearRect(0, 0, 84, 84);
|
||||||
|
|
||||||
switch (a)
|
switch (a) {
|
||||||
{
|
|
||||||
case 0: // Robot Body
|
case 0: // Robot Body
|
||||||
{
|
{
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
@@ -293,58 +286,56 @@ public void GenerateIcons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
// Do Thrusting
|
// Do Thrusting
|
||||||
if (charge>0 && level.electricity && (carriedBy == null) && thrusterPower)
|
if (charge > 0 && level.electricity && (carriedBy == null) && thrusterPower) {
|
||||||
{
|
if (topThruster) {
|
||||||
if (topThruster)
|
moveDown(8);
|
||||||
MoveDown(8);
|
}
|
||||||
if (rightThruster)
|
if (rightThruster) {
|
||||||
MoveLeft(8);
|
moveLeft(8);
|
||||||
if (bottomThruster)
|
}
|
||||||
MoveUp(8);
|
if (bottomThruster) {
|
||||||
if (leftThruster)
|
moveUp(8);
|
||||||
MoveRight(8);
|
}
|
||||||
|
if (leftThruster) {
|
||||||
|
moveRight(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (charge>0 && level.electricity && thrusterPower)
|
if (charge > 0 && level.electricity && thrusterPower) {
|
||||||
{
|
|
||||||
Dimension d = GetXY();
|
Dimension d = GetXY();
|
||||||
int X = d.width;
|
int X = d.width;
|
||||||
int Y = d.height;
|
int Y = d.height;
|
||||||
if (topThruster)
|
if (topThruster) {
|
||||||
{
|
|
||||||
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 24, 0, -4, room));
|
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 24, 0, -4, room));
|
||||||
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 24, 0, -4, room));
|
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 24, 0, -4, room));
|
||||||
charge -= 2;
|
charge -= 2;
|
||||||
}
|
}
|
||||||
if (rightThruster)
|
if (rightThruster) {
|
||||||
{
|
|
||||||
level.sparks.addElement(new Spark(X - orgX + 74, Y - orgY + 36 + level.random.nextInt(20), 4, 0, room));
|
level.sparks.addElement(new Spark(X - orgX + 74, Y - orgY + 36 + level.random.nextInt(20), 4, 0, room));
|
||||||
level.sparks.addElement(new Spark(X - orgX + 74, Y - orgY + 36 + level.random.nextInt(20), 4, 0, room));
|
level.sparks.addElement(new Spark(X - orgX + 74, Y - orgY + 36 + level.random.nextInt(20), 4, 0, room));
|
||||||
charge -= 2;
|
charge -= 2;
|
||||||
}
|
}
|
||||||
if (bottomThruster)
|
if (bottomThruster) {
|
||||||
{
|
|
||||||
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 64, 0, 4, room));
|
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 64, 0, 4, room));
|
||||||
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 64, 0, 4, room));
|
level.sparks.addElement(new Spark(X - orgX + 32 + level.random.nextInt(24), Y - orgY + 64, 0, 4, room));
|
||||||
charge -= 2;
|
charge -= 2;
|
||||||
}
|
}
|
||||||
if (leftThruster)
|
if (leftThruster) {
|
||||||
{
|
|
||||||
level.sparks.addElement(new Spark(X - orgX + 14, Y - orgY + 36 + level.random.nextInt(20), -4, 0, room));
|
level.sparks.addElement(new Spark(X - orgX + 14, Y - orgY + 36 + level.random.nextInt(20), -4, 0, room));
|
||||||
level.sparks.addElement(new Spark(X - orgX + 14, Y - orgY + 36 + level.random.nextInt(20), -4, 0, room));
|
level.sparks.addElement(new Spark(X - orgX + 14, Y - orgY + 36 + level.random.nextInt(20), -4, 0, room));
|
||||||
charge -= 2;
|
charge -= 2;
|
||||||
}
|
}
|
||||||
charge--;
|
charge--;
|
||||||
if (charge<0) charge=0;
|
if (charge < 0) {
|
||||||
|
charge = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Draw Antenna sparks around Broadcasting Antenna
|
// Draw Antenna sparks around Broadcasting Antenna
|
||||||
if (broadcasting && level.electricity)
|
if (broadcasting && level.electricity) {
|
||||||
{
|
|
||||||
Dimension d = GetXY();
|
Dimension d = GetXY();
|
||||||
level.sparks.addElement(new Spark(d.width - orgX + 34, d.height - orgY + 10,
|
level.sparks.addElement(new Spark(d.width - orgX + 34, d.height - orgY + 10,
|
||||||
level.random.nextInt(9) - 4,
|
level.random.nextInt(9) - 4,
|
||||||
@@ -353,20 +344,21 @@ public void Animate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sounds
|
// Make sounds
|
||||||
if (topBumper)
|
if (topBumper && !oldTopBumper) {
|
||||||
if (oldTopBumper != topBumper)
|
|
||||||
level.PlaySound(room, Level.BUMPSOUND);
|
level.PlaySound(room, Level.BUMPSOUND);
|
||||||
if (bottomBumper)
|
}
|
||||||
if (oldBottomBumper != bottomBumper)
|
if (bottomBumper && !oldBottomBumper) {
|
||||||
level.PlaySound(room, Level.BUMPSOUND);
|
level.PlaySound(room, Level.BUMPSOUND);
|
||||||
if (rightBumper)
|
}
|
||||||
if (oldRightBumper != rightBumper)
|
if (rightBumper && !oldRightBumper) {
|
||||||
level.PlaySound(room, Level.BUMPSOUND);
|
level.PlaySound(room, Level.BUMPSOUND);
|
||||||
if (leftBumper)
|
}
|
||||||
if (oldLeftBumper != leftBumper)
|
if (leftBumper && !oldLeftBumper) {
|
||||||
level.PlaySound(room, Level.BUMPSOUND);
|
level.PlaySound(room, Level.BUMPSOUND);
|
||||||
if (broadcasting && level.electricity)
|
}
|
||||||
|
if (broadcasting && level.electricity) {
|
||||||
level.PlaySound(room, Level.BEEPSOUND);
|
level.PlaySound(room, Level.BEEPSOUND);
|
||||||
|
}
|
||||||
oldTopBumper = topBumper;
|
oldTopBumper = topBumper;
|
||||||
oldBottomBumper = bottomBumper;
|
oldBottomBumper = bottomBumper;
|
||||||
oldRightBumper = rightBumper;
|
oldRightBumper = rightBumper;
|
||||||
@@ -374,16 +366,13 @@ public void Animate()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
// Paint background
|
// Paint background
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -396,40 +385,49 @@ public void Decorate()
|
|||||||
g.drawImage(images[0].getImage(), 0, 0, level);
|
g.drawImage(images[0].getImage(), 0, 0, level);
|
||||||
|
|
||||||
// Draw Bumpers
|
// Draw Bumpers
|
||||||
if (topBumper)
|
if (topBumper) {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
|
}
|
||||||
g.fillRect(32, 24, 22, 2);
|
g.fillRect(32, 24, 22, 2);
|
||||||
|
|
||||||
if (bottomBumper)
|
if (bottomBumper) {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
|
}
|
||||||
g.fillRect(32, 66, 22, 2);
|
g.fillRect(32, 66, 22, 2);
|
||||||
|
|
||||||
if (leftBumper)
|
if (leftBumper) {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
|
}
|
||||||
g.fillRect(12, 36, 4, 20);
|
g.fillRect(12, 36, 4, 20);
|
||||||
|
|
||||||
if (rightBumper)
|
if (rightBumper) {
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
|
}
|
||||||
g.fillRect(70, 36, 4, 20);
|
g.fillRect(70, 36, 4, 20);
|
||||||
|
|
||||||
// Draw Antenna
|
// Draw Antenna
|
||||||
if (antenna)
|
if (antenna) {
|
||||||
g.drawImage(images[6].getImage(), 0, 0, level);
|
g.drawImage(images[6].getImage(), 0, 0, level);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
g.drawImage(images[5].getImage(), 0, 0, level);
|
g.drawImage(images[5].getImage(), 0, 0, level);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw Grabber
|
// Draw Grabber
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
switch (grabber)
|
switch (grabber) {
|
||||||
{
|
|
||||||
case Port.ROT_UP:
|
case Port.ROT_UP:
|
||||||
g.drawImage(images[1].getImage(), 0, 0, level);
|
g.drawImage(images[1].getImage(), 0, 0, level);
|
||||||
break;
|
break;
|
||||||
@@ -446,41 +444,32 @@ public void Decorate()
|
|||||||
|
|
||||||
// Draw Periscope
|
// Draw Periscope
|
||||||
// if (periscope)
|
// if (periscope)
|
||||||
if (level.currentViewer == this)
|
if (level.currentViewer == this) {
|
||||||
{
|
|
||||||
periscopeAnimation++;
|
periscopeAnimation++;
|
||||||
if (periscopeAnimation == 32) periscopeAnimation =0;
|
if (periscopeAnimation == 32) {
|
||||||
if (periscopeAnimation <8)
|
periscopeAnimation = 0;
|
||||||
|
}
|
||||||
|
if (periscopeAnimation < 8) {
|
||||||
g.drawImage(images[7].getImage(), 0, 0, level);
|
g.drawImage(images[7].getImage(), 0, 0, level);
|
||||||
|
}
|
||||||
if ((periscopeAnimation >= 8 && periscopeAnimation < 16)
|
if ((periscopeAnimation >= 8 && periscopeAnimation < 16)
|
||||||
|| periscopeAnimation >=24)
|
|| periscopeAnimation >= 24) {
|
||||||
g.drawImage(images[8].getImage(), 0, 0, level);
|
g.drawImage(images[8].getImage(), 0, 0, level);
|
||||||
if (periscopeAnimation >=16 && periscopeAnimation <24)
|
}
|
||||||
|
if (periscopeAnimation >= 16 && periscopeAnimation < 24) {
|
||||||
g.drawImage(images[9].getImage(), 0, 0, level);
|
g.drawImage(images[9].getImage(), 0, 0, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
return !item.getClass().toString().endsWith("Robot") && super.CanBePickedUp(item);
|
||||||
if (item.getClass().toString().endsWith("Robot"))
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return super.CanBePickedUp(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Erase()
|
public void Erase() {
|
||||||
{
|
|
||||||
super.Erase();
|
super.Erase();
|
||||||
devices = null;
|
devices = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,25 +11,25 @@ import javax.swing.ImageIcon;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class Ghost extends Item
|
public class Ghost extends Item {
|
||||||
{
|
private int animationState = 0; // 0=Right, 1=Down, 2=Left, 3=Up
|
||||||
int animationState = 0; // 0=Right, 1=Down, 2=Left, 3=Up
|
|
||||||
// x values are 42, 154, 266, 378
|
// x values are 42, 154, 266, 378
|
||||||
// y values are 58, 186, 314
|
// y values are 58, 186, 314
|
||||||
|
|
||||||
transient boolean searched=false;
|
private transient boolean searched = false;
|
||||||
transient Item robot[];
|
private transient Item[] robot;
|
||||||
|
|
||||||
public Ghost(int X, int Y, Room r)
|
public Ghost(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width = 28; height = 32;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 32;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
robot = new Item[4];
|
robot = new Item[4];
|
||||||
icons = new ImageIcon[4];
|
icons = new ImageIcon[4];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -37,14 +37,11 @@ public void GenerateIcons()
|
|||||||
icons[2] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[2] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[3] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[3] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
for (int a=0; a<4; a++)
|
for (int a = 0; a < 4; a++) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
g = icons[a].getImage().getGraphics();
|
g = icons[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -59,8 +56,7 @@ public void GenerateIcons()
|
|||||||
g.fillOval(4, 8, 8, 8);
|
g.fillOval(4, 8, 8, 8);
|
||||||
g.fillOval(16, 8, 8, 8);
|
g.fillOval(16, 8, 8, 8);
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
switch(a)
|
switch (a) {
|
||||||
{
|
|
||||||
case 0: // Right
|
case 0: // Right
|
||||||
g.fillOval(9, 10, 4, 4);
|
g.fillOval(9, 10, 4, 4);
|
||||||
g.fillOval(21, 10, 4, 4);
|
g.fillOval(21, 10, 4, 4);
|
||||||
@@ -82,8 +78,7 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
// Positions: There are 4x3=12 "nodes" where the ghost travels to
|
// Positions: There are 4x3=12 "nodes" where the ghost travels to
|
||||||
// and from. Every time the ghost reaches a node position, it looks
|
// and from. Every time the ghost reaches a node position, it looks
|
||||||
// around for any robots in the area. If it sees a robot it then
|
// around for any robots in the area. If it sees a robot it then
|
||||||
@@ -91,14 +86,11 @@ public void Animate()
|
|||||||
// penalty box and drained of energy. If no robot is found it moves
|
// penalty box and drained of energy. If no robot is found it moves
|
||||||
// in a random direction.
|
// in a random direction.
|
||||||
|
|
||||||
if (!searched)
|
if (!searched) {
|
||||||
{
|
|
||||||
int rcounter = 0;
|
int rcounter = 0;
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item item = level.items.elementAt(a);
|
||||||
Item item = (Item) level.items.elementAt(a);
|
if (item instanceof GenericRobot) {
|
||||||
if (item instanceof GenericRobot)
|
|
||||||
{
|
|
||||||
robot[rcounter] = item;
|
robot[rcounter] = item;
|
||||||
rcounter++;
|
rcounter++;
|
||||||
}
|
}
|
||||||
@@ -108,82 +100,87 @@ public void Animate()
|
|||||||
|
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
if (((x == 42) || (x == 154) || (x == 266) || (x == 378))
|
if (((x == 42) || (x == 154) || (x == 266) || (x == 378))
|
||||||
&& ( (y==48) || (y==176) || (y==304)) )
|
&& ((y == 48) || (y == 176) || (y == 304))) {
|
||||||
flag = true;
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (flag)
|
if (flag) {
|
||||||
{
|
|
||||||
boolean decision = false;
|
boolean decision = false;
|
||||||
for (int a=0; a<robot.length; a++)
|
for (Item aRobot : robot) {
|
||||||
{
|
if (aRobot != null) {
|
||||||
if (robot[a] != null)
|
if (aRobot.room == room) {
|
||||||
if (robot[a].room == room)
|
Dimension d = aRobot.GetXY();
|
||||||
{
|
if (d.width < 14 * 28) {
|
||||||
Dimension d = robot[a].GetXY();
|
int dx = (d.width + aRobot.width / 2) - (x + width / 2);
|
||||||
if (d.width < 14*28)
|
int dy = (d.height + aRobot.height / 2) - (y + height / 2);
|
||||||
{
|
if ((Math.abs(dx) < 56) || (Math.abs(dy) < 64)) {
|
||||||
int dx = (d.width + robot[a].width/2) - (x+width/2);
|
|
||||||
int dy = (d.height + robot[a].height/2) - (y+height/2);
|
|
||||||
if ((Math.abs(dx)<56) || (Math.abs(dy)<64))
|
|
||||||
{
|
|
||||||
decision = true;
|
decision = true;
|
||||||
if (Math.abs(dx)<56)
|
if (Math.abs(dx) < 56) {
|
||||||
{
|
if (dy > 0) {
|
||||||
if (dy>0)
|
|
||||||
animationState = 1;
|
animationState = 1;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
animationState = 3;
|
animationState = 3;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
if (dx>0)
|
if (dx > 0) {
|
||||||
animationState = 0;
|
animationState = 0;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
animationState = 2;
|
animationState = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!decision)
|
}
|
||||||
{
|
}
|
||||||
|
if (!decision) {
|
||||||
boolean good;
|
boolean good;
|
||||||
int backwards = (animationState + 2) % 4;
|
int backwards = (animationState + 2) % 4;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
good = true;
|
good = true;
|
||||||
animationState = level.random.nextInt(4);
|
animationState = level.random.nextInt(4);
|
||||||
if (animationState==0 && x==378) good=false;
|
if (animationState == 0 && x == 378) {
|
||||||
if (animationState==1 && y==304) good=false;
|
good = false;
|
||||||
if (animationState==2 && x== 42) good=false;
|
}
|
||||||
if (animationState==3 && y== 48) good=false;
|
if (animationState == 1 && y == 304) {
|
||||||
if (animationState==backwards) good=false;
|
good = false;
|
||||||
|
}
|
||||||
|
if (animationState == 2 && x == 42) {
|
||||||
|
good = false;
|
||||||
|
}
|
||||||
|
if (animationState == 3 && y == 48) {
|
||||||
|
good = false;
|
||||||
|
}
|
||||||
|
if (animationState == backwards) {
|
||||||
|
good = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (!good);
|
while (!good);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (animationState)
|
switch (animationState) {
|
||||||
{
|
|
||||||
case 0: // Right
|
case 0: // Right
|
||||||
MoveRight(4);
|
moveRight(4);
|
||||||
break;
|
break;
|
||||||
case 1: // Down
|
case 1: // Down
|
||||||
MoveDown(4);
|
moveDown(4);
|
||||||
break;
|
break;
|
||||||
case 2: // Left
|
case 2: // Left
|
||||||
MoveLeft(4);
|
moveLeft(4);
|
||||||
break;
|
break;
|
||||||
case 3: // Up
|
case 3: // Up
|
||||||
MoveUp(4);
|
moveUp(4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentIcon = icons[animationState].getImage();
|
currentIcon = icons[animationState].getImage();
|
||||||
|
|
||||||
for (int a=0; a<4; a++)
|
for (int a = 0; a < 4; a++) {
|
||||||
if (robot[a] != null)
|
if (robot[a] != null) {
|
||||||
if (Overlaps(robot[a]))
|
if (Overlaps(robot[a])) {
|
||||||
{
|
|
||||||
robot[a].charge = 0;
|
robot[a].charge = 0;
|
||||||
level.PlaySound(room, Level.DISCHARGESOUND);
|
level.PlaySound(room, Level.DISCHARGESOUND);
|
||||||
robot[a].x = 16 * 28 + 14;
|
robot[a].x = 16 * 28 + 14;
|
||||||
@@ -191,3 +188,5 @@ public void Animate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,37 +1,32 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Handle extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class Handle extends Item {
|
||||||
// Handle used to pull sliding wall
|
// Handle used to pull sliding wall
|
||||||
|
|
||||||
public Handle(int X, int Y, Room r)
|
public Handle(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=12;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 12;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -46,38 +41,33 @@ public class Handle extends Item
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
if (item != level.player) {
|
||||||
if (item != level.player) return false;
|
return false;
|
||||||
|
}
|
||||||
PicksUp(item);
|
PicksUp(item);
|
||||||
level.player = this;
|
level.player = this;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
public boolean KeyUp(KeyEvent e) {
|
||||||
{
|
if (e.getKeyCode() == e.VK_RIGHT) {
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
if (x < 15 * 28) {
|
||||||
{
|
|
||||||
if (x<15*28)
|
|
||||||
{
|
|
||||||
room.SetMaterial(x / 28 - 12, 4, 0);
|
room.SetMaterial(x / 28 - 12, 4, 0);
|
||||||
MoveRight(28);
|
moveRight(28);
|
||||||
room.SetMaterial(x / 28 - 1, 4, 8);
|
room.SetMaterial(x / 28 - 1, 4, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
if (e.getKeyCode() == e.VK_LEFT) {
|
||||||
{
|
if (x > 13 * 28) {
|
||||||
if (x>13*28)
|
|
||||||
{
|
|
||||||
room.SetMaterial(x / 28 - 13, 4, 8);
|
room.SetMaterial(x / 28 - 13, 4, 8);
|
||||||
room.SetMaterial(x / 28 - 1, 4, 0);
|
room.SetMaterial(x / 28 - 1, 4, 0);
|
||||||
MoveLeft(28);
|
moveLeft(28);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getKeyCode() == e.VK_SPACE)
|
if (e.getKeyCode() == e.VK_SPACE) {
|
||||||
{
|
|
||||||
level.player = carrying;
|
level.player = carrying;
|
||||||
Drops();
|
Drops();
|
||||||
room.SetMaterial(1, 4, 8);
|
room.SetMaterial(1, 4, 8);
|
||||||
|
|||||||
@@ -9,30 +9,28 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Hexagon extends Item
|
public class Hexagon extends Item {
|
||||||
{
|
private Color color;
|
||||||
Color color;
|
|
||||||
|
|
||||||
public Hexagon(int X, int Y, Room r, Color c)
|
public Hexagon(int X, int Y, Room r, Color c) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=28;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 28;
|
||||||
color = c;
|
color = c;
|
||||||
editable = true;
|
editable = true;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,17 @@ import javax.swing.JPanel;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class HiddenCamera extends Item
|
public class HiddenCamera extends Item {
|
||||||
{
|
public HiddenCamera(Room r) {
|
||||||
public HiddenCamera(Room r)
|
x = 0;
|
||||||
{
|
y = 0;
|
||||||
x=0; y=0;
|
|
||||||
room = r;
|
room = r;
|
||||||
width=0; height=0;
|
width = 0;
|
||||||
|
height = 0;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g, JPanel jp)
|
public void Draw(Graphics g, JPanel jp) {
|
||||||
{}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
|
|
||||||
public class Initializer extends Item
|
public class Initializer extends Item {
|
||||||
{
|
protected Initializer() {
|
||||||
public Initializer()
|
width = 0;
|
||||||
{
|
height = 0;
|
||||||
width=0; height=0; x=0; y=0; room=null;
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
room = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init() {}
|
public void Init() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -9,30 +9,29 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Key extends Item
|
public class Key extends Item {
|
||||||
{
|
|
||||||
// Generic Key, defined by it's color.
|
// Generic Key, defined by it's color.
|
||||||
|
|
||||||
public Color color;
|
public Color color;
|
||||||
|
|
||||||
public Key(int X, int Y, Room r, Color c)
|
public Key(int X, int Y, Room r, Color c) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r; color = c;
|
y = Y;
|
||||||
width=26; height=8;
|
room = r;
|
||||||
|
color = c;
|
||||||
|
width = 26;
|
||||||
|
height = 8;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,26 +9,24 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Magnet extends Item
|
public class Magnet extends Item {
|
||||||
{
|
public Magnet(int X, int Y, Room r) {
|
||||||
public Magnet(int X, int Y, Room r)
|
x = X;
|
||||||
{
|
y = Y;
|
||||||
x=X; y=Y; room=r;
|
room = r;
|
||||||
width=28; height=20;
|
width = 28;
|
||||||
|
height = 20;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ import com.droidquest.devices.Bumper;
|
|||||||
import com.droidquest.devices.Grabber;
|
import com.droidquest.devices.Grabber;
|
||||||
import com.droidquest.devices.Thruster;
|
import com.droidquest.devices.Thruster;
|
||||||
|
|
||||||
public class MasterRobot extends GenericRobot
|
public class MasterRobot extends GenericRobot {
|
||||||
{
|
|
||||||
private int scan;
|
private int scan;
|
||||||
|
|
||||||
public MasterRobot(int X, int Y, Room r)
|
public MasterRobot(int X, int Y, Room r) {
|
||||||
{
|
|
||||||
super(X, Y, r, Color.blue);
|
super(X, Y, r, Color.blue);
|
||||||
scan = 0;
|
scan = 0;
|
||||||
Animate();
|
Animate();
|
||||||
@@ -29,21 +27,19 @@ public MasterRobot(int X, int Y, Room r)
|
|||||||
devices[7] = new Bumper(28, 134, InternalRoom, Port.ROT_LEFT, Color.white);
|
devices[7] = new Bumper(28, 134, InternalRoom, Port.ROT_LEFT, Color.white);
|
||||||
devices[8] = new Antenna(64, 70, InternalRoom, Color.white);
|
devices[8] = new Antenna(64, 70, InternalRoom, Color.white);
|
||||||
devices[9] = new Grabber(126, 44, InternalRoom, Color.white);
|
devices[9] = new Grabber(126, 44, InternalRoom, Color.white);
|
||||||
for (int a=0; a<10; a++)
|
for (int a = 0; a < 10; a++) {
|
||||||
level.items.addElement(devices[a]);
|
level.items.addElement(devices[a]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,8 +47,7 @@ public void Decorate()
|
|||||||
g.fillRect(orgX + 16, orgY + 12, 26, 20);
|
g.fillRect(orgX + 16, orgY + 12, 26, 20);
|
||||||
g.setColor(new Color(255, 128, 0));
|
g.setColor(new Color(255, 128, 0));
|
||||||
|
|
||||||
switch(scan)
|
switch (scan) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
g.fillRect(orgX + 28, orgY + 18, 2, 8);
|
g.fillRect(orgX + 28, orgY + 18, 2, 8);
|
||||||
scan = 1;
|
scan = 1;
|
||||||
|
|||||||
@@ -10,38 +10,35 @@ import javax.swing.ImageIcon;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.decorations.TextBox;
|
import com.droidquest.decorations.TextBox;
|
||||||
|
|
||||||
public class MazeControl extends Item
|
public class MazeControl extends Item {
|
||||||
{
|
|
||||||
static int mazeWidth = 4;
|
static int mazeWidth = 4;
|
||||||
static int mazeHeight = 2;
|
static int mazeHeight = 2;
|
||||||
int direction;
|
private int direction;
|
||||||
public static final int DIR_UP = 0;
|
public static final int DIR_UP = 0;
|
||||||
public static final int DIR_RIGHT = 1;
|
public static final int DIR_RIGHT = 1;
|
||||||
public static final int DIR_DOWN = 2;
|
public static final int DIR_DOWN = 2;
|
||||||
public static final int DIR_LEFT = 3;
|
public static final int DIR_LEFT = 3;
|
||||||
|
|
||||||
public MazeControl(int X, int Y, Room r, int dir)
|
public MazeControl(int X, int Y, Room r, int dir) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
room = r;
|
room = r;
|
||||||
width=26; height=26;
|
width = 26;
|
||||||
|
height = 26;
|
||||||
direction = dir;
|
direction = dir;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
Graphics2D g2;
|
Graphics2D g2;
|
||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -49,8 +46,7 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
switch(direction)
|
switch (direction) {
|
||||||
{
|
|
||||||
case DIR_UP:
|
case DIR_UP:
|
||||||
g.fillRect(12, 0, 2, 2);
|
g.fillRect(12, 0, 2, 2);
|
||||||
g.fillRect(10, 2, 6, 2);
|
g.fillRect(10, 2, 6, 2);
|
||||||
@@ -95,26 +91,28 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
switch (direction) {
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case DIR_UP:
|
case DIR_UP:
|
||||||
if (mazeHeight==1) return false;
|
if (mazeHeight == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mazeHeight--;
|
mazeHeight--;
|
||||||
break;
|
break;
|
||||||
case DIR_DOWN:
|
case DIR_DOWN:
|
||||||
mazeHeight++;
|
mazeHeight++;
|
||||||
break;
|
break;
|
||||||
case DIR_LEFT:
|
case DIR_LEFT:
|
||||||
if (mazeWidth==1) return false;
|
if (mazeWidth == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mazeWidth--;
|
mazeWidth--;
|
||||||
break;
|
break;
|
||||||
case DIR_RIGHT:
|
case DIR_RIGHT:
|
||||||
mazeWidth++;
|
mazeWidth++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TextBox tb = (TextBox) room.textBoxes.elementAt(1);
|
TextBox tb = room.textBoxes.elementAt(1);
|
||||||
tb.textString = mazeWidth + "x" + mazeHeight;
|
tb.textString = mazeWidth + "x" + mazeHeight;
|
||||||
tb.x = (560 - 12 * tb.textString.length()) / 2;
|
tb.x = (560 - 12 * tb.textString.length()) / 2;
|
||||||
|
|
||||||
|
|||||||
@@ -1,99 +1,92 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class MazeCreator extends Button
|
import java.awt.*;
|
||||||
{
|
|
||||||
public MazeCreator(int X, int Y, Room r)
|
public class MazeCreator extends Button {
|
||||||
{
|
public MazeCreator(int X, int Y, Room r) {
|
||||||
super(X, Y, r, Color.blue);
|
super(X, Y, r, Color.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
|
||||||
Room mazeEntrance = null;
|
Room mazeEntrance = null;
|
||||||
for (int a=0; a<level.rooms.size(); a++)
|
for (int a = 0; a < level.rooms.size(); a++) {
|
||||||
{
|
Room r = level.rooms.elementAt(a);
|
||||||
Room r = (Room) level.rooms.elementAt(a);
|
if (r.downRoom != null) {
|
||||||
if (r.downRoom != null)
|
if (!r.editable && r.downRoom.editable) {
|
||||||
if (!r.editable && r.downRoom.editable)
|
|
||||||
mazeEntrance = r;
|
mazeEntrance = r;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (int a=0; a<level.items.size(); a++)
|
|
||||||
{
|
|
||||||
Item i = (Item) level.items.elementAt(a);
|
|
||||||
if (i.room != null)
|
|
||||||
if (i.room.editable)
|
|
||||||
i.room = room;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a=0; a<level.rooms.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item i = level.items.elementAt(a);
|
||||||
Room r = (Room) level.rooms.elementAt(a);
|
if (i.room != null) {
|
||||||
if (r.editable)
|
if (i.room.editable) {
|
||||||
{
|
i.room = room;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int a = 0; a < level.rooms.size(); a++) {
|
||||||
|
Room r = level.rooms.elementAt(a);
|
||||||
|
if (r.editable) {
|
||||||
level.rooms.removeElement(r);
|
level.rooms.removeElement(r);
|
||||||
a--;
|
a--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(mazeEntrance != null) {
|
||||||
mazeEntrance.downRoom = null;
|
mazeEntrance.downRoom = null;
|
||||||
|
}
|
||||||
|
|
||||||
for (int Y=0; Y<MazeControl.mazeHeight; Y++)
|
for (int Y = 0; Y < MazeControl.mazeHeight; Y++) {
|
||||||
for (int X=0; X<MazeControl.mazeWidth; X++)
|
for (int X = 0; X < MazeControl.mazeWidth; X++) {
|
||||||
{
|
|
||||||
Room newRoom = new Room();
|
Room newRoom = new Room();
|
||||||
newRoom.editable = true;
|
newRoom.editable = true;
|
||||||
newRoom.GenerateArray();
|
newRoom.GenerateArray();
|
||||||
level.rooms.addElement(newRoom);
|
level.rooms.addElement(newRoom);
|
||||||
if (Y==0)
|
if (Y == 0) {
|
||||||
{
|
for (int a = 0; a < 20; a++) {
|
||||||
for (int a=0; a<20; a++)
|
|
||||||
newRoom.SetMaterial(a, 0, 3);
|
newRoom.SetMaterial(a, 0, 3);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
Room UpRoom = (Room) level.rooms.elementAt(level.rooms.size()-1-MazeControl.mazeWidth);
|
Room UpRoom = level.rooms.elementAt(level.rooms.size() - 1 - MazeControl.mazeWidth);
|
||||||
UpRoom.downRoom = newRoom;
|
UpRoom.downRoom = newRoom;
|
||||||
newRoom.upRoom = UpRoom;
|
newRoom.upRoom = UpRoom;
|
||||||
}
|
}
|
||||||
if (Y==MazeControl.mazeHeight-1)
|
if (Y == MazeControl.mazeHeight - 1) {
|
||||||
{
|
for (int a = 0; a < 20; a++) {
|
||||||
for (int a=0; a<20; a++)
|
|
||||||
newRoom.SetMaterial(a, 11, 3);
|
newRoom.SetMaterial(a, 11, 3);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (X==0)
|
if (X == 0) {
|
||||||
{
|
for (int a = 0; a < 12; a++) {
|
||||||
for (int a=0; a<12; a++)
|
|
||||||
newRoom.SetMaterial(0, a, 3);
|
newRoom.SetMaterial(0, a, 3);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
Room LeftRoom = (Room) level.rooms.elementAt(level.rooms.size()-2);
|
Room LeftRoom = level.rooms.elementAt(level.rooms.size() - 2);
|
||||||
LeftRoom.rightRoom = newRoom;
|
LeftRoom.rightRoom = newRoom;
|
||||||
newRoom.leftRoom = LeftRoom;
|
newRoom.leftRoom = LeftRoom;
|
||||||
}
|
}
|
||||||
if (X==MazeControl.mazeWidth-1)
|
if (X == MazeControl.mazeWidth - 1) {
|
||||||
{
|
for (int a = 0; a < 12; a++) {
|
||||||
for (int a=0; a<12; a++)
|
|
||||||
newRoom.SetMaterial(19, a, 3);
|
newRoom.SetMaterial(19, a, 3);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (X==0 && Y==0)
|
if (X == 0 && Y == 0) {
|
||||||
{
|
if(mazeEntrance != null) {
|
||||||
mazeEntrance.downRoom = newRoom;
|
mazeEntrance.downRoom = newRoom;
|
||||||
|
}
|
||||||
newRoom.upRoom = mazeEntrance;
|
newRoom.upRoom = mazeEntrance;
|
||||||
newRoom.SetMaterial(1, 0, 0);
|
newRoom.SetMaterial(1, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,33 +3,23 @@ package com.droidquest.items;
|
|||||||
import com.droidquest.materials.Switch;
|
import com.droidquest.materials.Switch;
|
||||||
|
|
||||||
|
|
||||||
public class MazeLock extends Switch
|
public class MazeLock extends Switch {
|
||||||
{
|
private transient static Item paintbrush;
|
||||||
transient static Item paintbrush;
|
|
||||||
|
|
||||||
public MazeLock()
|
public MazeLock() {
|
||||||
{
|
|
||||||
super(Switch.ROT_DOWN);
|
super(Switch.ROT_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TouchedByItem(Item item)
|
public void TouchedByItem(Item item) {
|
||||||
{
|
if (paintbrush == null) {
|
||||||
if (paintbrush==null)
|
|
||||||
paintbrush = level.paintbrush;
|
paintbrush = level.paintbrush;
|
||||||
|
}
|
||||||
|
|
||||||
if (!value)
|
if (!value) {
|
||||||
{
|
|
||||||
level.paintbrush = null;
|
level.paintbrush = null;
|
||||||
value = true;
|
value = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// for (int a=0; a<level.items.size(); a++)
|
|
||||||
// {
|
|
||||||
// Item i = (Item) level.items.elementAt(a);
|
|
||||||
// if (i instanceof PaintBrush)
|
|
||||||
// level.paintbrush = i;
|
|
||||||
// }
|
|
||||||
level.paintbrush = paintbrush;
|
level.paintbrush = paintbrush;
|
||||||
value = false;
|
value = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,30 +9,28 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class NotAButton extends Item
|
public class NotAButton extends Item {
|
||||||
{
|
|
||||||
int animationState = 0;
|
int animationState = 0;
|
||||||
transient EnergyButton eb=null;
|
private transient EnergyButton eb = null;
|
||||||
|
|
||||||
public NotAButton(int X, int Y, Room r)
|
public NotAButton(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=26;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 26;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -53,43 +51,42 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (eb == null) {
|
||||||
if (eb==null)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
Item item = level.items.elementAt(a);
|
||||||
{
|
if (item instanceof EnergyButton) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if(item instanceof EnergyButton)
|
|
||||||
{
|
|
||||||
eb = (EnergyButton) item;
|
eb = (EnergyButton) item;
|
||||||
eb.nb = this;
|
eb.nb = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (animationState<51)
|
if (animationState < 51) {
|
||||||
{
|
|
||||||
animationState++;
|
animationState++;
|
||||||
int dx = level.random.nextInt(11) - 5;
|
int dx = level.random.nextInt(11) - 5;
|
||||||
int dy = level.random.nextInt(11) - 5;
|
int dy = level.random.nextInt(11) - 5;
|
||||||
if (x+dx>28 && x+dx<(19*28))
|
if (x + dx > 28 && x + dx < (19 * 28)) {
|
||||||
x += dx;
|
x += dx;
|
||||||
if (y+dy>32 && y+dy<(11*32))
|
}
|
||||||
|
if (y + dy > 32 && y + dy < (11 * 32)) {
|
||||||
y += dy;
|
y += dy;
|
||||||
if (animationState==1)
|
}
|
||||||
{
|
if (animationState == 1) {
|
||||||
eb.x=x; eb.y=y;
|
eb.x = x;
|
||||||
|
eb.y = y;
|
||||||
eb.room = room;
|
eb.room = room;
|
||||||
room = null;
|
room = null;
|
||||||
}
|
}
|
||||||
if (animationState==2)
|
if (animationState == 2) {
|
||||||
{
|
|
||||||
room = eb.room;
|
room = eb.room;
|
||||||
eb.room = null;
|
eb.room = null;
|
||||||
}
|
}
|
||||||
if (animationState==50)
|
if (animationState == 50) {
|
||||||
animationState = 0;
|
animationState = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ import com.droidquest.devices.Bumper;
|
|||||||
import com.droidquest.devices.Grabber;
|
import com.droidquest.devices.Grabber;
|
||||||
import com.droidquest.devices.Thruster;
|
import com.droidquest.devices.Thruster;
|
||||||
|
|
||||||
public class OrangeRobot extends GenericRobot
|
public class OrangeRobot extends GenericRobot {
|
||||||
{
|
public OrangeRobot(int X, int Y, Room r) {
|
||||||
public OrangeRobot(int X, int Y, Room r)
|
|
||||||
{
|
|
||||||
super(X, Y, r, new Color(255, 128, 0));
|
super(X, Y, r, new Color(255, 128, 0));
|
||||||
Animate();
|
Animate();
|
||||||
devices[0] = new Thruster(176, 16, InternalRoom, Port.ROT_UP, Color.white);
|
devices[0] = new Thruster(176, 16, InternalRoom, Port.ROT_UP, Color.white);
|
||||||
@@ -26,22 +24,20 @@ public OrangeRobot(int X, int Y, Room r)
|
|||||||
devices[7] = new Bumper(28, 134, InternalRoom, Port.ROT_LEFT, Color.white);
|
devices[7] = new Bumper(28, 134, InternalRoom, Port.ROT_LEFT, Color.white);
|
||||||
devices[8] = new Antenna(64, 70, InternalRoom, Color.white);
|
devices[8] = new Antenna(64, 70, InternalRoom, Color.white);
|
||||||
devices[9] = new Grabber(126, 44, InternalRoom, Color.white);
|
devices[9] = new Grabber(126, 44, InternalRoom, Color.white);
|
||||||
for (int a=0; a<10; a++)
|
for (int a = 0; a < 10; a++) {
|
||||||
level.items.addElement(devices[a]);
|
level.items.addElement(devices[a]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Decorate()
|
public void Decorate() {
|
||||||
{
|
|
||||||
super.Decorate();
|
super.Decorate();
|
||||||
Graphics g;
|
Graphics g;
|
||||||
int cx, cy, cc;
|
int cx, cy, cc;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -49,26 +45,31 @@ public void Decorate()
|
|||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
g.fillRect(22, 36, 42, 20);
|
g.fillRect(22, 36, 42, 20);
|
||||||
|
|
||||||
for (int a=0; a<20; a++)
|
for (int a = 0; a < 20; a++) {
|
||||||
{
|
|
||||||
cx = level.random.nextInt(41) + 22;
|
cx = level.random.nextInt(41) + 22;
|
||||||
cy = level.random.nextInt(19) + 36;
|
cy = level.random.nextInt(19) + 36;
|
||||||
cc = level.random.nextInt(7);
|
cc = level.random.nextInt(7);
|
||||||
switch (cc)
|
switch (cc) {
|
||||||
{
|
case 0:
|
||||||
case 0: g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
break;
|
break;
|
||||||
case 1: g.setColor(Color.red);
|
case 1:
|
||||||
|
g.setColor(Color.red);
|
||||||
break;
|
break;
|
||||||
case 2: g.setColor(new Color(255,128,0));
|
case 2:
|
||||||
|
g.setColor(new Color(255, 128, 0));
|
||||||
break;
|
break;
|
||||||
case 3: g.setColor(Color.yellow);
|
case 3:
|
||||||
|
g.setColor(Color.yellow);
|
||||||
break;
|
break;
|
||||||
case 4: g.setColor(Color.green);
|
case 4:
|
||||||
|
g.setColor(Color.green);
|
||||||
break;
|
break;
|
||||||
case 5: g.setColor(Color.blue);
|
case 5:
|
||||||
|
g.setColor(Color.blue);
|
||||||
break;
|
break;
|
||||||
case 6: g.setColor(Color.magenta);
|
case 6:
|
||||||
|
g.setColor(Color.magenta);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g.fillRect(cx, cy, 2, 2);
|
g.fillRect(cx, cy, 2, 2);
|
||||||
|
|||||||
@@ -11,26 +11,24 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.devices.Prototype16Chip;
|
import com.droidquest.devices.Prototype16Chip;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class PC16Button extends Item
|
public class PC16Button extends Item {
|
||||||
{
|
public PC16Button(int X, int Y, Room r) {
|
||||||
public PC16Button(int X, int Y, Room r)
|
x = X;
|
||||||
{
|
y = Y;
|
||||||
x=X; y=Y; room=r;
|
room = r;
|
||||||
width=28; height=26;
|
width = 28;
|
||||||
|
height = 26;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,8 +49,7 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
|
||||||
Prototype16Chip newPC = new Prototype16Chip(228, 160, room);
|
Prototype16Chip newPC = new Prototype16Chip(228, 160, room);
|
||||||
level.items.addElement(newPC);
|
level.items.addElement(newPC);
|
||||||
level.PlaySound(room, Level.CHARGESOUND);
|
level.PlaySound(room, Level.CHARGESOUND);
|
||||||
|
|||||||
@@ -11,26 +11,24 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.devices.Prototype32Chip;
|
import com.droidquest.devices.Prototype32Chip;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class PC32Button extends Item
|
public class PC32Button extends Item {
|
||||||
{
|
public PC32Button(int X, int Y, Room r) {
|
||||||
public PC32Button(int X, int Y, Room r)
|
x = X;
|
||||||
{
|
y = Y;
|
||||||
x=X; y=Y; room=r;
|
room = r;
|
||||||
width=28; height=26;
|
width = 28;
|
||||||
|
height = 26;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,8 +49,7 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
|
||||||
Prototype32Chip newPC = new Prototype32Chip(228, 160, room);
|
Prototype32Chip newPC = new Prototype32Chip(228, 160, room);
|
||||||
level.items.addElement(newPC);
|
level.items.addElement(newPC);
|
||||||
level.PlaySound(room, Level.CHARGESOUND);
|
level.PlaySound(room, Level.CHARGESOUND);
|
||||||
|
|||||||
@@ -11,26 +11,24 @@ import com.droidquest.Room;
|
|||||||
import com.droidquest.devices.PrototypeChip;
|
import com.droidquest.devices.PrototypeChip;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class PCButton extends Item
|
public class PCButton extends Item {
|
||||||
{
|
public PCButton(int X, int Y, Room r) {
|
||||||
public PCButton(int X, int Y, Room r)
|
x = X;
|
||||||
{
|
y = Y;
|
||||||
x=X; y=Y; room=r;
|
room = r;
|
||||||
width=28; height=26;
|
width = 28;
|
||||||
|
height = 26;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,8 +49,7 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
|
||||||
PrototypeChip newPC = new PrototypeChip(228, 160, room);
|
PrototypeChip newPC = new PrototypeChip(228, 160, room);
|
||||||
level.items.addElement(newPC);
|
level.items.addElement(newPC);
|
||||||
level.PlaySound(room, Level.CHARGESOUND);
|
level.PlaySound(room, Level.CHARGESOUND);
|
||||||
|
|||||||
@@ -9,37 +9,35 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Pellet extends Item
|
public class Pellet extends Item {
|
||||||
{
|
private transient static int pelletCount = 0;
|
||||||
transient static int pelletCount = 0;
|
private transient boolean counted = false;
|
||||||
transient boolean counted = false;
|
|
||||||
|
|
||||||
public Pellet(int X, int Y, Room r)
|
public Pellet(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room = r;
|
y = Y;
|
||||||
width = 28; height = 28;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 28;
|
||||||
pelletCount++;
|
pelletCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
if (!counted) {
|
||||||
if (!counted)
|
|
||||||
{
|
|
||||||
int index = level.items.indexOf(this);
|
int index = level.items.indexOf(this);
|
||||||
if (!(level.items.elementAt(index-1) instanceof Pellet))
|
if (!(level.items.elementAt(index - 1) instanceof Pellet)) {
|
||||||
pelletCount = 0;
|
pelletCount = 0;
|
||||||
|
}
|
||||||
counted = true;
|
counted = true;
|
||||||
pelletCount++;
|
pelletCount++;
|
||||||
}
|
}
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -52,28 +50,25 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
if (item instanceof GenericRobot) {
|
||||||
if (item instanceof GenericRobot)
|
|
||||||
{
|
|
||||||
level.items.removeElement(this);
|
level.items.removeElement(this);
|
||||||
pelletCount--;
|
pelletCount--;
|
||||||
if (pelletCount==0)
|
if (pelletCount == 0) {
|
||||||
{
|
|
||||||
room.SetMaterial(15, 1, 0);
|
room.SetMaterial(15, 1, 0);
|
||||||
room.SetMaterial(15, 2, 0);
|
room.SetMaterial(15, 2, 0);
|
||||||
room.SetMaterial(15, 5, 0);
|
room.SetMaterial(15, 5, 0);
|
||||||
room.SetMaterial(15, 6, 0);
|
room.SetMaterial(15, 6, 0);
|
||||||
room.SetMaterial(15, 9, 0);
|
room.SetMaterial(15, 9, 0);
|
||||||
room.SetMaterial(15, 10, 0);
|
room.SetMaterial(15, 10, 0);
|
||||||
for (int a=0; a<level.items.size(); a++)
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
{
|
Item i = level.items.elementAt(a);
|
||||||
Item i = (Item) level.items.elementAt(a);
|
if (i instanceof Ghost) {
|
||||||
if (i instanceof Ghost)
|
|
||||||
level.items.removeElement(i);
|
level.items.removeElement(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,29 +10,27 @@ import javax.swing.ImageIcon;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class Polarizer extends Item
|
public class Polarizer extends Item {
|
||||||
{
|
private transient boolean searched = false;
|
||||||
transient boolean searched=false;
|
private transient boolean found = false;
|
||||||
transient boolean found=false;
|
|
||||||
|
|
||||||
public Polarizer(int X, int Y, Room r)
|
public Polarizer(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=24; height=32;
|
room = r;
|
||||||
|
width = 24;
|
||||||
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -53,30 +51,22 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (!searched) {
|
||||||
if (!searched)
|
for(Item item : level.items) {
|
||||||
{
|
|
||||||
for (int a=0; a<level.items.size(); a++)
|
|
||||||
{
|
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (item instanceof StormCloud)
|
|
||||||
{
|
|
||||||
found=true;
|
|
||||||
}
|
|
||||||
searched = true;
|
searched = true;
|
||||||
|
if(item != null && item instanceof StormCloud) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
if (found) {
|
||||||
{
|
if (room.upRoom == room) {
|
||||||
if (room.upRoom == room)
|
for(Item item : level.items) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
if (item != null && item instanceof StormCloud) {
|
||||||
{
|
if (Overlaps(item)) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (item instanceof StormCloud)
|
|
||||||
if (Overlaps(item))
|
|
||||||
{
|
|
||||||
level.PlaySound(room, Level.DISCHARGESOUND);
|
level.PlaySound(room, Level.DISCHARGESOUND);
|
||||||
level.LinkRoomsUpDown(36, 4);
|
level.LinkRoomsUpDown(36, 4);
|
||||||
room.SetMaterial(8, 0, 0);
|
room.SetMaterial(8, 0, 0);
|
||||||
@@ -85,13 +75,16 @@ public void Animate()
|
|||||||
room.SetMaterial(11, 0, 0);
|
room.SetMaterial(11, 0, 0);
|
||||||
item.room = null;
|
item.room = null;
|
||||||
level.items.removeElement(item);
|
level.items.removeElement(item);
|
||||||
if (carriedBy != null)
|
if (carriedBy != null) {
|
||||||
carriedBy.Drops();
|
carriedBy.Drops();
|
||||||
|
}
|
||||||
room = null;
|
room = null;
|
||||||
level.items.removeElement(this);
|
level.items.removeElement(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,23 +9,25 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class PowerSwitch extends Item
|
public class PowerSwitch extends Item {
|
||||||
{
|
|
||||||
// Controls the power in a Generic Robot
|
// Controls the power in a Generic Robot
|
||||||
|
|
||||||
public PowerSwitch(int X, int Y, Room r)
|
public PowerSwitch(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=32;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 32;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
if (((GenericRobot)room.portalItem).thrusterPower)
|
if (((GenericRobot) room.portalItem).thrusterPower) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -34,12 +36,10 @@ public class PowerSwitch extends Item
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// 0 = Off
|
// 0 = Off
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -57,12 +57,10 @@ public class PowerSwitch extends Item
|
|||||||
g.fillRect(20, 28, 8, 4);
|
g.fillRect(20, 28, 8, 4);
|
||||||
|
|
||||||
// 1 = On
|
// 1 = On
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -76,22 +74,26 @@ public class PowerSwitch extends Item
|
|||||||
g.fillRect(8, 26, 12, 6);
|
g.fillRect(8, 26, 12, 6);
|
||||||
g.fillRect(20, 28, 8, 4);
|
g.fillRect(20, 28, 8, 4);
|
||||||
|
|
||||||
if (((GenericRobot)room.portalItem).thrusterPower)
|
if (((GenericRobot) room.portalItem).thrusterPower) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item i)
|
public boolean CanBePickedUp(Item i) {
|
||||||
{
|
if (i != level.player) {
|
||||||
if (i!=level.player)
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
((GenericRobot) room.portalItem).thrusterPower = !((GenericRobot) room.portalItem).thrusterPower;
|
((GenericRobot) room.portalItem).thrusterPower = !((GenericRobot) room.portalItem).thrusterPower;
|
||||||
if (((GenericRobot)room.portalItem).thrusterPower)
|
if (((GenericRobot) room.portalItem).thrusterPower) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Sentry extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class Sentry extends Item {
|
||||||
// Base class for all Sentries.
|
// Base class for all Sentries.
|
||||||
//
|
//
|
||||||
// Either individual Sentries will have different Animate functions, or
|
// Either individual Sentries will have different Animate functions, or
|
||||||
@@ -33,7 +29,7 @@ public class Sentry extends Item
|
|||||||
// pairs of XY coordinates. The first two pairs define an area which
|
// pairs of XY coordinates. The first two pairs define an area which
|
||||||
// triggers the Sentry to pounce. The third pair defines where the
|
// triggers the Sentry to pounce. The third pair defines where the
|
||||||
// sentry will drag the player. This array can have any number of
|
// sentry will drag the player. This array can have any number of
|
||||||
// sextets of numbers. (The total size of the array must be divisable by
|
// sextets of numbers. (The total size of the array must be divisible by
|
||||||
// six). Each block of six numbers defines an area and target the sentry
|
// six). Each block of six numbers defines an area and target the sentry
|
||||||
// guards.
|
// guards.
|
||||||
//
|
//
|
||||||
@@ -44,30 +40,36 @@ public class Sentry extends Item
|
|||||||
int animation = 0; // 0-3, 1 & 3 = icons[1]
|
int animation = 0; // 0-3, 1 & 3 = icons[1]
|
||||||
public int behavior = 0; // 0+ for pacing, until pounce and drag. -1=pin.
|
public int behavior = 0; // 0+ for pacing, until pounce and drag. -1=pin.
|
||||||
public int previousBehavior;
|
public int previousBehavior;
|
||||||
int[] pace; // List of pacing cordinates
|
private int[] pace; // List of pacing coordinates
|
||||||
public int[] protect; // List of areas and targets
|
public int[] protect; // List of areas and targets
|
||||||
int goToX; // Current position pacing towards
|
private int goToX; // Current position pacing towards
|
||||||
int goToY; // ""
|
private int goToY; // ""
|
||||||
int carryToX; // Currently dragging towards
|
private int carryToX; // Currently dragging towards
|
||||||
int carryToY; // ""
|
private int carryToY; // ""
|
||||||
int pounce; // Pouncing behaviour number (pace.length/2)
|
private int pounce; // Pouncing behaviour number (pace.length/2)
|
||||||
int drag; // Dragging behavior number (pounce+1)
|
private int drag; // Dragging behavior number (pounce+1)
|
||||||
boolean smartblock; // Pins robots if they carry the player.
|
private boolean smartblock; // Pins robots if they carry the player.
|
||||||
GenericRobot robot; // Robot to pin
|
private GenericRobot robot; // Robot to pin
|
||||||
|
|
||||||
public Sentry(int X, int Y, Room r)
|
Sentry(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=18; orgY = 30;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 18;
|
||||||
|
orgY = 30;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sentry(int X, int Y, Room r, int[] p1, int[] p2, boolean sb)
|
public Sentry(int X, int Y, Room r, int[] p1, int[] p2, boolean sb) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=18; orgY = 30;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 18;
|
||||||
|
orgY = 30;
|
||||||
pace = p1;
|
pace = p1;
|
||||||
protect = p2;
|
protect = p2;
|
||||||
smartblock = sb;
|
smartblock = sb;
|
||||||
@@ -81,8 +83,7 @@ public class Sentry extends Item
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[3];
|
icons = new ImageIcon[3];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -92,12 +93,10 @@ public class Sentry extends Item
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// 0 = Legs out
|
// 0 = Legs out
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -105,7 +104,9 @@ public class Sentry extends Item
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height + orgY);
|
g2.clearRect(0, 0, width, height + orgY);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
if (smartblock) g.setColor(Color.blue);
|
if (smartblock) {
|
||||||
|
g.setColor(Color.blue);
|
||||||
|
}
|
||||||
g.fillRect(8, 0, 12, 6);
|
g.fillRect(8, 0, 12, 6);
|
||||||
g.fillRect(12, 6, 4, 6);
|
g.fillRect(12, 6, 4, 6);
|
||||||
g.fillRect(8, 12, 12, 24);
|
g.fillRect(8, 12, 12, 24);
|
||||||
@@ -130,12 +131,10 @@ public class Sentry extends Item
|
|||||||
|
|
||||||
|
|
||||||
// 1 = legs mid
|
// 1 = legs mid
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -143,7 +142,9 @@ public class Sentry extends Item
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height + orgY);
|
g2.clearRect(0, 0, width, height + orgY);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
if (smartblock) g.setColor(Color.blue);
|
if (smartblock) {
|
||||||
|
g.setColor(Color.blue);
|
||||||
|
}
|
||||||
g.fillRect(8, 0, 12, 6);
|
g.fillRect(8, 0, 12, 6);
|
||||||
g.fillRect(12, 6, 4, 6);
|
g.fillRect(12, 6, 4, 6);
|
||||||
g.fillRect(8, 12, 12, 28);
|
g.fillRect(8, 12, 12, 28);
|
||||||
@@ -166,12 +167,10 @@ public class Sentry extends Item
|
|||||||
|
|
||||||
|
|
||||||
// 2 = legs in
|
// 2 = legs in
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[2].getImage().getGraphics();
|
g = icons[2].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -179,7 +178,9 @@ public class Sentry extends Item
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height + orgY);
|
g2.clearRect(0, 0, width, height + orgY);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
if (smartblock) g.setColor(Color.blue);
|
if (smartblock) {
|
||||||
|
g.setColor(Color.blue);
|
||||||
|
}
|
||||||
g.fillRect(8, 0, 12, 6);
|
g.fillRect(8, 0, 12, 6);
|
||||||
g.fillRect(12, 6, 4, 36);
|
g.fillRect(12, 6, 4, 36);
|
||||||
g.fillRect(8, 12, 12, 24);
|
g.fillRect(8, 12, 12, 24);
|
||||||
@@ -198,57 +199,56 @@ public class Sentry extends Item
|
|||||||
g.fillRect(12, 30, 4, 2);
|
g.fillRect(12, 30, 4, 2);
|
||||||
g.fillRect(12, 22, 4, 6);
|
g.fillRect(12, 22, 4, 6);
|
||||||
|
|
||||||
if (animation==3)
|
if (animation == 3) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[animation].getImage();
|
currentIcon = icons[animation].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (carrying == null) {
|
||||||
if (carrying==null) animation++;
|
animation++;
|
||||||
if (animation==4) animation=0;
|
}
|
||||||
if (animation==3)
|
if (animation == 4) {
|
||||||
|
animation = 0;
|
||||||
|
}
|
||||||
|
if (animation == 3) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[animation].getImage();
|
currentIcon = icons[animation].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
if (behavior== -2)
|
if (behavior == -2) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smartblock)
|
if (smartblock) {
|
||||||
{
|
|
||||||
robot = PlayerInRobot(null);
|
robot = PlayerInRobot(null);
|
||||||
if (robot != null)
|
if (robot != null) {
|
||||||
{
|
|
||||||
previousBehavior = 0;
|
previousBehavior = 0;
|
||||||
behavior = -1; // Pin Robot
|
behavior = -1; // Pin Robot
|
||||||
}
|
}
|
||||||
else if (carrying!=null && behavior!=drag)
|
else if (carrying != null && behavior != drag) {
|
||||||
{
|
|
||||||
Drops();
|
Drops();
|
||||||
behavior = previousBehavior;
|
behavior = previousBehavior;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (behavior==-1)
|
if (behavior == -1) {
|
||||||
{
|
if (carrying == null) {
|
||||||
if (carrying==null)
|
|
||||||
{
|
|
||||||
x = robot.x + robot.width / 2 - width / 2;
|
x = robot.x + robot.width / 2 - width / 2;
|
||||||
y = robot.y + robot.height / 2 - height / 2;
|
y = robot.y + robot.height / 2 - height / 2;
|
||||||
PicksUp(robot);
|
PicksUp(robot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (behavior >=0 && behavior < pounce)
|
if (behavior >= 0 && behavior < pounce) {
|
||||||
if (protect.length >0 && level.player.room == room)
|
if (protect.length > 0 && level.player.room == room) {
|
||||||
{
|
for (int p = 0; p < protect.length / 6; p++) {
|
||||||
for (int p=0; p<protect.length/6; p++)
|
|
||||||
{
|
|
||||||
int x1 = protect[p * 6];
|
int x1 = protect[p * 6];
|
||||||
int y1 = protect[p * 6 + 1];
|
int y1 = protect[p * 6 + 1];
|
||||||
int x2 = protect[p * 6 + 2];
|
int x2 = protect[p * 6 + 2];
|
||||||
@@ -259,162 +259,165 @@ public class Sentry extends Item
|
|||||||
if (level.player.x >= x1
|
if (level.player.x >= x1
|
||||||
&& level.player.x <= x2
|
&& level.player.x <= x2
|
||||||
&& level.player.y >= y1
|
&& level.player.y >= y1
|
||||||
&& level.player.y <= y2)
|
&& level.player.y <= y2) {
|
||||||
{
|
|
||||||
carryToX = x3;
|
carryToX = x3;
|
||||||
carryToY = y3;
|
carryToY = y3;
|
||||||
previousBehavior = behavior;
|
previousBehavior = behavior;
|
||||||
if (previousBehavior >= pounce)
|
if (previousBehavior >= pounce) {
|
||||||
previousBehavior = 0;
|
previousBehavior = 0;
|
||||||
|
}
|
||||||
behavior = pounce;
|
behavior = pounce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (behavior >=0 && behavior < pounce)
|
if (behavior >= 0 && behavior < pounce) {
|
||||||
{
|
if (x == goToX && y == goToY) {
|
||||||
if (x == goToX && y == goToY)
|
|
||||||
{
|
|
||||||
behavior++;
|
behavior++;
|
||||||
if (behavior==pounce) behavior=0;
|
if (behavior == pounce) {
|
||||||
|
behavior = 0;
|
||||||
|
}
|
||||||
goToX = pace[behavior * 2];
|
goToX = pace[behavior * 2];
|
||||||
goToY = pace[behavior * 2 + 1];
|
goToY = pace[behavior * 2 + 1];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (x != goToX) {
|
||||||
if (x != goToX)
|
|
||||||
{
|
|
||||||
int diff = Math.abs(goToX - x);
|
int diff = Math.abs(goToX - x);
|
||||||
int dir = diff / (goToX - x);
|
int dir = diff / (goToX - x);
|
||||||
if (diff > 8) diff = 8;
|
if (diff > 8) {
|
||||||
MoveRight(diff * dir);
|
diff = 8;
|
||||||
}
|
}
|
||||||
if (y != goToY)
|
moveRight(diff * dir);
|
||||||
{
|
}
|
||||||
|
if (y != goToY) {
|
||||||
int diff = Math.abs(goToY - y);
|
int diff = Math.abs(goToY - y);
|
||||||
int dir = diff / (goToY - y);
|
int dir = diff / (goToY - y);
|
||||||
if (diff > 8) diff = 8;
|
if (diff > 8) {
|
||||||
MoveDown(diff * dir);
|
diff = 8;
|
||||||
|
}
|
||||||
|
moveDown(diff * dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (behavior == pounce)
|
else if (behavior == pounce) {
|
||||||
{
|
if (level.player.room != room) {
|
||||||
if (level.player.room != room)
|
|
||||||
behavior = previousBehavior;
|
behavior = previousBehavior;
|
||||||
if (animation==0)
|
}
|
||||||
{
|
if (animation == 0) {
|
||||||
x = level.player.x;
|
x = level.player.x;
|
||||||
y = level.player.y;
|
y = level.player.y;
|
||||||
}
|
}
|
||||||
if (x != level.player.x)
|
if (x != level.player.x) {
|
||||||
{
|
|
||||||
int diff = Math.abs(level.player.x - x);
|
int diff = Math.abs(level.player.x - x);
|
||||||
int dir = diff / (level.player.x - x);
|
int dir = diff / (level.player.x - x);
|
||||||
if (diff > 50) diff /= 2;
|
if (diff > 50) {
|
||||||
MoveRight(diff * dir);
|
diff /= 2;
|
||||||
}
|
}
|
||||||
if (y != level.player.y)
|
moveRight(diff * dir);
|
||||||
{
|
}
|
||||||
|
if (y != level.player.y) {
|
||||||
int diff = Math.abs(level.player.y - y);
|
int diff = Math.abs(level.player.y - y);
|
||||||
int dir = diff / (level.player.y - y);
|
int dir = diff / (level.player.y - y);
|
||||||
if (diff > 50) diff /= 2;
|
if (diff > 50) {
|
||||||
MoveDown(diff * dir);
|
diff /= 2;
|
||||||
}
|
}
|
||||||
if (x == level.player.x && y == level.player.y)
|
moveDown(diff * dir);
|
||||||
{
|
}
|
||||||
|
if (x == level.player.x && y == level.player.y) {
|
||||||
PicksUp(level.player);
|
PicksUp(level.player);
|
||||||
// if (level.player.carrying != null)
|
// if (level.player.carrying != null)
|
||||||
// level.player.Drops();
|
// level.player.Drops();
|
||||||
behavior = drag;
|
behavior = drag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (behavior == drag)
|
else if (behavior == drag) {
|
||||||
{
|
if (x == carryToX && y == carryToY) {
|
||||||
if (x == carryToX && y == carryToY)
|
|
||||||
{
|
|
||||||
Drops();
|
Drops();
|
||||||
behavior = previousBehavior;
|
behavior = previousBehavior;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (x != carryToX) {
|
||||||
if (x != carryToX)
|
|
||||||
{
|
|
||||||
int diff = Math.abs(carryToX - x);
|
int diff = Math.abs(carryToX - x);
|
||||||
int dir = diff / (carryToX - x);
|
int dir = diff / (carryToX - x);
|
||||||
if (diff > 8) diff = 8;
|
if (diff > 8) {
|
||||||
MoveRight(diff * dir);
|
diff = 8;
|
||||||
}
|
}
|
||||||
if (y != carryToY)
|
moveRight(diff * dir);
|
||||||
{
|
}
|
||||||
|
if (y != carryToY) {
|
||||||
int diff = Math.abs(carryToY - y);
|
int diff = Math.abs(carryToY - y);
|
||||||
int dir = diff / (carryToY - y);
|
int dir = diff / (carryToY - y);
|
||||||
if (diff > 8) diff = 8;
|
if (diff > 8) {
|
||||||
MoveDown(diff * dir);
|
diff = 8;
|
||||||
|
}
|
||||||
|
moveDown(diff * dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenericRobot PlayerInRobot(GenericRobot robot)
|
GenericRobot PlayerInRobot(GenericRobot robot) {
|
||||||
{
|
if (robot == null) {
|
||||||
if (robot==null)
|
if (level.player.room.portalItem != null) {
|
||||||
{
|
if (level.player.room.portalItem.getClass().toString().endsWith("Robot")) {
|
||||||
if (level.player.room.portalItem!=null)
|
|
||||||
{
|
|
||||||
if (level.player.room.portalItem.getClass().toString().endsWith("Robot"))
|
|
||||||
return (PlayerInRobot((GenericRobot) level.player.room.portalItem));
|
return (PlayerInRobot((GenericRobot) level.player.room.portalItem));
|
||||||
else return (null);
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
if (robot.room.portalItem != null)
|
else {
|
||||||
{
|
return (null);
|
||||||
if (robot.room.portalItem.getClass().toString().endsWith("Robot"))
|
}
|
||||||
|
}
|
||||||
|
else if (robot.room.portalItem != null) {
|
||||||
|
if (robot.room.portalItem.getClass().toString().endsWith("Robot")) {
|
||||||
return (PlayerInRobot((GenericRobot) robot.room.portalItem));
|
return (PlayerInRobot((GenericRobot) robot.room.portalItem));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
if (robot.room == room)
|
if (robot.room == room) {
|
||||||
return robot;
|
return robot;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveUp(int dist)
|
public void moveUp(int dist) {
|
||||||
{
|
|
||||||
int newY = y - dist;
|
int newY = y - dist;
|
||||||
if (newY<0)
|
if (newY < 0) {
|
||||||
newY = 0;
|
newY = 0;
|
||||||
|
}
|
||||||
y = newY;
|
y = newY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveDown(int dist)
|
public void moveDown(int dist) {
|
||||||
{
|
|
||||||
int newY = y + dist;
|
int newY = y + dist;
|
||||||
if (newY>383)
|
if (newY > 383) {
|
||||||
newY = 383;
|
newY = 383;
|
||||||
|
}
|
||||||
y = newY;
|
y = newY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveLeft(int dist)
|
public void moveLeft(int dist) {
|
||||||
{
|
|
||||||
int newX = x - dist;
|
int newX = x - dist;
|
||||||
if (newX<0)
|
if (newX < 0) {
|
||||||
newX = 0;
|
newX = 0;
|
||||||
|
}
|
||||||
x = newX;
|
x = newX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveRight(int dist)
|
public void moveRight(int dist) {
|
||||||
{
|
|
||||||
int newX = x + dist;
|
int newX = x + dist;
|
||||||
if (newX>579)
|
if (newX > 579) {
|
||||||
newX = 579;
|
newX = 579;
|
||||||
|
}
|
||||||
x = newX;
|
x = newX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package com.droidquest.items;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Sentry3 extends Sentry
|
public class Sentry3 extends Sentry {
|
||||||
{
|
|
||||||
// This sentry guards the Sewer Grate room. It walks up and down from
|
// This sentry guards the Sewer Grate room. It walks up and down from
|
||||||
// position (2*28,2*32) to (2*28,8*32). It does not notice the player
|
// position (2*28,2*32) to (2*28,8*32). It does not notice the player
|
||||||
// unless the player passes below y=11*32. Then it grabs the player if
|
// unless the player passes below y=11*32. Then it grabs the player if
|
||||||
@@ -15,95 +14,129 @@ public class Sentry3 extends Sentry
|
|||||||
// 1=Move Up
|
// 1=Move Up
|
||||||
// 2=Attack
|
// 2=Attack
|
||||||
// 3=Drag
|
// 3=Drag
|
||||||
int carryToX;
|
private int carryToX;
|
||||||
boolean smart= false; // knows about the player
|
private boolean smart = false; // knows about the player
|
||||||
|
|
||||||
public Sentry3(int X, int Y, Room r)
|
public Sentry3(int X, int Y, Room r) {
|
||||||
{
|
|
||||||
super(X, Y, r);
|
super(X, Y, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (behavior < 3) {
|
||||||
if (behavior<3) animation++;
|
animation++;
|
||||||
if (animation==4) animation=0;
|
}
|
||||||
if (animation==3)
|
if (animation == 4) {
|
||||||
|
animation = 0;
|
||||||
|
}
|
||||||
|
if (animation == 3) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[animation].getImage();
|
currentIcon = icons[animation].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
if (level.player.room!=room)
|
if (level.player.room != room) {
|
||||||
{
|
if (smart) {
|
||||||
if (smart) behavior = previousBehavior;
|
behavior = previousBehavior;
|
||||||
|
}
|
||||||
smart = false;
|
smart = false;
|
||||||
}
|
}
|
||||||
else
|
else if (level.player.y > 320) {
|
||||||
if (level.player.y>320)
|
|
||||||
{
|
|
||||||
carryToX = level.player.x;
|
carryToX = level.player.x;
|
||||||
smart = true;
|
smart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (behavior<2 && smart)
|
if (behavior < 2 && smart) {
|
||||||
if (level.player.y <= 256)
|
if (level.player.y <= 256) {
|
||||||
{
|
|
||||||
previousBehavior = behavior;
|
previousBehavior = behavior;
|
||||||
behavior = 2;
|
behavior = 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (behavior)
|
switch (behavior) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
if (y<256) MoveDown(8);
|
if (y < 256) {
|
||||||
else behavior=1;
|
moveDown(8);
|
||||||
if (x<56) MoveRight(8);
|
}
|
||||||
if (x>56) MoveLeft(8);
|
else {
|
||||||
|
behavior = 1;
|
||||||
|
}
|
||||||
|
if (x < 56) {
|
||||||
|
moveRight(8);
|
||||||
|
}
|
||||||
|
if (x > 56) {
|
||||||
|
moveLeft(8);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (y>64) MoveUp(8);
|
if (y > 64) {
|
||||||
else behavior=0;
|
moveUp(8);
|
||||||
if (x<56) MoveRight(8);
|
}
|
||||||
if (x>56) MoveLeft(8);
|
else {
|
||||||
|
behavior = 0;
|
||||||
|
}
|
||||||
|
if (x < 56) {
|
||||||
|
moveRight(8);
|
||||||
|
}
|
||||||
|
if (x > 56) {
|
||||||
|
moveLeft(8);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (level.player.room != room)
|
if (level.player.room != room) {
|
||||||
{
|
|
||||||
behavior = previousBehavior;
|
behavior = previousBehavior;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int dx = level.player.x - x;
|
int dx = level.player.x - x;
|
||||||
int dy = level.player.y - y;
|
int dy = level.player.y - y;
|
||||||
if (dx<-50) dx=-50;
|
if (dx < -50) {
|
||||||
if (dx>50) dx=50;
|
dx = -50;
|
||||||
if (dy<-50) dy=-50;
|
}
|
||||||
if (dy>50) dy=50;
|
if (dx > 50) {
|
||||||
if (dx<0) MoveLeft(-dx);
|
dx = 50;
|
||||||
if (dx>0) MoveRight(dx);
|
}
|
||||||
if (dy<0) MoveUp(-dy);
|
if (dy < -50) {
|
||||||
if (dy>0) MoveDown(dy);
|
dy = -50;
|
||||||
if (dx==0 && dy==0)
|
}
|
||||||
{
|
if (dy > 50) {
|
||||||
|
dy = 50;
|
||||||
|
}
|
||||||
|
if (dx < 0) {
|
||||||
|
moveLeft(-dx);
|
||||||
|
}
|
||||||
|
if (dx > 0) {
|
||||||
|
moveRight(dx);
|
||||||
|
}
|
||||||
|
if (dy < 0) {
|
||||||
|
moveUp(-dy);
|
||||||
|
}
|
||||||
|
if (dy > 0) {
|
||||||
|
moveDown(dy);
|
||||||
|
}
|
||||||
|
if (dx == 0 && dy == 0) {
|
||||||
PicksUp(level.player);
|
PicksUp(level.player);
|
||||||
behavior = 3;
|
behavior = 3;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (y>=320)
|
if (y >= 320) {
|
||||||
{
|
|
||||||
Drops();
|
Drops();
|
||||||
behavior = previousBehavior;
|
behavior = previousBehavior;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (y < 312) {
|
||||||
if (y<312)
|
moveDown(8);
|
||||||
MoveDown(8);
|
}
|
||||||
else if (y<320)
|
else if (y < 320) {
|
||||||
MoveDown(320-y);
|
moveDown(320 - y);
|
||||||
if (x<carryToX)
|
}
|
||||||
MoveRight(8);
|
if (x < carryToX) {
|
||||||
if (x>carryToX)
|
moveRight(8);
|
||||||
MoveLeft(8);
|
}
|
||||||
|
if (x > carryToX) {
|
||||||
|
moveLeft(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class SentryT1 extends Item
|
public class SentryT1 extends Item {
|
||||||
{
|
|
||||||
// This sentry does nothing but pace back and forth in the first tutorial.
|
// This sentry does nothing but pace back and forth in the first tutorial.
|
||||||
// It walks left and right, and switches directions when it hits a wall.
|
// It walks left and right, and switches directions when it hits a wall.
|
||||||
|
|
||||||
@@ -18,20 +17,22 @@ public class SentryT1 extends Item
|
|||||||
// 0=Move Left
|
// 0=Move Left
|
||||||
// 1=Move Right
|
// 1=Move Right
|
||||||
|
|
||||||
int animation = 0; // 0-3, 1 & 3 = icons[1]
|
private int animation = 0; // 0-3, 1 & 3 = icons[1]
|
||||||
int behavior = 0; // 0+ for pacing, until pounce and drag. -1=pin.
|
private int behavior = 0; // 0+ for pacing, until pounce and drag. -1=pin.
|
||||||
|
|
||||||
public SentryT1(int X, int Y, Room r)
|
public SentryT1(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=28; height=18; orgY = 30;
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 18;
|
||||||
|
orgY = 30;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[3];
|
icons = new ImageIcon[3];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height + orgY, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -41,12 +42,10 @@ public class SentryT1 extends Item
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// 0 = Legs out
|
// 0 = Legs out
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -78,12 +77,10 @@ public class SentryT1 extends Item
|
|||||||
|
|
||||||
|
|
||||||
// 1 = legs mid
|
// 1 = legs mid
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -113,12 +110,10 @@ public class SentryT1 extends Item
|
|||||||
|
|
||||||
|
|
||||||
// 2 = legs in
|
// 2 = legs in
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[2].getImage().getGraphics();
|
g = icons[2].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -144,34 +139,44 @@ public class SentryT1 extends Item
|
|||||||
g.fillRect(12, 30, 4, 2);
|
g.fillRect(12, 30, 4, 2);
|
||||||
g.fillRect(12, 22, 4, 6);
|
g.fillRect(12, 22, 4, 6);
|
||||||
|
|
||||||
if (animation==3)
|
if (animation == 3) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[animation].getImage();
|
currentIcon = icons[animation].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (behavior < 3) {
|
||||||
if (behavior<3) animation++;
|
animation++;
|
||||||
if (animation==4) animation=0;
|
}
|
||||||
if (animation==3)
|
if (animation == 4) {
|
||||||
|
animation = 0;
|
||||||
|
}
|
||||||
|
if (animation == 3) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[animation].getImage();
|
currentIcon = icons[animation].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
int oldX;
|
int oldX;
|
||||||
switch (behavior)
|
switch (behavior) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
oldX = x;
|
oldX = x;
|
||||||
MoveLeft(4);
|
moveLeft(4);
|
||||||
if (oldX==x) behavior=1;
|
if (oldX == x) {
|
||||||
|
behavior = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
oldX = x;
|
oldX = x;
|
||||||
MoveRight(4);
|
moveRight(4);
|
||||||
if (oldX==x) behavior=0;
|
if (oldX == x) {
|
||||||
|
behavior = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package com.droidquest.items;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class SentryT2 extends Sentry
|
public class SentryT2 extends Sentry {
|
||||||
{
|
|
||||||
// This sentry guards a room from the toolbox being carried through it.
|
// This sentry guards a room from the toolbox being carried through it.
|
||||||
// It walks up and down, and pounces and drags if the cursor is
|
// It walks up and down, and pounces and drags if the cursor is
|
||||||
// carrying the toolbox.
|
// carrying the toolbox.
|
||||||
@@ -14,79 +13,114 @@ public class SentryT2 extends Sentry
|
|||||||
// 2=Attack
|
// 2=Attack
|
||||||
// 3=Drag back
|
// 3=Drag back
|
||||||
|
|
||||||
public SentryT2(int X, int Y, Room r)
|
public SentryT2(int X, int Y, Room r) {
|
||||||
{
|
|
||||||
super(X, Y, r);
|
super(X, Y, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (behavior < 3) {
|
||||||
if (behavior<3) animation++;
|
animation++;
|
||||||
if (animation==4) animation=0;
|
}
|
||||||
if (animation==3)
|
if (animation == 4) {
|
||||||
|
animation = 0;
|
||||||
|
}
|
||||||
|
if (animation == 3) {
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentIcon = icons[animation].getImage();
|
currentIcon = icons[animation].getImage();
|
||||||
|
}
|
||||||
|
|
||||||
if (level.player.room==room)
|
if (level.player.room == room) {
|
||||||
if (level.player.x>=112)
|
if (level.player.x >= 112) {
|
||||||
if (level.player.carrying==level.toolbox)
|
if (level.player.carrying == level.toolbox) {
|
||||||
{
|
|
||||||
previousBehavior = behavior;
|
previousBehavior = behavior;
|
||||||
behavior = 2;
|
behavior = 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (behavior)
|
switch (behavior) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
if (y<256) MoveDown(4);
|
if (y < 256) {
|
||||||
else behavior=1;
|
moveDown(4);
|
||||||
if (x<56) MoveRight(4);
|
}
|
||||||
if (x>56) MoveLeft(4);
|
else {
|
||||||
|
behavior = 1;
|
||||||
|
}
|
||||||
|
if (x < 56) {
|
||||||
|
moveRight(4);
|
||||||
|
}
|
||||||
|
if (x > 56) {
|
||||||
|
moveLeft(4);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (y>64) MoveUp(4);
|
if (y > 64) {
|
||||||
else behavior=0;
|
moveUp(4);
|
||||||
if (x<56) MoveRight(4);
|
}
|
||||||
if (x>56) MoveLeft(4);
|
else {
|
||||||
|
behavior = 0;
|
||||||
|
}
|
||||||
|
if (x < 56) {
|
||||||
|
moveRight(4);
|
||||||
|
}
|
||||||
|
if (x > 56) {
|
||||||
|
moveLeft(4);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (level.player.room != room)
|
if (level.player.room != room) {
|
||||||
{
|
|
||||||
behavior = previousBehavior;
|
behavior = previousBehavior;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int dx = level.player.x - x;
|
int dx = level.player.x - x;
|
||||||
int dy = level.player.y - y;
|
int dy = level.player.y - y;
|
||||||
if (dx<-50) dx=-50;
|
if (dx < -50) {
|
||||||
if (dx>50) dx=50;
|
dx = -50;
|
||||||
if (dy<-50) dy=-50;
|
}
|
||||||
if (dy>50) dy=50;
|
if (dx > 50) {
|
||||||
if (dx<0) MoveLeft(-dx);
|
dx = 50;
|
||||||
if (dx>0) MoveRight(dx);
|
}
|
||||||
if (dy<0) MoveUp(-dy);
|
if (dy < -50) {
|
||||||
if (dy>0) MoveDown(dy);
|
dy = -50;
|
||||||
if (dx==0 && dy==0)
|
}
|
||||||
{
|
if (dy > 50) {
|
||||||
|
dy = 50;
|
||||||
|
}
|
||||||
|
if (dx < 0) {
|
||||||
|
moveLeft(-dx);
|
||||||
|
}
|
||||||
|
if (dx > 0) {
|
||||||
|
moveRight(dx);
|
||||||
|
}
|
||||||
|
if (dy < 0) {
|
||||||
|
moveUp(-dy);
|
||||||
|
}
|
||||||
|
if (dy > 0) {
|
||||||
|
moveDown(dy);
|
||||||
|
}
|
||||||
|
if (dx == 0 && dy == 0) {
|
||||||
PicksUp(level.player);
|
PicksUp(level.player);
|
||||||
behavior = 3;
|
behavior = 3;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (x<=56 && y>=20 && y<=30)
|
if (x <= 56 && y >= 20 && y <= 30) {
|
||||||
{
|
|
||||||
Drops();
|
Drops();
|
||||||
behavior = 1;
|
behavior = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (x > 56) {
|
||||||
if (x>56)
|
moveLeft(4);
|
||||||
MoveLeft(4);
|
}
|
||||||
if (y<20)
|
if (y < 20) {
|
||||||
MoveDown(4);
|
moveDown(4);
|
||||||
if (y>30)
|
}
|
||||||
MoveUp(4);
|
if (y > 30) {
|
||||||
|
moveUp(4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,54 +4,48 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class SkyGuard extends Item
|
public class SkyGuard extends Item {
|
||||||
{
|
private int animationState = 0;
|
||||||
int animationState=0;
|
private int speed;
|
||||||
int speed;
|
|
||||||
|
|
||||||
public SkyGuard (int X, int Y, Room r, int s)
|
public SkyGuard(int X, int Y, Room r, int s) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
|
room = r;
|
||||||
speed = s;
|
speed = s;
|
||||||
width=28; height=32;
|
width = 28;
|
||||||
|
height = 32;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[5];
|
icons = new ImageIcon[5];
|
||||||
for (int a=0; a<5; a++)
|
for (int a = 0; a < 5; a++) {
|
||||||
icons[a] = new ImageIcon("images/skyguard" + a + ".gif");
|
icons[a] = new ImageIcon("images/skyguard" + a + ".gif");
|
||||||
|
}
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
animationState = 1 - animationState;
|
animationState = 1 - animationState;
|
||||||
|
|
||||||
if (speed>0)
|
if (speed > 0) {
|
||||||
{
|
if (speed + x < 420) {
|
||||||
if (speed+x < 420)
|
moveRight(speed);
|
||||||
{
|
|
||||||
MoveRight(speed);
|
|
||||||
currentIcon = icons[animationState].getImage();
|
currentIcon = icons[animationState].getImage();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
speed = -speed;
|
speed = -speed;
|
||||||
currentIcon = icons[2].getImage();
|
currentIcon = icons[2].getImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (speed<0)
|
else if (speed < 0) {
|
||||||
{
|
if (speed + x > 112) {
|
||||||
if (speed+x > 112)
|
moveLeft(-speed);
|
||||||
{
|
|
||||||
MoveLeft(-speed);
|
|
||||||
currentIcon = icons[3 + animationState].getImage();
|
currentIcon = icons[3 + animationState].getImage();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
speed = -speed;
|
speed = -speed;
|
||||||
currentIcon = icons[2].getImage();
|
currentIcon = icons[2].getImage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,57 +5,60 @@ import javax.swing.ImageIcon;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.levels.Level;
|
import com.droidquest.levels.Level;
|
||||||
|
|
||||||
public class SkywayFlyer extends Item
|
public class SkywayFlyer extends Item {
|
||||||
{
|
private int speed;
|
||||||
int speed;
|
private String[] filenames;
|
||||||
String[] filenames;
|
private int animationState = 0;
|
||||||
int animationState=0;
|
|
||||||
|
|
||||||
public SkywayFlyer(int X, int Y, Room r, String[] f, int spd)
|
public SkywayFlyer(int X, int Y, Room r, String[] f, int spd) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y; room=r;
|
y = Y;
|
||||||
width=24; height=32;
|
room = r;
|
||||||
|
width = 24;
|
||||||
|
height = 32;
|
||||||
orgX = 2;
|
orgX = 2;
|
||||||
filenames = f; speed=spd;
|
filenames = f;
|
||||||
|
speed = spd;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[filenames.length];
|
icons = new ImageIcon[filenames.length];
|
||||||
for (int a=0; a<filenames.length; a++)
|
for (int a = 0; a < filenames.length; a++) {
|
||||||
icons[a] = new ImageIcon("images/" + filenames[a]);
|
icons[a] = new ImageIcon("images/" + filenames[a]);
|
||||||
|
}
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveUp(int dist)
|
public void moveUp(int dist) {
|
||||||
{
|
|
||||||
y = y - dist;
|
y = y - dist;
|
||||||
if (y<32)
|
if (y < 32) {
|
||||||
y = 320;
|
y = 320;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveDown(int dist)
|
|
||||||
{
|
|
||||||
y = y + dist;
|
|
||||||
if (y>320)
|
|
||||||
y = 32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void moveDown(int dist) {
|
||||||
{
|
y = y + dist;
|
||||||
|
if (y > 320) {
|
||||||
|
y = 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Animate() {
|
||||||
animationState++;
|
animationState++;
|
||||||
if (animationState == filenames.length)
|
if (animationState == filenames.length) {
|
||||||
animationState = 0;
|
animationState = 0;
|
||||||
|
}
|
||||||
currentIcon = icons[animationState].getImage();
|
currentIcon = icons[animationState].getImage();
|
||||||
|
|
||||||
if (speed<0)
|
if (speed < 0) {
|
||||||
MoveUp(-speed);
|
moveUp(-speed);
|
||||||
else
|
}
|
||||||
MoveDown(speed);
|
else {
|
||||||
|
moveDown(speed);
|
||||||
|
}
|
||||||
|
|
||||||
if (Overlaps(level.player))
|
if (Overlaps(level.player)) {
|
||||||
{
|
|
||||||
level.PlaySound(room, Level.DISCHARGESOUND);
|
level.PlaySound(room, Level.DISCHARGESOUND);
|
||||||
level.player.x = 2 * 28;
|
level.player.x = 2 * 28;
|
||||||
level.player.y = 8 * 32;
|
level.player.y = 8 * 32;
|
||||||
|
|||||||
@@ -3,53 +3,42 @@ package com.droidquest.items;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
public class SlipperyToken extends Token
|
public class SlipperyToken extends Token {
|
||||||
{
|
private boolean jumping = true;
|
||||||
boolean jumping = true;
|
|
||||||
|
|
||||||
public SlipperyToken(int X, int Y, Room r)
|
public SlipperyToken(int X, int Y, Room r) {
|
||||||
{
|
|
||||||
super(X, Y, r);
|
super(X, Y, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
return !(item == level.player && jumping);
|
||||||
if (item == level.player && jumping)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IsDropped()
|
public void IsDropped() {
|
||||||
{
|
|
||||||
int bigX = (x + width / 2) / 28;
|
int bigX = (x + width / 2) / 28;
|
||||||
int bigY = (y + height / 2) / 32;
|
int bigY = (y + height / 2) / 32;
|
||||||
Material mat = room.MaterialArray[bigY][bigX];
|
Material mat = room.MaterialArray[bigY][bigX];
|
||||||
if (mat.getClass().toString().endsWith("VendingSlot"))
|
if (mat.getClass().toString().endsWith("VendingSlot")) {
|
||||||
{
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
Item item = level.items.elementAt(a);
|
||||||
{
|
if (item.getClass().toString().endsWith("VendingHandle")) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (item.getClass().toString().endsWith("VendingHandle"))
|
|
||||||
{
|
|
||||||
VendingHandle vh = (VendingHandle) item;
|
VendingHandle vh = (VendingHandle) item;
|
||||||
vh.paid = true;
|
vh.paid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x=3*28; y=3*32;
|
x = 3 * 28;
|
||||||
room = (Room) level.rooms.elementAt(34);
|
y = 3 * 32;
|
||||||
|
room = level.rooms.elementAt(34);
|
||||||
jumping = true;
|
jumping = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (carriedBy != null) {
|
||||||
if (carriedBy != null)
|
|
||||||
jumping = false;
|
jumping = false;
|
||||||
if (jumping)
|
}
|
||||||
{
|
if (jumping) {
|
||||||
if (Overlaps(level.player))
|
if (Overlaps(level.player)) {
|
||||||
{
|
|
||||||
x = level.random.nextInt(16 * 28) + 28;
|
x = level.random.nextInt(16 * 28) + 28;
|
||||||
y = level.random.nextInt(8 * 32) + (2 * 32);
|
y = level.random.nextInt(8 * 32) + (2 * 32);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import javax.swing.ImageIcon;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.devices.Antenna;
|
import com.droidquest.devices.Antenna;
|
||||||
|
|
||||||
public class SonicLock extends Item
|
public class SonicLock extends Item {
|
||||||
{
|
|
||||||
// This works much like a regular Lock, except it locks or unlocks by watching the Radio.
|
// This works much like a regular Lock, except it locks or unlocks by watching the Radio.
|
||||||
//
|
//
|
||||||
// The program has either an array of binary values, or an array of X,Y,Materials.
|
// The program has either an array of binary values, or an array of X,Y,Materials.
|
||||||
@@ -23,42 +22,39 @@ public class SonicLock extends Item
|
|||||||
|
|
||||||
public static final int MODIFY = -1;
|
public static final int MODIFY = -1;
|
||||||
public static final int BINARY = -2;
|
public static final int BINARY = -2;
|
||||||
static final int RESET = -3;
|
private static final int RESET = -3;
|
||||||
static final int LEFT = -4;
|
private static final int LEFT = -4;
|
||||||
static final int RIGHT = -5;
|
private static final int RIGHT = -5;
|
||||||
static final int UP = -6;
|
private static final int UP = -6;
|
||||||
static final int DOWN = -7;
|
private static final int DOWN = -7;
|
||||||
int[][] program;
|
private int[][] program;
|
||||||
int doorState=0;
|
private int doorState = 0;
|
||||||
int radioState=1;
|
private int radioState = 1;
|
||||||
int animationState=1;
|
private int animationState = 1;
|
||||||
Room currentRoom;
|
private Room currentRoom;
|
||||||
|
|
||||||
public SonicLock(int X, int Y, Room r, int[][] p)
|
public SonicLock(int X, int Y, Room r, int[][] p) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
room = r;
|
room = r;
|
||||||
program = p;
|
program = p;
|
||||||
width=28; height=30;
|
width = 28;
|
||||||
|
height = 30;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
currentRoom = room;
|
currentRoom = room;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[2];
|
icons = new ImageIcon[2];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
for (int a=0; a<2; a++)
|
for (int a = 0; a < 2; a++) {
|
||||||
{
|
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[a].getImage().getGraphics();
|
g = icons[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -66,8 +62,7 @@ public class SonicLock extends Item
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
switch (a)
|
switch (a) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
break;
|
break;
|
||||||
@@ -90,46 +85,45 @@ public class SonicLock extends Item
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
if (doorState == program.length) {
|
||||||
if (doorState == program.length)
|
|
||||||
doorState = 0;
|
doorState = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (program[doorState][0]==BINARY)
|
if (program[doorState][0] == BINARY) {
|
||||||
{
|
|
||||||
animationState++;
|
animationState++;
|
||||||
if (animationState==program[doorState].length)
|
if (animationState == program[doorState].length) {
|
||||||
animationState = 1;
|
animationState = 1;
|
||||||
|
}
|
||||||
currentIcon = icons[program[doorState][animationState]].getImage();
|
currentIcon = icons[program[doorState][animationState]].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (program[doorState][0])
|
switch (program[doorState][0]) {
|
||||||
{
|
case MODIFY: {
|
||||||
case MODIFY:
|
for (int a = 0; a < program[doorState].length / 3; a++) {
|
||||||
{
|
|
||||||
for (int a=0; a<program[doorState].length/3; a++)
|
|
||||||
currentRoom.SetMaterial(program[doorState][a * 3 + 1],
|
currentRoom.SetMaterial(program[doorState][a * 3 + 1],
|
||||||
program[doorState][a * 3 + 2],
|
program[doorState][a * 3 + 2],
|
||||||
program[doorState][a * 3 + 3]);
|
program[doorState][a * 3 + 3]);
|
||||||
|
}
|
||||||
doorState++;
|
doorState++;
|
||||||
radioState = 1;
|
radioState = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BINARY:
|
case BINARY: {
|
||||||
{
|
|
||||||
currentRoom = room;
|
currentRoom = room;
|
||||||
boolean radio = (Antenna.radio > 0);
|
boolean radio = (Antenna.radio > 0);
|
||||||
boolean bit = (program[doorState][radioState] == 1);
|
boolean bit = (program[doorState][radioState] == 1);
|
||||||
if (radio == bit)
|
if (radio == bit) {
|
||||||
{
|
|
||||||
radioState++;
|
radioState++;
|
||||||
if (radioState == program[doorState].length)
|
if (radioState == program[doorState].length) {
|
||||||
doorState++;
|
doorState++;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
radioState = 1;
|
radioState = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESET:
|
case RESET:
|
||||||
|
|||||||
@@ -1,47 +1,38 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.chipstuff.ChipCompiler;
|
import com.droidquest.chipstuff.ChipCompiler;
|
||||||
import com.droidquest.decorations.TextBox;
|
import com.droidquest.decorations.TextBox;
|
||||||
import com.droidquest.materials.Material;
|
|
||||||
|
|
||||||
public
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
class SpeedControl extends Item
|
public class SpeedControl extends Item {
|
||||||
{
|
private int direction;
|
||||||
int direction;
|
|
||||||
public static final int DIR_UP = 0;
|
public static final int DIR_UP = 0;
|
||||||
public static final int DIR_DOWN = 1;
|
public static final int DIR_DOWN = 1;
|
||||||
|
|
||||||
public SpeedControl(int X, int Y, Room r, int dir)
|
public SpeedControl(int X, int Y, Room r, int dir) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
room = r;
|
room = r;
|
||||||
width=26; height=26;
|
width = 26;
|
||||||
|
height = 26;
|
||||||
direction = dir;
|
direction = dir;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
Graphics2D g2;
|
Graphics2D g2;
|
||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -49,8 +40,7 @@ public void GenerateIcons()
|
|||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, width, height);
|
g2.clearRect(0, 0, width, height);
|
||||||
g.setColor(Color.white);
|
g.setColor(Color.white);
|
||||||
switch(direction)
|
switch (direction) {
|
||||||
{
|
|
||||||
case DIR_UP:
|
case DIR_UP:
|
||||||
g.fillRect(12, 0, 2, 2);
|
g.fillRect(12, 0, 2, 2);
|
||||||
g.fillRect(10, 2, 6, 2);
|
g.fillRect(10, 2, 6, 2);
|
||||||
@@ -75,19 +65,19 @@ public void GenerateIcons()
|
|||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean CanBePickedUp(Item item)
|
public boolean CanBePickedUp(Item item) {
|
||||||
{
|
switch (direction) {
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case DIR_UP:
|
case DIR_UP:
|
||||||
ChipCompiler.chipSpeed++;
|
ChipCompiler.chipSpeed++;
|
||||||
break;
|
break;
|
||||||
case DIR_DOWN:
|
case DIR_DOWN:
|
||||||
if (ChipCompiler.chipSpeed==1) return false;
|
if (ChipCompiler.chipSpeed == 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
ChipCompiler.chipSpeed--;
|
ChipCompiler.chipSpeed--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TextBox tb = (TextBox) room.textBoxes.elementAt(1);
|
TextBox tb = room.textBoxes.elementAt(1);
|
||||||
tb.textString = ChipCompiler.chipSpeed + "x";
|
tb.textString = ChipCompiler.chipSpeed + "x";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +1,49 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
import com.droidquest.avatars.Avatar;
|
||||||
import com.droidquest.decorations.TextBox;
|
import com.droidquest.decorations.TextBox;
|
||||||
|
|
||||||
public class SpyCam extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public SpyCam(Room r)
|
import java.awt.event.KeyEvent;
|
||||||
{
|
|
||||||
x=0; y=0;
|
public class SpyCam extends Item implements Avatar {
|
||||||
|
public SpyCam(Room r) {
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
room = r;
|
room = r;
|
||||||
width=0; height=0;
|
width = 0;
|
||||||
|
height = 0;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g, JPanel jp)
|
public void Draw(Graphics g, JPanel jp) {
|
||||||
{}
|
}
|
||||||
|
|
||||||
public boolean KeyUp(KeyEvent e)
|
public boolean KeyUp(KeyEvent e) {
|
||||||
{
|
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||||
if (e.getKeyCode() == e.VK_RIGHT)
|
|
||||||
{
|
|
||||||
SetRoom(room.rightRoom);
|
SetRoom(room.rightRoom);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_LEFT)
|
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||||
{
|
|
||||||
SetRoom(room.leftRoom);
|
SetRoom(room.leftRoom);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_UP)
|
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||||
{
|
|
||||||
SetRoom(room.upRoom);
|
SetRoom(room.upRoom);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_DOWN)
|
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||||
{
|
|
||||||
SetRoom(room.downRoom);
|
SetRoom(room.downRoom);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e.getKeyCode() == e.VK_SPACE)
|
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
|
||||||
{
|
|
||||||
level.player = level.gameCursor;
|
level.player = level.gameCursor;
|
||||||
level.currentViewer = level.player;
|
level.currentViewer = level.player;
|
||||||
for (int a=5; a<60; a++)
|
for (int a = 5; a < 60; a++) {
|
||||||
{
|
Room r = level.rooms.elementAt(a);
|
||||||
Room r = (Room) level.rooms.elementAt(a);
|
TextBox tb = r.textBoxes.elementAt(0);
|
||||||
TextBox tb = (TextBox) r.textBoxes.elementAt(0);
|
|
||||||
tb.y += 500;
|
tb.y += 500;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -58,4 +51,63 @@ public boolean KeyUp(KeyEvent e)
|
|||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,42 +1,37 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Square extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
Color color;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
public Square(int X, int Y, Room r, Color c)
|
public class Square extends Item {
|
||||||
{
|
private Color color;
|
||||||
x=X; y=Y; room=r;
|
|
||||||
width=28; height=28;
|
public Square(int X, int Y, Room r, Color c) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 28;
|
||||||
editable = true;
|
editable = true;
|
||||||
color = c;
|
color = c;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
|
||||||
g.setColor(color);
|
g.setColor(color);
|
||||||
g.fillRect(0, 0, 28, 28);
|
g.fillRect(0, 0, 28, 28);
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
|
|||||||
@@ -1,51 +1,45 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.devices.StormShield;
|
import com.droidquest.devices.StormShield;
|
||||||
|
|
||||||
public class StormCloud extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
transient int animateState=0;
|
import java.awt.image.BufferedImage;
|
||||||
transient int xDirection;
|
|
||||||
transient int yDirection;
|
|
||||||
transient int moveTimer;
|
|
||||||
transient OrangeRobot orobot;
|
|
||||||
transient WhiteRobot wrobot;
|
|
||||||
transient BlueRobot brobot;
|
|
||||||
transient StormShield stormshield;
|
|
||||||
static int maxspeed = 30;
|
|
||||||
transient int anicount=0;
|
|
||||||
|
|
||||||
public StormCloud(int X, int Y, Room r)
|
public class StormCloud extends Item {
|
||||||
{
|
private transient int animateState = 0;
|
||||||
x=X; y=Y; room=r;
|
private transient int xDirection;
|
||||||
width=28; height=32;
|
private transient int yDirection;
|
||||||
|
private transient int moveTimer;
|
||||||
|
private transient OrangeRobot orobot;
|
||||||
|
private transient WhiteRobot wrobot;
|
||||||
|
private transient BlueRobot brobot;
|
||||||
|
private transient StormShield stormshield;
|
||||||
|
private static int maxspeed = 30;
|
||||||
|
private transient int anicount = 0;
|
||||||
|
|
||||||
|
public StormCloud(int X, int Y, Room r) {
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 28;
|
||||||
|
height = 32;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[3];
|
icons = new ImageIcon[3];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[2] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[2] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
for (int a=0; a<3; a++)
|
for (int a = 0; a < 3; a++) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
g = icons[a].getImage().getGraphics();
|
g = icons[a].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -78,32 +72,32 @@ public void GenerateIcons()
|
|||||||
g.fillRect(16, 24, 4, 2);
|
g.fillRect(16, 24, 4, 2);
|
||||||
}
|
}
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
do
|
do {
|
||||||
xDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
xDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
||||||
|
}
|
||||||
while (xDirection == 0);
|
while (xDirection == 0);
|
||||||
do
|
do {
|
||||||
yDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
yDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
||||||
|
}
|
||||||
while (yDirection == 0);
|
while (yDirection == 0);
|
||||||
moveTimer = level.random.nextInt(50) + 1;
|
moveTimer = level.random.nextInt(50) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
animateState++;
|
animateState++;
|
||||||
if (animateState==3) animateState=0;
|
if (animateState == 3) {
|
||||||
|
animateState = 0;
|
||||||
|
}
|
||||||
currentIcon = icons[animateState].getImage();
|
currentIcon = icons[animateState].getImage();
|
||||||
|
|
||||||
if (anicount<3)
|
if (anicount < 3) {
|
||||||
{
|
|
||||||
Graphics g;
|
Graphics g;
|
||||||
anicount++;
|
anicount++;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
icons[animateState] = new ImageIcon(new BufferedImage(4 * 28, 3 * 32, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[animateState] = new ImageIcon(new BufferedImage(4 * 28, 3 * 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
g = icons[animateState].getImage().getGraphics();
|
g = icons[animateState].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -111,22 +105,33 @@ public void Animate()
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
g2.setBackground(transparent);
|
g2.setBackground(transparent);
|
||||||
g2.clearRect(0, 0, 4 * 28, 3 * 32);
|
g2.clearRect(0, 0, 4 * 28, 3 * 32);
|
||||||
for (int b=0; b<50; b++)
|
for (int b = 0; b < 50; b++) {
|
||||||
{
|
switch (level.random.nextInt(7)) {
|
||||||
switch (level.random.nextInt(7))
|
case 0:
|
||||||
{
|
g2.setColor(Color.white);
|
||||||
case 0: g2.setColor(Color.white); break;
|
break;
|
||||||
case 1: g2.setColor(Color.red); break;
|
case 1:
|
||||||
case 2: g2.setColor(Color.orange); break;
|
g2.setColor(Color.red);
|
||||||
case 3: g2.setColor(Color.yellow); break;
|
break;
|
||||||
case 4: g2.setColor(Color.green); break;
|
case 2:
|
||||||
case 5: g2.setColor(Color.blue); break;
|
g2.setColor(Color.orange);
|
||||||
case 6: g2.setColor(Color.magenta); break;
|
break;
|
||||||
|
case 3:
|
||||||
|
g2.setColor(Color.yellow);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
g2.setColor(Color.green);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
g2.setColor(Color.blue);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
g2.setColor(Color.magenta);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
int x1, y1, d;
|
int x1, y1, d;
|
||||||
int d2 = (3 * 32 / 2) * (3 * 32 / 2);
|
int d2 = (3 * 32 / 2) * (3 * 32 / 2);
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
x1 = level.random.nextInt(3 * 32) + 4 * 28 / 2 - 3 * 32 / 2;
|
x1 = level.random.nextInt(3 * 32) + 4 * 28 / 2 - 3 * 32 / 2;
|
||||||
y1 = level.random.nextInt(3 * 32);
|
y1 = level.random.nextInt(3 * 32);
|
||||||
int xd = (x1 - 4 * 28 / 2);
|
int xd = (x1 - 4 * 28 / 2);
|
||||||
@@ -139,115 +144,130 @@ public void Animate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveTimer--;
|
moveTimer--;
|
||||||
if (moveTimer==0)
|
if (moveTimer == 0) {
|
||||||
{
|
do {
|
||||||
do
|
|
||||||
xDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
xDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
||||||
|
}
|
||||||
while (xDirection == 0);
|
while (xDirection == 0);
|
||||||
do
|
do {
|
||||||
yDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
yDirection = level.random.nextInt(maxspeed * 2 + 1) - maxspeed;
|
||||||
|
}
|
||||||
while (yDirection == 0);
|
while (yDirection == 0);
|
||||||
moveTimer = level.random.nextInt(50) + 1;
|
moveTimer = level.random.nextInt(50) + 1;
|
||||||
}
|
}
|
||||||
if (brobot==null)
|
if (brobot == null) {
|
||||||
{
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a=0; a<level.items.size(); a++)
|
Item item = level.items.elementAt(a);
|
||||||
{
|
if (item.getClass().toString().endsWith("BlueRobot")) {
|
||||||
Item item = (Item) level.items.elementAt(a);
|
|
||||||
if (item.getClass().toString().endsWith("BlueRobot"))
|
|
||||||
brobot = (BlueRobot) item;
|
brobot = (BlueRobot) item;
|
||||||
if (item.getClass().toString().endsWith("OrangeRobot"))
|
}
|
||||||
|
if (item.getClass().toString().endsWith("OrangeRobot")) {
|
||||||
orobot = (OrangeRobot) item;
|
orobot = (OrangeRobot) item;
|
||||||
if (item.getClass().toString().endsWith("WhiteRobot"))
|
}
|
||||||
|
if (item.getClass().toString().endsWith("WhiteRobot")) {
|
||||||
wrobot = (WhiteRobot) item;
|
wrobot = (WhiteRobot) item;
|
||||||
if (item.getClass().toString().endsWith("StormShield"))
|
}
|
||||||
|
if (item.getClass().toString().endsWith("StormShield")) {
|
||||||
stormshield = (StormShield) item;
|
stormshield = (StormShield) item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (xDirection>0) MoveRight(xDirection);
|
if (xDirection > 0) {
|
||||||
if (xDirection<0) MoveLeft(-xDirection);
|
moveRight(xDirection);
|
||||||
if (yDirection>0) MoveDown(yDirection);
|
}
|
||||||
if (yDirection<0) MoveUp(-yDirection);
|
if (xDirection < 0) {
|
||||||
|
moveLeft(-xDirection);
|
||||||
|
}
|
||||||
|
if (yDirection > 0) {
|
||||||
|
moveDown(yDirection);
|
||||||
|
}
|
||||||
|
if (yDirection < 0) {
|
||||||
|
moveUp(-yDirection);
|
||||||
|
}
|
||||||
|
|
||||||
if (brobot!=null)
|
if (brobot != null) {
|
||||||
if (Overlaps(brobot))
|
if (Overlaps(brobot)) {
|
||||||
{
|
|
||||||
boolean drain = true;
|
boolean drain = true;
|
||||||
if (stormshield.room == brobot.InternalRoom)
|
if (stormshield.room == brobot.InternalRoom) {
|
||||||
if (stormshield.ports[0].value==true)
|
if (stormshield.ports[0].value) {
|
||||||
drain = false;
|
drain = false;
|
||||||
if (drain)
|
}
|
||||||
|
}
|
||||||
|
if (drain) {
|
||||||
brobot.charge -= 5000;
|
brobot.charge -= 5000;
|
||||||
if (brobot.charge<0)
|
}
|
||||||
|
if (brobot.charge < 0) {
|
||||||
brobot.charge = 0;
|
brobot.charge = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (orobot!=null)
|
if (orobot != null) {
|
||||||
if (Overlaps(orobot))
|
if (Overlaps(orobot)) {
|
||||||
{
|
|
||||||
boolean drain = true;
|
boolean drain = true;
|
||||||
if (stormshield.room == orobot.InternalRoom)
|
if (stormshield.room == orobot.InternalRoom) {
|
||||||
if (stormshield.ports[0].value==true)
|
if (stormshield.ports[0].value) {
|
||||||
drain = false;
|
drain = false;
|
||||||
if (drain)
|
}
|
||||||
|
}
|
||||||
|
if (drain) {
|
||||||
orobot.charge -= 5000;
|
orobot.charge -= 5000;
|
||||||
if (orobot.charge<0)
|
}
|
||||||
|
if (orobot.charge < 0) {
|
||||||
orobot.charge = 0;
|
orobot.charge = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (wrobot!=null)
|
if (wrobot != null) {
|
||||||
if (Overlaps(wrobot))
|
if (Overlaps(wrobot)) {
|
||||||
{
|
|
||||||
boolean drain = true;
|
boolean drain = true;
|
||||||
if (stormshield.room == wrobot.InternalRoom)
|
if (stormshield.room == wrobot.InternalRoom) {
|
||||||
if (stormshield.ports[0].value==true)
|
if (stormshield.ports[0].value) {
|
||||||
drain = false;
|
drain = false;
|
||||||
if (drain)
|
}
|
||||||
|
}
|
||||||
|
if (drain) {
|
||||||
wrobot.charge -= 5000;
|
wrobot.charge -= 5000;
|
||||||
if (wrobot.charge<0)
|
}
|
||||||
|
if (wrobot.charge < 0) {
|
||||||
wrobot.charge = 0;
|
wrobot.charge = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveRight(int dist)
|
public void moveRight(int dist) {
|
||||||
{
|
|
||||||
int newX = x + dist;
|
int newX = x + dist;
|
||||||
if (newX > 559 - 4*28/2)
|
if (newX > 559 - 4 * 28 / 2) {
|
||||||
{
|
|
||||||
xDirection = -(level.random.nextInt(maxspeed) + 1);
|
xDirection = -(level.random.nextInt(maxspeed) + 1);
|
||||||
newX = x + xDirection;
|
newX = x + xDirection;
|
||||||
}
|
}
|
||||||
x = newX;
|
x = newX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveLeft(int dist)
|
public void moveLeft(int dist) {
|
||||||
{
|
|
||||||
int newX = x - dist;
|
int newX = x - dist;
|
||||||
if (newX < 0)
|
if (newX < 0) {
|
||||||
{
|
|
||||||
xDirection = level.random.nextInt(maxspeed) + 1;
|
xDirection = level.random.nextInt(maxspeed) + 1;
|
||||||
newX = x + xDirection;
|
newX = x + xDirection;
|
||||||
}
|
}
|
||||||
x = newX;
|
x = newX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveUp(int dist)
|
public void moveUp(int dist) {
|
||||||
{
|
|
||||||
y -= dist;
|
y -= dist;
|
||||||
if (y < 0)
|
if (y < 0) {
|
||||||
{
|
|
||||||
room = room.upRoom;
|
room = room.upRoom;
|
||||||
y += 384;
|
y += 384;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveDown(int dist)
|
public void moveDown(int dist) {
|
||||||
{
|
|
||||||
y += dist;
|
y += dist;
|
||||||
if (y > 383)
|
if (y > 383) {
|
||||||
{
|
|
||||||
room = room.downRoom;
|
room = room.downRoom;
|
||||||
y -= 384;
|
y -= 384;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
|
|
||||||
public class Suitcase extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
public Suitcase(int X, int Y, Room r)
|
import java.awt.image.BufferedImage;
|
||||||
{
|
|
||||||
x=X; y=Y; room=r;
|
public class Suitcase extends Item {
|
||||||
width = 24; height=18;
|
public Suitcase(int X, int Y, Room r) {
|
||||||
width = 36; height=42;
|
x = X;
|
||||||
orgX = -6; orgY = -12;
|
y = Y;
|
||||||
|
room = r;
|
||||||
|
width = 24;
|
||||||
|
height = 18;
|
||||||
|
width = 36;
|
||||||
|
height = 42;
|
||||||
|
orgX = -6;
|
||||||
|
orgY = -12;
|
||||||
|
|
||||||
InternalRoom = new Room();
|
InternalRoom = new Room();
|
||||||
int[][] table1 = {
|
InternalRoom.RoomArray = new int[][]{
|
||||||
{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
|
||||||
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||||
@@ -34,34 +34,31 @@ public Suitcase(int X, int Y, Room r)
|
|||||||
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
|
||||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||||
};
|
};
|
||||||
InternalRoom.RoomArray = table1;
|
|
||||||
|
|
||||||
InternalRoom.portalItem = this;
|
InternalRoom.portalItem = this;
|
||||||
level.rooms.addElement(InternalRoom);
|
level.rooms.addElement(InternalRoom);
|
||||||
Material mat1 = Material.FindSimiliar(new Material(Color.blue, false, true));
|
Material mat1 = Material.FindSimiliar(new Material(Color.blue, false, true));
|
||||||
int mat1Index = level.materials.indexOf(mat1);
|
int mat1Index = level.materials.indexOf(mat1);
|
||||||
|
|
||||||
for (int rY=0; rY<12; rY++)
|
for (int rY = 0; rY < 12; rY++) {
|
||||||
for (int rX=0; rX<20; rX++)
|
for (int rX = 0; rX < 20; rX++) {
|
||||||
{
|
if (InternalRoom.RoomArray[rY][rX] == 1) {
|
||||||
if (InternalRoom.RoomArray[rY][rX]==1)
|
|
||||||
InternalRoom.RoomArray[rY][rX] = mat1Index;
|
InternalRoom.RoomArray[rY][rX] = mat1Index;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[1];
|
icons = new ImageIcon[1];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
Graphics g;
|
Graphics g;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,31 @@
|
|||||||
package com.droidquest.items;
|
package com.droidquest.items;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
|
|
||||||
public class Sweeper extends Item
|
import javax.swing.*;
|
||||||
{
|
import java.awt.*;
|
||||||
int animationState;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
public class Sweeper extends Item {
|
||||||
|
private int animationState;
|
||||||
// 1=Moving Left
|
// 1=Moving Left
|
||||||
// 2=Stopped and facing camera
|
// 2=Stopped and facing camera
|
||||||
// 3=Moving Right
|
// 3=Moving Right
|
||||||
// 4=Stopped and facing camera
|
// 4=Stopped and facing camera
|
||||||
|
|
||||||
public Sweeper(int X, int Y, Room r)
|
public Sweeper(int X, int Y, Room r) {
|
||||||
{
|
x = X;
|
||||||
x=X; y=Y;
|
y = Y;
|
||||||
room = r;
|
room = r;
|
||||||
width=48; height=32;
|
width = 48;
|
||||||
|
height = 32;
|
||||||
grabbable = false;
|
grabbable = false;
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
animationState = 1;
|
animationState = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateIcons()
|
public void GenerateIcons() {
|
||||||
{
|
|
||||||
icons = new ImageIcon[3];
|
icons = new ImageIcon[3];
|
||||||
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[0] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
icons[1] = new ImageIcon(new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR));
|
||||||
@@ -39,12 +35,10 @@ public void GenerateIcons()
|
|||||||
Color transparent = new Color(0, 0, 0, 0);
|
Color transparent = new Color(0, 0, 0, 0);
|
||||||
|
|
||||||
// sweeper1.gif = Moving Right
|
// sweeper1.gif = Moving Right
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[0].getImage().getGraphics();
|
g = icons[0].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -78,12 +72,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(32, 28, 4, 2);
|
g.fillRect(32, 28, 4, 2);
|
||||||
|
|
||||||
// sweeper2.gif = Looking Straight
|
// sweeper2.gif = Looking Straight
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[1].getImage().getGraphics();
|
g = icons[1].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -114,12 +106,10 @@ public void GenerateIcons()
|
|||||||
g.fillRect(30, 28, 4, 2);
|
g.fillRect(30, 28, 4, 2);
|
||||||
|
|
||||||
// sweeper3.gif = Moving Left
|
// sweeper3.gif = Moving Left
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
g = icons[2].getImage().getGraphics();
|
g = icons[2].getImage().getGraphics();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e) {
|
||||||
{
|
|
||||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -152,8 +142,7 @@ public void GenerateIcons()
|
|||||||
g.fillRect(16, 24, 4, 2);
|
g.fillRect(16, 24, 4, 2);
|
||||||
g.fillRect(12, 28, 4, 2);
|
g.fillRect(12, 28, 4, 2);
|
||||||
|
|
||||||
switch (animationState)
|
switch (animationState) {
|
||||||
{
|
|
||||||
case 1:
|
case 1:
|
||||||
currentIcon = icons[0].getImage();
|
currentIcon = icons[0].getImage();
|
||||||
break;
|
break;
|
||||||
@@ -167,30 +156,27 @@ public void GenerateIcons()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
for (int a = 0; a < level.items.size(); a++) {
|
||||||
for (int a = 0; a< level.items.size(); a++)
|
Item testItem = level.items.elementAt(a);
|
||||||
{
|
if (testItem.carriedBy == null) {
|
||||||
Item testItem = (Item) level.items.elementAt(a);
|
if (Overlaps(testItem)) {
|
||||||
if (testItem.carriedBy == null)
|
|
||||||
if (Overlaps(testItem))
|
|
||||||
{
|
|
||||||
testItem.x = 280;
|
testItem.x = 280;
|
||||||
testItem.y = 192;
|
testItem.y = 192;
|
||||||
testItem.SetRoom((Room) level.rooms.elementAt(1));
|
testItem.SetRoom(level.rooms.elementAt(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (animationState)
|
switch (animationState) {
|
||||||
{
|
|
||||||
case 1:
|
case 1:
|
||||||
if (room==(Room) level.rooms.elementAt(14) && x>=120)
|
if (room == level.rooms.elementAt(14) && x >= 120) {
|
||||||
{
|
|
||||||
animationState = 2;
|
animationState = 2;
|
||||||
currentIcon = icons[1].getImage();
|
currentIcon = icons[1].getImage();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
MoveRight(8);
|
moveRight(8);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@@ -199,13 +185,13 @@ public void Animate()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (room==(Room) level.rooms.elementAt(2) && x<=504)
|
if (room == level.rooms.elementAt(2) && x <= 504) {
|
||||||
{
|
|
||||||
animationState = 4;
|
animationState = 4;
|
||||||
currentIcon = icons[2].getImage();
|
currentIcon = icons[2].getImage();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
MoveLeft(8);
|
moveLeft(8);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
|||||||
@@ -3,37 +3,32 @@ package com.droidquest.items;
|
|||||||
import com.droidquest.Room;
|
import com.droidquest.Room;
|
||||||
import com.droidquest.materials.Switch;
|
import com.droidquest.materials.Switch;
|
||||||
|
|
||||||
public class Switch4A extends Switch
|
public class Switch4A extends Switch {
|
||||||
{
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int doorState=0;
|
private int doorState = 0;
|
||||||
transient Room room = null;
|
transient Room room = null;
|
||||||
|
|
||||||
public Switch4A()
|
public Switch4A() {
|
||||||
{
|
|
||||||
super(Switch.ROT_UP);
|
super(Switch.ROT_UP);
|
||||||
GenerateIcons();
|
GenerateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TouchedByItem(Item item)
|
public void TouchedByItem(Item item) {
|
||||||
{
|
if (!value) {
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
value = true;
|
value = true;
|
||||||
count++;
|
count++;
|
||||||
room = item.room;
|
room = item.room;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Animate()
|
public void Animate() {
|
||||||
{
|
|
||||||
super.Animate();
|
super.Animate();
|
||||||
|
|
||||||
if (doorState==0 && count==4)
|
if (doorState == 0 && count == 4) {
|
||||||
doorState = 1;
|
doorState = 1;
|
||||||
|
}
|
||||||
|
|
||||||
switch (doorState)
|
switch (doorState) {
|
||||||
{
|
|
||||||
case 1:
|
case 1:
|
||||||
room.SetMaterial(8, 3, 0);
|
room.SetMaterial(8, 3, 0);
|
||||||
room.SetMaterial(9, 3, 0);
|
room.SetMaterial(9, 3, 0);
|
||||||
@@ -108,43 +103,52 @@ public void Animate()
|
|||||||
case 4:
|
case 4:
|
||||||
Room temproom = room.rightRoom; // KeyTunnel Left
|
Room temproom = room.rightRoom; // KeyTunnel Left
|
||||||
temproom.SetMaterial(2, 3, 0);
|
temproom.SetMaterial(2, 3, 0);
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
temproom.SetMaterial(8, a + 1, 0);
|
temproom.SetMaterial(8, a + 1, 0);
|
||||||
temproom.SetMaterial(12, a + 1, 0);
|
temproom.SetMaterial(12, a + 1, 0);
|
||||||
temproom.SetMaterial(16, a + 1, 0);
|
temproom.SetMaterial(16, a + 1, 0);
|
||||||
}
|
}
|
||||||
temproom = temproom.rightRoom; // KeyTunnel Right
|
temproom = temproom.rightRoom; // KeyTunnel Right
|
||||||
for (int a=0; a<8; a++)
|
for (int a = 0; a < 8; a++) {
|
||||||
{
|
|
||||||
temproom.SetMaterial(3, a + 1, 0);
|
temproom.SetMaterial(3, a + 1, 0);
|
||||||
temproom.SetMaterial(7, a + 1, 0);
|
temproom.SetMaterial(7, a + 1, 0);
|
||||||
temproom.SetMaterial(11, a + 1, 0);
|
temproom.SetMaterial(11, a + 1, 0);
|
||||||
}
|
}
|
||||||
temproom = room.leftRoom; // MineField top right
|
temproom = room.leftRoom; // MineField top right
|
||||||
for (int Y=0; Y<12; Y++)
|
for (int Y = 0; Y < 12; Y++) {
|
||||||
for (int X=0; X<20; X++)
|
for (int X = 0; X < 20; X++) {
|
||||||
if (temproom.RoomArray[Y][X]==8)
|
if (temproom.RoomArray[Y][X] == 8) {
|
||||||
temproom.SetMaterial(X, Y, 11);
|
temproom.SetMaterial(X, Y, 11);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
temproom = temproom.leftRoom; // MineField top left
|
temproom = temproom.leftRoom; // MineField top left
|
||||||
for (int Y=0; Y<12; Y++)
|
for (int Y = 0; Y < 12; Y++) {
|
||||||
for (int X=0; X<20; X++)
|
for (int X = 0; X < 20; X++) {
|
||||||
{
|
if (temproom.RoomArray[Y][X] == 8) {
|
||||||
if (temproom.RoomArray[Y][X]==8)
|
|
||||||
temproom.SetMaterial(X, Y, 11);
|
temproom.SetMaterial(X, Y, 11);
|
||||||
if (temproom.RoomArray[Y][X]==16)
|
}
|
||||||
|
if (temproom.RoomArray[Y][X] == 16) {
|
||||||
temproom.SetMaterial(X, Y, 0);
|
temproom.SetMaterial(X, Y, 0);
|
||||||
}
|
}
|
||||||
temproom = temproom.downRoom; // MineField botom left
|
}
|
||||||
for (int Y=0; Y<12; Y++)
|
}
|
||||||
for (int X=0; X<20; X++)
|
temproom = temproom.downRoom; // MineField bottom left
|
||||||
if (temproom.RoomArray[Y][X]==8)
|
for (int Y = 0; Y < 12; Y++) {
|
||||||
|
for (int X = 0; X < 20; X++) {
|
||||||
|
if (temproom.RoomArray[Y][X] == 8) {
|
||||||
temproom.SetMaterial(X, Y, 11);
|
temproom.SetMaterial(X, Y, 11);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
temproom = temproom.rightRoom; // MineField bottom right
|
temproom = temproom.rightRoom; // MineField bottom right
|
||||||
for (int Y=0; Y<12; Y++)
|
for (int Y = 0; Y < 12; Y++) {
|
||||||
for (int X=0; X<20; X++)
|
for (int X = 0; X < 20; X++) {
|
||||||
if (temproom.RoomArray[Y][X]==8)
|
if (temproom.RoomArray[Y][X] == 8) {
|
||||||
temproom.SetMaterial(X, Y, 11);
|
temproom.SetMaterial(X, Y, 11);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
temproom = room.upRoom;
|
temproom = room.upRoom;
|
||||||
temproom.SetMaterial(19, 5, 0);
|
temproom.SetMaterial(19, 5, 0);
|
||||||
temproom.SetMaterial(19, 6, 0);
|
temproom.SetMaterial(19, 6, 0);
|
||||||
|
|||||||
@@ -3,29 +3,24 @@ package com.droidquest.items;
|
|||||||
import com.droidquest.materials.Material;
|
import com.droidquest.materials.Material;
|
||||||
import com.droidquest.materials.Switch;
|
import com.droidquest.materials.Switch;
|
||||||
|
|
||||||
public class Switch4B extends Switch
|
public class Switch4B extends Switch {
|
||||||
{
|
private transient Switch4A sw = null;
|
||||||
transient Switch4A sw = null;
|
|
||||||
|
|
||||||
public Switch4B()
|
public Switch4B() {
|
||||||
{
|
|
||||||
super(Switch.ROT_RIGHT);
|
super(Switch.ROT_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TouchedByItem(Item item)
|
public void TouchedByItem(Item item) {
|
||||||
{
|
if (sw == null) {
|
||||||
if (sw==null)
|
for (int a = 0; a < level.materials.size(); a++) {
|
||||||
{
|
Material mat = level.materials.elementAt(a);
|
||||||
for (int a=0; a<level.materials.size(); a++)
|
if (mat instanceof Switch4A) {
|
||||||
{
|
|
||||||
Material mat = (Material) level.materials.elementAt(a);
|
|
||||||
if (mat instanceof Switch4A)
|
|
||||||
sw = (Switch4A) mat;
|
sw = (Switch4A) mat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!value)
|
if (!value) {
|
||||||
{
|
|
||||||
value = true;
|
value = true;
|
||||||
sw.count++;
|
sw.count++;
|
||||||
sw.room = item.room;
|
sw.room = item.room;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user