Refactored and cleaned up code. Modernized some constructs.
This commit is contained in:
@@ -1,40 +1,37 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.avatars.GameCursor;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class AntiPlayer extends Material
|
||||
{
|
||||
// Sends the Player (in or out of a robot) to the Main Office
|
||||
import java.awt.*;
|
||||
|
||||
public AntiPlayer()
|
||||
{
|
||||
super(Color.black,true,false);
|
||||
}
|
||||
public class AntiPlayer extends Material {
|
||||
// Sends the Player (in or out of a robot) to the Main Office
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
boolean trigger = false;
|
||||
if (item == level.player)
|
||||
trigger = true;
|
||||
else if (item instanceof GenericRobot)
|
||||
{
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item)
|
||||
trigger=true;;
|
||||
}
|
||||
|
||||
if (trigger)
|
||||
{
|
||||
level.player.room = (Room) level.rooms.elementAt(40);
|
||||
level.player.x = 10*28;
|
||||
level.player.y = 5*32;
|
||||
level.currentViewer = level.player;
|
||||
}
|
||||
}
|
||||
public AntiPlayer() {
|
||||
super(Color.black, true, false);
|
||||
}
|
||||
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
boolean trigger = false;
|
||||
if (item == level.player) {
|
||||
trigger = true;
|
||||
}
|
||||
else if (item instanceof GenericRobot) {
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item) {
|
||||
trigger = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (trigger) {
|
||||
level.player.room = level.rooms.elementAt(40);
|
||||
level.player.x = 10 * 28;
|
||||
level.player.y = 5 * 32;
|
||||
level.currentViewer = level.player;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,74 +4,71 @@ import java.awt.Color;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class AutoRunner extends Material
|
||||
{
|
||||
int direction;
|
||||
public static final int UP =0;
|
||||
public static final int RIGHTUP =1;
|
||||
public static final int RIGHT =2;
|
||||
public static final int RIGHTDOWN=3;
|
||||
public static final int DOWN =4;
|
||||
public static final int LEFTDOWN =5;
|
||||
public static final int LEFT =6;
|
||||
public static final int LEFTUP =7;
|
||||
public static final int STOP =8;
|
||||
public class AutoRunner extends Material {
|
||||
private int direction;
|
||||
public static final int UP = 0;
|
||||
public static final int RIGHTUP = 1;
|
||||
public static final int RIGHT = 2;
|
||||
public static final int RIGHTDOWN = 3;
|
||||
public static final int DOWN = 4;
|
||||
public static final int LEFTDOWN = 5;
|
||||
public static final int LEFT = 6;
|
||||
public static final int LEFTUP = 7;
|
||||
public static final int STOP = 8;
|
||||
|
||||
public AutoRunner(int d)
|
||||
{
|
||||
super(Color.black, true, false);
|
||||
direction = d;
|
||||
}
|
||||
public AutoRunner(int d) {
|
||||
super(Color.black, true, false);
|
||||
direction = d;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item == level.player)
|
||||
switch (direction)
|
||||
{
|
||||
case UP:
|
||||
level.player.autoX= level.player.x;
|
||||
level.player.autoY= level.player.y-32;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case RIGHTUP:
|
||||
level.player.autoX= level.player.x+28;
|
||||
level.player.autoY= level.player.y-32;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case RIGHT:
|
||||
level.player.autoX= level.player.x+28;
|
||||
level.player.autoY= level.player.y;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case RIGHTDOWN:
|
||||
level.player.autoX= level.player.x+28;
|
||||
level.player.autoY= level.player.y+32;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case DOWN:
|
||||
level.player.autoX= level.player.x;
|
||||
level.player.autoY= level.player.y+32;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case LEFTDOWN:
|
||||
level.player.autoX= level.player.x-28;
|
||||
level.player.autoY= level.player.y+32;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case LEFT:
|
||||
level.player.autoX= level.player.x-28;
|
||||
level.player.autoY= level.player.y;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case LEFTUP:
|
||||
level.player.autoX= level.player.x-28;
|
||||
level.player.autoY= level.player.y-32;
|
||||
level.player.automove=1;
|
||||
break;
|
||||
case STOP:
|
||||
level.player.automove=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
switch (direction) {
|
||||
case UP:
|
||||
level.player.autoX = level.player.x;
|
||||
level.player.autoY = level.player.y - 32;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case RIGHTUP:
|
||||
level.player.autoX = level.player.x + 28;
|
||||
level.player.autoY = level.player.y - 32;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case RIGHT:
|
||||
level.player.autoX = level.player.x + 28;
|
||||
level.player.autoY = level.player.y;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case RIGHTDOWN:
|
||||
level.player.autoX = level.player.x + 28;
|
||||
level.player.autoY = level.player.y + 32;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case DOWN:
|
||||
level.player.autoX = level.player.x;
|
||||
level.player.autoY = level.player.y + 32;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case LEFTDOWN:
|
||||
level.player.autoX = level.player.x - 28;
|
||||
level.player.autoY = level.player.y + 32;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case LEFT:
|
||||
level.player.autoX = level.player.x - 28;
|
||||
level.player.autoY = level.player.y;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case LEFTUP:
|
||||
level.player.autoX = level.player.x - 28;
|
||||
level.player.autoY = level.player.y - 32;
|
||||
level.player.automove = 1;
|
||||
break;
|
||||
case STOP:
|
||||
level.player.automove = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,77 +10,69 @@ import com.droidquest.items.Crystal;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.levels.Level;
|
||||
|
||||
public class BatteryIn extends Material
|
||||
{
|
||||
// Charges the Battery when an Energy Crystal is passed over it.
|
||||
public class BatteryIn extends Material {
|
||||
// Charges the Battery when an Energy Crystal is passed over it.
|
||||
|
||||
public void BatteryIn()
|
||||
{
|
||||
passable = true;
|
||||
GenerateIcons();
|
||||
}
|
||||
public void BatteryIn() {
|
||||
passable = true;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public transient Item robot;
|
||||
public transient Item robot;
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
icon = new ImageIcon(bi);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12,4,4,24);
|
||||
g.fillRect(8,8,12,16);
|
||||
g.fillRect(4,10,20,12);
|
||||
g.fillRect(0,14,28,4);
|
||||
g.fillRect(0,8,4,2);
|
||||
g.fillRect(0,22,4,2);
|
||||
g.fillRect(24,8,4,2);
|
||||
g.fillRect(24,22,4,2);
|
||||
passable = true;
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
icon = new ImageIcon(bi);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item.charge > 0)
|
||||
{
|
||||
// Check to see if it's a pure Crystal, not a Black Crystal
|
||||
if (item instanceof Crystal)
|
||||
{
|
||||
int empty = 100000 - robot.charge;
|
||||
if (empty >= item.charge)
|
||||
{
|
||||
robot.charge += item.charge;
|
||||
item.charge=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.charge-=empty;
|
||||
robot.charge=100000;
|
||||
}
|
||||
level.PlaySound(robot.InternalRoom, Level.DISCHARGESOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12, 4, 4, 24);
|
||||
g.fillRect(8, 8, 12, 16);
|
||||
g.fillRect(4, 10, 20, 12);
|
||||
g.fillRect(0, 14, 28, 4);
|
||||
g.fillRect(0, 8, 4, 2);
|
||||
g.fillRect(0, 22, 4, 2);
|
||||
g.fillRect(24, 8, 4, 2);
|
||||
g.fillRect(24, 22, 4, 2);
|
||||
passable = true;
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (robot != null)
|
||||
if (robot == ((BatteryIn)mat).robot)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item.charge > 0) {
|
||||
// Check to see if it's a pure Crystal, not a Black Crystal
|
||||
if (item instanceof Crystal) {
|
||||
int empty = 100000 - robot.charge;
|
||||
if (empty >= item.charge) {
|
||||
robot.charge += item.charge;
|
||||
item.charge = 0;
|
||||
}
|
||||
else {
|
||||
item.charge -= empty;
|
||||
robot.charge = 100000;
|
||||
}
|
||||
level.PlaySound(robot.InternalRoom, Level.DISCHARGESOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (robot != null) {
|
||||
if (robot == ((BatteryIn) mat).robot) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@@ -8,71 +8,64 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class BatteryOut extends Material
|
||||
{
|
||||
// Graph that shows the battery charge in a Generic Robot
|
||||
public class BatteryOut extends Material {
|
||||
// Graph that shows the battery charge in a Generic Robot
|
||||
|
||||
public BatteryOut()
|
||||
{
|
||||
passable = true;
|
||||
GenerateIcons();
|
||||
}
|
||||
public BatteryOut() {
|
||||
passable = true;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public transient Item robot;
|
||||
public transient Item robot;
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
icon = new ImageIcon(bi);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(4,0,8,32);
|
||||
g.fillRect(18,0,10,32);
|
||||
g.fillRect(0,8,4,4);
|
||||
g.fillRect(0,20,4,4);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
icon = new ImageIcon(bi);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = icon.getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12,0,6,32);
|
||||
g.setColor(new Color(255,128,0));
|
||||
if (robot!=null)
|
||||
{
|
||||
int fuel = (robot.charge+1564) / 3125; // 3125 = 100,000/32
|
||||
g.fillRect(12,32-fuel,6,fuel);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(4, 0, 8, 32);
|
||||
g.fillRect(18, 0, 10, 32);
|
||||
g.fillRect(0, 8, 4, 4);
|
||||
g.fillRect(0, 20, 4, 4);
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (robot != null)
|
||||
if (robot == ((BatteryOut)mat).robot)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void Animate() {
|
||||
Graphics g;
|
||||
try {
|
||||
g = icon.getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12, 0, 6, 32);
|
||||
g.setColor(new Color(255, 128, 0));
|
||||
if (robot != null) {
|
||||
int fuel = (robot.charge + 1564) / 3125; // 3125 = 100,000/32
|
||||
g.fillRect(12, 32 - fuel, 6, fuel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (robot != null) {
|
||||
if (robot == ((BatteryOut) mat).robot) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,213 +11,220 @@ import com.droidquest.Room;
|
||||
import com.droidquest.items.BinaryKey;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class BinaryLock extends Material
|
||||
{
|
||||
// Binary shaped Generic Lock; Used to redefine materials in the local room.
|
||||
public class BinaryLock extends Material {
|
||||
// Binary shaped Generic Lock; Used to redefine materials in the local room.
|
||||
|
||||
int doorState=0;
|
||||
transient BinaryKey latchKey = null;
|
||||
transient Room room;
|
||||
transient Room currentRoom;
|
||||
static public int NARROW = -1;
|
||||
static public int WIDE = -2;
|
||||
static public int REMOVE = -3;
|
||||
static public int RESET = -4;
|
||||
static public int LEFT = -5;
|
||||
static public int RIGHT = -6;
|
||||
static public int UP = -7;
|
||||
static public int DOWN = -8;
|
||||
int[][] program;
|
||||
private int doorState = 0;
|
||||
private transient BinaryKey latchKey = null;
|
||||
private transient Room room;
|
||||
private transient Room currentRoom;
|
||||
static public int NARROW = -1;
|
||||
private static int WIDE = -2;
|
||||
private static int REMOVE = -3;
|
||||
private static int RESET = -4;
|
||||
private static int LEFT = -5;
|
||||
private static int RIGHT = -6;
|
||||
private static int UP = -7;
|
||||
private static int DOWN = -8;
|
||||
int[][] program;
|
||||
|
||||
// program[][] is an array of arrays. Each array holds the behavior of a
|
||||
// single value of doorState.
|
||||
//
|
||||
// A single array can hold one of the following:
|
||||
// program[][] is an array of arrays. Each array holds the behavior of a
|
||||
// single value of doorState.
|
||||
//
|
||||
// A single array can hold one of the following:
|
||||
// A single value of Lock.NARROW, Lock.WIDE, or Lock.REMOVE to define a pause
|
||||
// A single value of RESET, LEFT, RIGHT, UP, or DOWN to change rooms
|
||||
// A series of triplets (X,Y,M) with the XY position and the Materials
|
||||
// Index.
|
||||
//
|
||||
// Pause value can be one of the following:
|
||||
// Lock.NARROW = Pause until the key is placed once more precisely into the lock.
|
||||
// Lock.WIDE = Pause until the key is placed ANYWHERE into the lock
|
||||
// Lock.REMOVE = Pause until the key is removed.
|
||||
//
|
||||
// Pause values automatically reset the current Room to the original value.
|
||||
//
|
||||
// Lock.RESET = Set current room to the original room value
|
||||
// Lock.LEFT = Change the current room to the room's left room
|
||||
// Lock.RIGHT = Same, but right
|
||||
// Lock.UP = Same, but up
|
||||
// Lock.DOWN = Same, but down
|
||||
//
|
||||
// The room is normally the key's rom when the key touches the lock, and
|
||||
// the triplets change the materials within the current room. With these
|
||||
// commands the current room can be changed so other rooms can be
|
||||
// manipulated.
|
||||
//
|
||||
// Here's a sample program[][]
|
||||
//
|
||||
// int[][] = {
|
||||
//
|
||||
// Pause value can be one of the following:
|
||||
// Lock.NARROW = Pause until the key is placed once more precisely into the lock.
|
||||
// Lock.WIDE = Pause until the key is placed ANYWHERE into the lock
|
||||
// Lock.REMOVE = Pause until the key is removed.
|
||||
//
|
||||
// Pause values automatically reset the current Room to the original value.
|
||||
//
|
||||
// Lock.RESET = Set current room to the original room value
|
||||
// Lock.LEFT = Change the current room to the room's left room
|
||||
// Lock.RIGHT = Same, but right
|
||||
// Lock.UP = Same, but up
|
||||
// Lock.DOWN = Same, but down
|
||||
//
|
||||
// The room is normally the key's rom when the key touches the lock, and
|
||||
// the triplets change the materials within the current room. With these
|
||||
// commands the current room can be changed so other rooms can be
|
||||
// manipulated.
|
||||
//
|
||||
// Here's a sample program[][]
|
||||
//
|
||||
// int[][] = {
|
||||
// {Lock.NARROW}, // Wait for precise placement
|
||||
// {10,5,0, 11,5,0}, // Converts two spots to holes
|
||||
// {10,6,0, 11,6,0}, // Same, but lower
|
||||
// {Lock.NARROW}, // Wait again
|
||||
// {10,6,1, 11,6,1}, // Converts two spots to wall
|
||||
// {10,5,1, 11,5,1} // same, in reverse, go to pause.
|
||||
// };
|
||||
//
|
||||
// };
|
||||
//
|
||||
|
||||
public BinaryLock(Color lc, int[][] prg)
|
||||
{
|
||||
super(true, false);
|
||||
color = lc;
|
||||
program = prg;
|
||||
GenerateIcons();
|
||||
}
|
||||
public BinaryLock(Color lc, int[][] prg) {
|
||||
super(true, false);
|
||||
color = lc;
|
||||
program = prg;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(color);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(16,2,4,8);
|
||||
g.fillRect(16,12,4,2);
|
||||
g.fillRect(12,14,4,4);
|
||||
g.fillRect(20,14,4,4);
|
||||
g.fillRect(16,18,4,2);
|
||||
g.fillRect(16,22,4,8);
|
||||
g.fillRect(24,4,4,4);
|
||||
g.fillRect(24,24,4,4);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (program == ((BinaryLock)mat).program)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
g.setColor(color);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(16, 2, 4, 8);
|
||||
g.fillRect(16, 12, 4, 2);
|
||||
g.fillRect(12, 14, 4, 4);
|
||||
g.fillRect(20, 14, 4, 4);
|
||||
g.fillRect(16, 18, 4, 2);
|
||||
g.fillRect(16, 22, 4, 8);
|
||||
g.fillRect(24, 4, 4, 4);
|
||||
g.fillRect(24, 24, 4, 4);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
if (doorState == program.length)
|
||||
doorState = 0;
|
||||
|
||||
if (latchKey==null)
|
||||
return;
|
||||
|
||||
|
||||
if (program[doorState].length > 1)
|
||||
{
|
||||
for (int a=0; a<program[doorState].length/3; a++)
|
||||
currentRoom.SetMaterial(program[doorState][a*3],
|
||||
program[doorState][a*3+1],
|
||||
program[doorState][a*3+2]);
|
||||
doorState++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (program[doorState][0]==REMOVE)
|
||||
{
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int bigXL = d.width/28;
|
||||
int bigXR = (d.width + latchKey.getWidth()) / 28;
|
||||
int bigYT = d.height/32;
|
||||
int bigYB = (d.height + latchKey.getHeight()) / 32;
|
||||
boolean flag = false;
|
||||
if (room.MaterialArray[bigYT][bigXL] == this) flag=true;
|
||||
if (room.MaterialArray[bigYT][bigXR] == this) flag=true;
|
||||
if (room.MaterialArray[bigYB][bigXL] == this) flag=true;
|
||||
if (room.MaterialArray[bigYB][bigXR] == this) flag=true;
|
||||
if (!flag)
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==RESET)
|
||||
{
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==LEFT)
|
||||
{
|
||||
currentRoom = currentRoom.leftRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==RIGHT)
|
||||
{
|
||||
currentRoom = currentRoom.rightRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==UP)
|
||||
{
|
||||
currentRoom = currentRoom.upRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==DOWN)
|
||||
{
|
||||
currentRoom = currentRoom.downRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length)
|
||||
doorState = 0;
|
||||
}
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (program == ((BinaryLock) mat).program) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item instanceof BinaryKey)
|
||||
{
|
||||
latchKey = (BinaryKey) item;
|
||||
room = latchKey.room;
|
||||
}
|
||||
|
||||
if (latchKey==null)
|
||||
return;
|
||||
|
||||
if (latchKey != item)
|
||||
return;
|
||||
|
||||
if (program[doorState].length==1)
|
||||
{
|
||||
if (program[doorState][0]==NARROW)
|
||||
{
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int X = d.width % 28;
|
||||
int Y = d.height % 32;
|
||||
if (X>=10 && X <=14
|
||||
&& Y<=4)
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==WIDE)
|
||||
{
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length)
|
||||
doorState = 0;
|
||||
|
||||
}
|
||||
public void Animate() {
|
||||
if (doorState == program.length) {
|
||||
doorState = 0;
|
||||
}
|
||||
|
||||
}
|
||||
if (latchKey == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (program[doorState].length > 1) {
|
||||
for (int a = 0; a < program[doorState].length / 3; a++) {
|
||||
currentRoom.SetMaterial(program[doorState][a * 3],
|
||||
program[doorState][a * 3 + 1],
|
||||
program[doorState][a * 3 + 2]);
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else {
|
||||
if (program[doorState][0] == REMOVE) {
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int bigXL = d.width / 28;
|
||||
int bigXR = (d.width + latchKey.getWidth()) / 28;
|
||||
int bigYT = d.height / 32;
|
||||
int bigYB = (d.height + latchKey.getHeight()) / 32;
|
||||
boolean flag = false;
|
||||
if (room.MaterialArray[bigYT][bigXL] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (room.MaterialArray[bigYT][bigXR] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (room.MaterialArray[bigYB][bigXL] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (room.MaterialArray[bigYB][bigXR] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (!flag) {
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
else if (program[doorState][0] == RESET) {
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == LEFT) {
|
||||
currentRoom = currentRoom.leftRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == RIGHT) {
|
||||
currentRoom = currentRoom.rightRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == UP) {
|
||||
currentRoom = currentRoom.upRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == DOWN) {
|
||||
currentRoom = currentRoom.downRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length) {
|
||||
doorState = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item instanceof BinaryKey) {
|
||||
latchKey = (BinaryKey) item;
|
||||
room = latchKey.room;
|
||||
}
|
||||
|
||||
if (latchKey == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (latchKey != item) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (program[doorState].length == 1) {
|
||||
if (program[doorState][0] == NARROW) {
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int X = d.width % 28;
|
||||
int Y = d.height % 32;
|
||||
if (X >= 10 && X <= 14
|
||||
&& Y <= 4) {
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
else if (program[doorState][0] == WIDE) {
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length) {
|
||||
doorState = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,190 +13,173 @@ import com.droidquest.decorations.Graphix;
|
||||
import com.droidquest.decorations.TextBox;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class BlueGridSwitch extends Material
|
||||
{
|
||||
// This object turns off the Blue grid (and HotWires), and opens the
|
||||
// doorway to the room above.
|
||||
public class BlueGridSwitch extends Material {
|
||||
// This object turns off the Blue grid (and HotWires), and opens the
|
||||
// doorway to the room above.
|
||||
|
||||
public ImageIcon[] images;
|
||||
boolean value=false;
|
||||
int animationState=0;
|
||||
transient Room room=null;
|
||||
Date timeout;
|
||||
transient TextBox textbox = null;
|
||||
private ImageIcon[] images;
|
||||
private boolean value = false;
|
||||
private int animationState = 0;
|
||||
private transient Room room = null;
|
||||
private Date timeout;
|
||||
private transient TextBox textbox = null;
|
||||
|
||||
public BlueGridSwitch()
|
||||
{
|
||||
super(true, false);
|
||||
}
|
||||
public BlueGridSwitch() {
|
||||
super(true, false);
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
images = new ImageIcon[2];
|
||||
for (int a=0; a<2; a++)
|
||||
{
|
||||
images[a] = new ImageIcon(new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
Color c;
|
||||
if (a==0)
|
||||
c = Color.white;
|
||||
else
|
||||
c = new Color(255,128,0);
|
||||
|
||||
g2.setColor(c);
|
||||
g.fillRect(0,0,28,32);
|
||||
g2.setColor(Color.black);
|
||||
g.fillRect(4,14,20,4);
|
||||
g.fillRect(8,12,12,8);
|
||||
g.fillRect(12,8,4,16);
|
||||
g2.setColor(c);
|
||||
g.fillRect(12,14,4,4);
|
||||
}
|
||||
|
||||
icon = images[0];
|
||||
if (value)
|
||||
icon = images[1];
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
images = new ImageIcon[2];
|
||||
for (int a = 0; a < 2; a++) {
|
||||
images[a] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try {
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
Color c;
|
||||
if (a == 0) {
|
||||
c = Color.white;
|
||||
}
|
||||
else {
|
||||
c = new Color(255, 128, 0);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (animationState==0)
|
||||
{
|
||||
animationState = 1;
|
||||
room = item.room;
|
||||
timeout = new Date(new Date().getTime() + 20000);
|
||||
textbox = (TextBox) item.room.textBoxes.elementAt(0);
|
||||
}
|
||||
}
|
||||
g2.setColor(c);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g2.setColor(Color.black);
|
||||
g.fillRect(4, 14, 20, 4);
|
||||
g.fillRect(8, 12, 12, 8);
|
||||
g.fillRect(12, 8, 4, 16);
|
||||
g2.setColor(c);
|
||||
g.fillRect(12, 14, 4, 4);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
icon = images[0];
|
||||
if (value)
|
||||
{
|
||||
icon = images[1];
|
||||
Date now = new Date();
|
||||
long timer = timeout.getTime() - now.getTime();
|
||||
if (timer > 0)
|
||||
{
|
||||
long seconds = Math.abs(timer/1000) + 1;
|
||||
if (seconds<10)
|
||||
textbox.textString = "0" + seconds;
|
||||
else
|
||||
textbox.textString = "" + seconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
textbox.textString = "00";
|
||||
animationState++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch (animationState)
|
||||
{
|
||||
case 1:value=true;
|
||||
room.SetMaterial(2,0,0);
|
||||
room.upRoom.SetMaterial(2,11,0);
|
||||
for (int a=0; a<level.materials.size(); a++)
|
||||
{
|
||||
Material mat = (Material) level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires)
|
||||
{
|
||||
HotWires hw = (HotWires) mat;
|
||||
if (hw.wall==0)
|
||||
hw.value=false;
|
||||
}
|
||||
}
|
||||
for (int a=0; a<5; a++)
|
||||
{
|
||||
Graphix gr = (Graphix) room.graphix.elementAt(a);
|
||||
String[] filelist = {"whiteHorizontal.gif"};
|
||||
gr.filenames = filelist;
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
for (int a=0; a<5; a++)
|
||||
{
|
||||
Graphix gr = (Graphix) room.graphix.elementAt(a+5);
|
||||
String[] filelist = {"whiteVertical.gif"};
|
||||
gr.filenames = filelist;
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
animationState++;
|
||||
break;
|
||||
case 2:
|
||||
room.SetMaterial(3,0,0);
|
||||
room.upRoom.SetMaterial(3,11,0);
|
||||
animationState++;
|
||||
break;
|
||||
case 3:
|
||||
room.SetMaterial(4,0,0);
|
||||
room.upRoom.SetMaterial(4,11,0);
|
||||
animationState++;
|
||||
break;
|
||||
case 4:
|
||||
room.SetMaterial(5,0,0);
|
||||
room.upRoom.SetMaterial(5,11,0);
|
||||
animationState++;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
room.SetMaterial(5,0,9);
|
||||
room.upRoom.SetMaterial(5,11,9);
|
||||
value = false;
|
||||
for (int a=0; a<level.materials.size(); a++)
|
||||
{
|
||||
Material mat = (Material) level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires)
|
||||
{
|
||||
HotWires hw = (HotWires) mat;
|
||||
if (hw.wall==0)
|
||||
hw.value=true;
|
||||
}
|
||||
}
|
||||
for (int a=0; a<5; a++)
|
||||
{
|
||||
Graphix gr = (Graphix) room.graphix.elementAt(a);
|
||||
String[] filelist = {"blueHorizontal.gif"};
|
||||
gr.filenames = filelist;
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
for (int a=0; a<5; a++)
|
||||
{
|
||||
Graphix gr = (Graphix) room.graphix.elementAt(a+5);
|
||||
String[] filelist = {"blueVertical.gif"};
|
||||
gr.filenames = filelist;
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
animationState++;
|
||||
break;
|
||||
case 7:
|
||||
room.SetMaterial(4,0,9);
|
||||
room.upRoom.SetMaterial(4,11,9);
|
||||
animationState++;
|
||||
break;
|
||||
case 8:
|
||||
room.SetMaterial(3,0,9);
|
||||
room.upRoom.SetMaterial(3,11,9);
|
||||
animationState++;
|
||||
break;
|
||||
case 9:
|
||||
room.SetMaterial(2,0,9);
|
||||
room.upRoom.SetMaterial(2,11,9);
|
||||
animationState = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
icon = images[0];
|
||||
if (value) {
|
||||
icon = images[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (animationState == 0) {
|
||||
animationState = 1;
|
||||
room = item.room;
|
||||
timeout = new Date(new Date().getTime() + 20000);
|
||||
textbox = item.room.textBoxes.elementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
icon = images[0];
|
||||
if (value) {
|
||||
icon = images[1];
|
||||
Date now = new Date();
|
||||
long timer = timeout.getTime() - now.getTime();
|
||||
if (timer > 0) {
|
||||
long seconds = Math.abs(timer / 1000) + 1;
|
||||
if (seconds < 10) {
|
||||
textbox.textString = "0" + seconds;
|
||||
}
|
||||
else {
|
||||
textbox.textString = "" + seconds;
|
||||
}
|
||||
}
|
||||
else {
|
||||
textbox.textString = "00";
|
||||
animationState++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch (animationState) {
|
||||
case 1:
|
||||
value = true;
|
||||
room.SetMaterial(2, 0, 0);
|
||||
room.upRoom.SetMaterial(2, 11, 0);
|
||||
for (int a = 0; a < level.materials.size(); a++) {
|
||||
Material mat = level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires) {
|
||||
HotWires hw = (HotWires) mat;
|
||||
if (hw.wall == 0) {
|
||||
hw.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int a = 0; a < 5; a++) {
|
||||
Graphix gr = room.graphix.elementAt(a);
|
||||
gr.filenames = new String[]{"whiteHorizontal.gif"};
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
for (int a = 0; a < 5; a++) {
|
||||
Graphix gr = room.graphix.elementAt(a + 5);
|
||||
gr.filenames = new String[]{"whiteVertical.gif"};
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
animationState++;
|
||||
break;
|
||||
case 2:
|
||||
room.SetMaterial(3, 0, 0);
|
||||
room.upRoom.SetMaterial(3, 11, 0);
|
||||
animationState++;
|
||||
break;
|
||||
case 3:
|
||||
room.SetMaterial(4, 0, 0);
|
||||
room.upRoom.SetMaterial(4, 11, 0);
|
||||
animationState++;
|
||||
break;
|
||||
case 4:
|
||||
room.SetMaterial(5, 0, 0);
|
||||
room.upRoom.SetMaterial(5, 11, 0);
|
||||
animationState++;
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
room.SetMaterial(5, 0, 9);
|
||||
room.upRoom.SetMaterial(5, 11, 9);
|
||||
value = false;
|
||||
for (int a = 0; a < level.materials.size(); a++) {
|
||||
Material mat = level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires) {
|
||||
HotWires hw = (HotWires) mat;
|
||||
if (hw.wall == 0) {
|
||||
hw.value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int a = 0; a < 5; a++) {
|
||||
Graphix gr = room.graphix.elementAt(a);
|
||||
gr.filenames = new String[]{"blueHorizontal.gif"};
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
for (int a = 0; a < 5; a++) {
|
||||
Graphix gr = room.graphix.elementAt(a + 5);
|
||||
gr.filenames = new String[]{"blueVertical.gif"};
|
||||
gr.GenerateIcons();
|
||||
}
|
||||
animationState++;
|
||||
break;
|
||||
case 7:
|
||||
room.SetMaterial(4, 0, 9);
|
||||
room.upRoom.SetMaterial(4, 11, 9);
|
||||
animationState++;
|
||||
break;
|
||||
case 8:
|
||||
room.SetMaterial(3, 0, 9);
|
||||
room.upRoom.SetMaterial(3, 11, 9);
|
||||
animationState++;
|
||||
break;
|
||||
case 9:
|
||||
room.SetMaterial(2, 0, 9);
|
||||
room.upRoom.SetMaterial(2, 11, 9);
|
||||
animationState = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,18 +4,12 @@ import java.awt.Color;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class BlueWall extends Material
|
||||
{
|
||||
public BlueWall()
|
||||
{
|
||||
super(new Color(0,0,255), false, true);
|
||||
}
|
||||
public class BlueWall extends Material {
|
||||
public BlueWall() {
|
||||
super(new Color(0, 0, 255), false, true);
|
||||
}
|
||||
|
||||
public boolean Passable(Item item)
|
||||
{
|
||||
if (item.getClass().toString().endsWith("Sentry3"))
|
||||
return true;
|
||||
else
|
||||
return passable;
|
||||
}
|
||||
public boolean Passable(Item item) {
|
||||
return item.getClass().toString().endsWith("Sentry3") || passable;
|
||||
}
|
||||
}
|
||||
|
@@ -8,33 +8,30 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class CameraDisable extends Material
|
||||
{
|
||||
public CameraDisable()
|
||||
{
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public class CameraDisable extends Material {
|
||||
public CameraDisable() {
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item == level.player)
|
||||
if (level.currentViewer != level.player)
|
||||
level.currentViewer = level.player;
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
if (level.currentViewer != level.player) {
|
||||
level.currentViewer = level.player;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,56 +8,52 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class CameraEnable extends Material
|
||||
{
|
||||
transient Item hiddenCamera=null;
|
||||
public class CameraEnable extends Material {
|
||||
private transient Item hiddenCamera = null;
|
||||
|
||||
public CameraEnable()
|
||||
{
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
public CameraEnable() {
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(8,9,12,2);
|
||||
g.fillRect(8,21,12,2);
|
||||
g.fillRect(4,11,4,2);
|
||||
g.fillRect(4,19,4,2);
|
||||
g.fillRect(20,11,4,2);
|
||||
g.fillRect(20,19,4,2);
|
||||
g.fillRect(0,13,4,6);
|
||||
g.fillRect(24,13,4,6);
|
||||
g.fillRect(8,13,12,6);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (hiddenCamera==null)
|
||||
for (int a=0; a<level.items.size(); a++)
|
||||
{
|
||||
Item i = (Item) level.items.elementAt(a);
|
||||
if (i.getClass().toString().endsWith("HiddenCamera"))
|
||||
hiddenCamera = i;
|
||||
}
|
||||
if (item == level.player)
|
||||
level.currentViewer = hiddenCamera;
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(8, 9, 12, 2);
|
||||
g.fillRect(8, 21, 12, 2);
|
||||
g.fillRect(4, 11, 4, 2);
|
||||
g.fillRect(4, 19, 4, 2);
|
||||
g.fillRect(20, 11, 4, 2);
|
||||
g.fillRect(20, 19, 4, 2);
|
||||
g.fillRect(0, 13, 4, 6);
|
||||
g.fillRect(24, 13, 4, 6);
|
||||
g.fillRect(8, 13, 12, 6);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (hiddenCamera == null) {
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
Item i = level.items.elementAt(a);
|
||||
if (i.getClass().toString().endsWith("HiddenCamera")) {
|
||||
hiddenCamera = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item == level.player) {
|
||||
level.currentViewer = hiddenCamera;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,11 +2,9 @@ package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ChipTester extends Material
|
||||
{
|
||||
public ChipTester()
|
||||
{
|
||||
color = Color.black;
|
||||
passable = true;
|
||||
}
|
||||
public class ChipTester extends Material {
|
||||
public ChipTester() {
|
||||
color = Color.black;
|
||||
passable = true;
|
||||
}
|
||||
}
|
@@ -2,12 +2,10 @@ package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class ChipTrash extends Material
|
||||
{
|
||||
public ChipTrash()
|
||||
{
|
||||
color = new Color(0,128,0);
|
||||
passable = true;
|
||||
}
|
||||
public class ChipTrash extends Material {
|
||||
public ChipTrash() {
|
||||
color = new Color(0, 128, 0);
|
||||
passable = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -6,34 +6,29 @@ import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class CoinSlot extends Material
|
||||
{
|
||||
public CoinSlot()
|
||||
{
|
||||
super(true,false);
|
||||
GenerateIcons();
|
||||
}
|
||||
public class CoinSlot extends Material {
|
||||
public CoinSlot() {
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12,4,4,24);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12, 4, 4, 24);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -9,50 +9,43 @@ import javax.swing.ImageIcon;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.levels.Level;
|
||||
|
||||
public class CrystalRecharger extends Material
|
||||
{
|
||||
// Charges a Crystal when one is passed over it.
|
||||
public CrystalRecharger()
|
||||
{
|
||||
super(true, false);
|
||||
}
|
||||
public class CrystalRecharger extends Material {
|
||||
// Charges a Crystal when one is passed over it.
|
||||
public CrystalRecharger() {
|
||||
super(true, false);
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
icon = new ImageIcon(bi);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(new Color(255,128,0));
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12,4,4,24);
|
||||
g.fillRect(8,8,12,16);
|
||||
g.fillRect(4,10,20,12);
|
||||
g.fillRect(0,14,28,4);
|
||||
g.fillRect(0,8,4,2);
|
||||
g.fillRect(0,22,4,2);
|
||||
g.fillRect(24,8,4,2);
|
||||
g.fillRect(24,22,4,2);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
icon = new ImageIcon(bi);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
// Check to see if it's a pure Crystal, not a Black Crystal
|
||||
if (item.getClass().toString().endsWith("Crystal"))
|
||||
{
|
||||
item.charge=100000;
|
||||
level.PlaySound(item.room, Level.CHARGESOUND);
|
||||
}
|
||||
}
|
||||
g.setColor(new Color(255, 128, 0));
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12, 4, 4, 24);
|
||||
g.fillRect(8, 8, 12, 16);
|
||||
g.fillRect(4, 10, 20, 12);
|
||||
g.fillRect(0, 14, 28, 4);
|
||||
g.fillRect(0, 8, 4, 2);
|
||||
g.fillRect(0, 22, 4, 2);
|
||||
g.fillRect(24, 8, 4, 2);
|
||||
g.fillRect(24, 22, 4, 2);
|
||||
}
|
||||
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
// Check to see if it's a pure Crystal, not a Black Crystal
|
||||
if (item.getClass().toString().endsWith("Crystal")) {
|
||||
item.charge = 100000;
|
||||
level.PlaySound(item.room, Level.CHARGESOUND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,143 +1,130 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.decorations.TextBox;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Sentry;
|
||||
|
||||
public class DeactivatorSwitch extends Material
|
||||
{
|
||||
// This object deactivates the Sentry in the Hot Wires room. When
|
||||
// activated, it sets the counter at 20 seconds, sets all versions of
|
||||
// the HotWires material to value=false, sets the sentry program so that
|
||||
// it's not sensitive to the area, and updates the timer text display.
|
||||
// When the counter reaches 0, it resets everything back to normal.
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
public boolean value;
|
||||
public Date timeout;
|
||||
public ImageIcon[] images;
|
||||
transient Item sentry = null;
|
||||
transient TextBox textbox = null;
|
||||
public class DeactivatorSwitch extends Material {
|
||||
// This object deactivates the Sentry in the Hot Wires room. When
|
||||
// activated, it sets the counter at 20 seconds, sets all versions of
|
||||
// the HotWires material to value=false, sets the sentry program so that
|
||||
// it's not sensitive to the area, and updates the timer text display.
|
||||
// When the counter reaches 0, it resets everything back to normal.
|
||||
|
||||
public DeactivatorSwitch()
|
||||
{
|
||||
super(true, false);
|
||||
value=false;
|
||||
}
|
||||
private boolean value;
|
||||
private Date timeout;
|
||||
private ImageIcon[] images;
|
||||
private transient Item sentry = null;
|
||||
private transient TextBox textbox = null;
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
images = new ImageIcon[2];
|
||||
for (int a=0; a<2; a++)
|
||||
{
|
||||
images[a] = new ImageIcon(new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
Color c;
|
||||
if (a==0)
|
||||
c = Color.white;
|
||||
else
|
||||
c = new Color(255,128,0);
|
||||
|
||||
g2.setColor(c);
|
||||
g.fillRect(0,0,28,32);
|
||||
g2.setColor(Color.black);
|
||||
g.fillRect(4,14,20,4);
|
||||
g.fillRect(8,12,12,8);
|
||||
g.fillRect(12,8,4,16);
|
||||
g2.setColor(c);
|
||||
g.fillRect(12,14,4,4);
|
||||
}
|
||||
|
||||
icon = images[0];
|
||||
if (value)
|
||||
icon = images[1];
|
||||
}
|
||||
public DeactivatorSwitch() {
|
||||
super(true, false);
|
||||
value = false;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (value==false)
|
||||
{
|
||||
value=true;
|
||||
Date now = new Date();
|
||||
timeout = new Date(now.getTime() + 20000);
|
||||
// Find HotWires and set their value to false;
|
||||
for (int a=0; a<level.materials.size(); a++)
|
||||
{
|
||||
Material mat = (Material) level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires)
|
||||
{
|
||||
HotWires hw = (HotWires) mat;
|
||||
if (hw.wall != 0)
|
||||
hw.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Find Sentry and set it's progam to something else.
|
||||
if (sentry==null)
|
||||
{
|
||||
for(int a=0; a<level.items.size(); a++)
|
||||
{
|
||||
Item i = (Item) level.items.elementAt(a);
|
||||
if (i instanceof Sentry && i.room == item.room.upRoom)
|
||||
sentry = i;
|
||||
}
|
||||
}
|
||||
((Sentry) sentry).protect[3]=0;
|
||||
|
||||
// Find the TextBox
|
||||
if (textbox==null)
|
||||
{
|
||||
textbox = (TextBox) item.room.textBoxes.elementAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
images = new ImageIcon[2];
|
||||
for (int a = 0; a < 2; a++) {
|
||||
images[a] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try {
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
Color c;
|
||||
if (a == 0) {
|
||||
c = Color.white;
|
||||
}
|
||||
else {
|
||||
c = new Color(255, 128, 0);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
icon = images[0];
|
||||
if (value)
|
||||
{
|
||||
icon = images[1];
|
||||
Date now = new Date();
|
||||
long timer = timeout.getTime() - now.getTime();
|
||||
if (timer > 0)
|
||||
{
|
||||
long seconds = Math.abs(timer/1000) + 1;
|
||||
if (seconds<10)
|
||||
textbox.textString = "0" + seconds;
|
||||
else
|
||||
textbox.textString = "" + seconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int a=0; a<level.materials.size(); a++)
|
||||
{
|
||||
Material mat = (Material) level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires)
|
||||
((HotWires)mat).value =true;
|
||||
}
|
||||
((Sentry) sentry).protect[3]=11*32;
|
||||
value=false;
|
||||
textbox.textString = "00";
|
||||
}
|
||||
}
|
||||
}
|
||||
g2.setColor(c);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g2.setColor(Color.black);
|
||||
g.fillRect(4, 14, 20, 4);
|
||||
g.fillRect(8, 12, 12, 8);
|
||||
g.fillRect(12, 8, 4, 16);
|
||||
g2.setColor(c);
|
||||
g.fillRect(12, 14, 4, 4);
|
||||
}
|
||||
|
||||
}
|
||||
icon = images[0];
|
||||
if (value) {
|
||||
icon = images[1];
|
||||
}
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (!value) {
|
||||
value = true;
|
||||
Date now = new Date();
|
||||
timeout = new Date(now.getTime() + 20000);
|
||||
// Find HotWires and set their value to false;
|
||||
for (int a = 0; a < level.materials.size(); a++) {
|
||||
Material mat = level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires) {
|
||||
HotWires hw = (HotWires) mat;
|
||||
if (hw.wall != 0) {
|
||||
hw.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find Sentry and set it's progam to something else.
|
||||
if (sentry == null) {
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
Item i = level.items.elementAt(a);
|
||||
if (i instanceof Sentry && i.room == item.room.upRoom) {
|
||||
sentry = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
((Sentry) sentry).protect[3] = 0;
|
||||
|
||||
// Find the TextBox
|
||||
if (textbox == null) {
|
||||
textbox = item.room.textBoxes.elementAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
icon = images[0];
|
||||
if (value) {
|
||||
icon = images[1];
|
||||
Date now = new Date();
|
||||
long timer = timeout.getTime() - now.getTime();
|
||||
if (timer > 0) {
|
||||
long seconds = Math.abs(timer / 1000) + 1;
|
||||
if (seconds < 10) {
|
||||
textbox.textString = "0" + seconds;
|
||||
}
|
||||
else {
|
||||
textbox.textString = "" + seconds;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int a = 0; a < level.materials.size(); a++) {
|
||||
Material mat = level.materials.elementAt(a);
|
||||
if (mat instanceof HotWires) {
|
||||
((HotWires) mat).value = true;
|
||||
}
|
||||
}
|
||||
((Sentry) sentry).protect[3] = 11 * 32;
|
||||
value = false;
|
||||
textbox.textString = "00";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.droidquest.avatars.GameCursor;
|
||||
import com.droidquest.decorations.Graphix;
|
||||
import com.droidquest.decorations.TextBox;
|
||||
@@ -9,137 +7,134 @@ import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Magnet;
|
||||
|
||||
public class ElevatorDoor extends Material
|
||||
{
|
||||
// This material will open or close the elevator doors based on where
|
||||
// the player is. It is sensitive to the player being inside a robot.
|
||||
transient boolean checkedForMagnet = false;
|
||||
transient Item magnet = null;
|
||||
import java.awt.*;
|
||||
|
||||
public ElevatorDoor()
|
||||
{
|
||||
super(Color.black, true, false);
|
||||
}
|
||||
public class ElevatorDoor extends Material {
|
||||
// This material will open or close the elevator doors based on where
|
||||
// the player is. It is sensitive to the player being inside a robot.
|
||||
private transient boolean checkedForMagnet = false;
|
||||
private transient Item magnet = null;
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item.carriedBy!=null) return;
|
||||
|
||||
if (!checkedForMagnet)
|
||||
{
|
||||
for (int a=0; a<level.items.size(); a++)
|
||||
{
|
||||
Item i = (Item) level.items.elementAt(a);
|
||||
if (i instanceof Magnet)
|
||||
{
|
||||
magnet = i;
|
||||
checkedForMagnet=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean test = false;
|
||||
|
||||
if (item == level.player)
|
||||
test = true;
|
||||
else if (item instanceof GenericRobot)
|
||||
{
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item)
|
||||
test=true;;
|
||||
}
|
||||
|
||||
Graphix gr = (Graphix) item.room.graphix.elementAt(1);
|
||||
gr.x = 18*28;
|
||||
|
||||
if (magnet!=null)
|
||||
if (magnet.room == item.room)
|
||||
{
|
||||
test=false;
|
||||
gr.x = 18*28-10;
|
||||
}
|
||||
|
||||
if (test)
|
||||
{
|
||||
int X = item.x/28;
|
||||
switch(X)
|
||||
{
|
||||
case 3:
|
||||
item.room.SetMaterial(11,1,0);
|
||||
item.room.SetMaterial(11,2,0);
|
||||
item.room.SetMaterial(11,3,0);
|
||||
item.room.SetMaterial(11,4,0);
|
||||
item.room.SetMaterial(11,5,0);
|
||||
item.room.SetMaterial(11,6,0);
|
||||
item.room.SetMaterial(11,7,0);
|
||||
item.room.SetMaterial(11,8,0);
|
||||
item.room.SetMaterial(11,9,0);
|
||||
item.room.SetMaterial(11,10,0);
|
||||
break;
|
||||
case 4:
|
||||
item.room.SetMaterial(11,1,2);
|
||||
item.room.SetMaterial(11,2,0);
|
||||
item.room.SetMaterial(11,3,0);
|
||||
item.room.SetMaterial(11,4,0);
|
||||
item.room.SetMaterial(11,5,0);
|
||||
item.room.SetMaterial(11,6,0);
|
||||
item.room.SetMaterial(11,7,0);
|
||||
item.room.SetMaterial(11,8,0);
|
||||
item.room.SetMaterial(11,9,0);
|
||||
item.room.SetMaterial(11,10,2);
|
||||
break;
|
||||
case 5:
|
||||
item.room.SetMaterial(11,1,2);
|
||||
item.room.SetMaterial(11,2,2);
|
||||
item.room.SetMaterial(11,3,0);
|
||||
item.room.SetMaterial(11,4,0);
|
||||
item.room.SetMaterial(11,5,0);
|
||||
item.room.SetMaterial(11,6,0);
|
||||
item.room.SetMaterial(11,7,0);
|
||||
item.room.SetMaterial(11,8,0);
|
||||
item.room.SetMaterial(11,9,2);
|
||||
item.room.SetMaterial(11,10,2);
|
||||
break;
|
||||
case 6:
|
||||
item.room.SetMaterial(11,1,2);
|
||||
item.room.SetMaterial(11,2,2);
|
||||
item.room.SetMaterial(11,3,2);
|
||||
item.room.SetMaterial(11,4,0);
|
||||
item.room.SetMaterial(11,5,0);
|
||||
item.room.SetMaterial(11,6,0);
|
||||
item.room.SetMaterial(11,7,0);
|
||||
item.room.SetMaterial(11,8,2);
|
||||
item.room.SetMaterial(11,9,2);
|
||||
item.room.SetMaterial(11,10,2);
|
||||
break;
|
||||
case 7:
|
||||
item.room.SetMaterial(11,1,2);
|
||||
item.room.SetMaterial(11,2,2);
|
||||
item.room.SetMaterial(11,3,2);
|
||||
item.room.SetMaterial(11,4,2);
|
||||
item.room.SetMaterial(11,5,0);
|
||||
item.room.SetMaterial(11,6,0);
|
||||
item.room.SetMaterial(11,7,2);
|
||||
item.room.SetMaterial(11,8,2);
|
||||
item.room.SetMaterial(11,9,2);
|
||||
item.room.SetMaterial(11,10,2);
|
||||
((TextBox) item.room.textBoxes.elementAt(1)).textString = "\"Hold please!\"";
|
||||
break;
|
||||
case 8:
|
||||
item.room.SetMaterial(11,1,2);
|
||||
item.room.SetMaterial(11,2,2);
|
||||
item.room.SetMaterial(11,3,2);
|
||||
item.room.SetMaterial(11,4,2);
|
||||
item.room.SetMaterial(11,5,2);
|
||||
item.room.SetMaterial(11,6,2);
|
||||
item.room.SetMaterial(11,7,2);
|
||||
item.room.SetMaterial(11,8,2);
|
||||
item.room.SetMaterial(11,9,2);
|
||||
item.room.SetMaterial(11,10,2);
|
||||
((TextBox) item.room.textBoxes.elementAt(1)).textString = "\"Going up!\"";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public ElevatorDoor() {
|
||||
super(Color.black, true, false);
|
||||
}
|
||||
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item.carriedBy != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkedForMagnet) {
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
Item i = level.items.elementAt(a);
|
||||
if (i instanceof Magnet) {
|
||||
magnet = i;
|
||||
checkedForMagnet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean test = false;
|
||||
|
||||
if (item == level.player) {
|
||||
test = true;
|
||||
}
|
||||
else if (item instanceof GenericRobot) {
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item) {
|
||||
test = true;
|
||||
}
|
||||
}
|
||||
|
||||
Graphix gr = item.room.graphix.elementAt(1);
|
||||
gr.x = 18 * 28;
|
||||
|
||||
if (magnet != null) {
|
||||
if (magnet.room == item.room) {
|
||||
test = false;
|
||||
gr.x = 18 * 28 - 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (test) {
|
||||
int X = item.x / 28;
|
||||
switch (X) {
|
||||
case 3:
|
||||
item.room.SetMaterial(11, 1, 0);
|
||||
item.room.SetMaterial(11, 2, 0);
|
||||
item.room.SetMaterial(11, 3, 0);
|
||||
item.room.SetMaterial(11, 4, 0);
|
||||
item.room.SetMaterial(11, 5, 0);
|
||||
item.room.SetMaterial(11, 6, 0);
|
||||
item.room.SetMaterial(11, 7, 0);
|
||||
item.room.SetMaterial(11, 8, 0);
|
||||
item.room.SetMaterial(11, 9, 0);
|
||||
item.room.SetMaterial(11, 10, 0);
|
||||
break;
|
||||
case 4:
|
||||
item.room.SetMaterial(11, 1, 2);
|
||||
item.room.SetMaterial(11, 2, 0);
|
||||
item.room.SetMaterial(11, 3, 0);
|
||||
item.room.SetMaterial(11, 4, 0);
|
||||
item.room.SetMaterial(11, 5, 0);
|
||||
item.room.SetMaterial(11, 6, 0);
|
||||
item.room.SetMaterial(11, 7, 0);
|
||||
item.room.SetMaterial(11, 8, 0);
|
||||
item.room.SetMaterial(11, 9, 0);
|
||||
item.room.SetMaterial(11, 10, 2);
|
||||
break;
|
||||
case 5:
|
||||
item.room.SetMaterial(11, 1, 2);
|
||||
item.room.SetMaterial(11, 2, 2);
|
||||
item.room.SetMaterial(11, 3, 0);
|
||||
item.room.SetMaterial(11, 4, 0);
|
||||
item.room.SetMaterial(11, 5, 0);
|
||||
item.room.SetMaterial(11, 6, 0);
|
||||
item.room.SetMaterial(11, 7, 0);
|
||||
item.room.SetMaterial(11, 8, 0);
|
||||
item.room.SetMaterial(11, 9, 2);
|
||||
item.room.SetMaterial(11, 10, 2);
|
||||
break;
|
||||
case 6:
|
||||
item.room.SetMaterial(11, 1, 2);
|
||||
item.room.SetMaterial(11, 2, 2);
|
||||
item.room.SetMaterial(11, 3, 2);
|
||||
item.room.SetMaterial(11, 4, 0);
|
||||
item.room.SetMaterial(11, 5, 0);
|
||||
item.room.SetMaterial(11, 6, 0);
|
||||
item.room.SetMaterial(11, 7, 0);
|
||||
item.room.SetMaterial(11, 8, 2);
|
||||
item.room.SetMaterial(11, 9, 2);
|
||||
item.room.SetMaterial(11, 10, 2);
|
||||
break;
|
||||
case 7:
|
||||
item.room.SetMaterial(11, 1, 2);
|
||||
item.room.SetMaterial(11, 2, 2);
|
||||
item.room.SetMaterial(11, 3, 2);
|
||||
item.room.SetMaterial(11, 4, 2);
|
||||
item.room.SetMaterial(11, 5, 0);
|
||||
item.room.SetMaterial(11, 6, 0);
|
||||
item.room.SetMaterial(11, 7, 2);
|
||||
item.room.SetMaterial(11, 8, 2);
|
||||
item.room.SetMaterial(11, 9, 2);
|
||||
item.room.SetMaterial(11, 10, 2);
|
||||
item.room.textBoxes.elementAt(1).textString = "\"Hold please!\"";
|
||||
break;
|
||||
case 8:
|
||||
item.room.SetMaterial(11, 1, 2);
|
||||
item.room.SetMaterial(11, 2, 2);
|
||||
item.room.SetMaterial(11, 3, 2);
|
||||
item.room.SetMaterial(11, 4, 2);
|
||||
item.room.SetMaterial(11, 5, 2);
|
||||
item.room.SetMaterial(11, 6, 2);
|
||||
item.room.SetMaterial(11, 7, 2);
|
||||
item.room.SetMaterial(11, 8, 2);
|
||||
item.room.SetMaterial(11, 9, 2);
|
||||
item.room.SetMaterial(11, 10, 2);
|
||||
item.room.textBoxes.elementAt(1).textString = "\"Going up!\"";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,50 +9,43 @@ import javax.swing.ImageIcon;
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class ElevatorInPortal extends Material
|
||||
{
|
||||
public ElevatorInPortal()
|
||||
{
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
public class ElevatorInPortal extends Material {
|
||||
public ElevatorInPortal() {
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(10,4,8,2);
|
||||
g.fillRect(10,8,8,2);
|
||||
g.fillRect(10,12,8,2);
|
||||
g.fillRect(10,16,8,2);
|
||||
g.fillRect(10,20,8,2);
|
||||
g.fillRect(10,24,8,2);
|
||||
g.fillRect(10,28,8,2);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item == level.player)
|
||||
{
|
||||
Room elevatorRoom = (Room) level.rooms.elementAt(35);
|
||||
item.x = 28;
|
||||
item.y = 10*32;
|
||||
item.SetRoom(elevatorRoom);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(10, 4, 8, 2);
|
||||
g.fillRect(10, 8, 8, 2);
|
||||
g.fillRect(10, 12, 8, 2);
|
||||
g.fillRect(10, 16, 8, 2);
|
||||
g.fillRect(10, 20, 8, 2);
|
||||
g.fillRect(10, 24, 8, 2);
|
||||
g.fillRect(10, 28, 8, 2);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
Room elevatorRoom = level.rooms.elementAt(35);
|
||||
item.x = 28;
|
||||
item.y = 10 * 32;
|
||||
item.SetRoom(elevatorRoom);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -9,88 +9,81 @@ import javax.swing.ImageIcon;
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class ElevatorLock extends Material
|
||||
{
|
||||
int doorstate = 0;
|
||||
public class ElevatorLock extends Material {
|
||||
private int doorstate = 0;
|
||||
// 0=closed
|
||||
// 1=opening
|
||||
// 2=opening
|
||||
// 3=open
|
||||
// 4=closing
|
||||
// 5=closing
|
||||
Room room;
|
||||
private Room room;
|
||||
|
||||
public ElevatorLock()
|
||||
{
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
public ElevatorLock() {
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(4,4,4,2);
|
||||
g.fillRect(12,4,4,2);
|
||||
g.fillRect(4,8,4,2);
|
||||
g.fillRect(20,8,4,2);
|
||||
g.fillRect(20,26,4,2);
|
||||
g.fillRect(4,14,12,4);
|
||||
g.fillRect(4,22,12,4);
|
||||
g.fillRect(20,12,4,12);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item.getClass().toString().endsWith("ElevatorKey"))
|
||||
{
|
||||
room = item.room;
|
||||
if (doorstate==0)
|
||||
doorstate=1;
|
||||
else if (doorstate==3)
|
||||
doorstate=4;
|
||||
}
|
||||
}
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(4, 4, 4, 2);
|
||||
g.fillRect(12, 4, 4, 2);
|
||||
g.fillRect(4, 8, 4, 2);
|
||||
g.fillRect(20, 8, 4, 2);
|
||||
g.fillRect(20, 26, 4, 2);
|
||||
g.fillRect(4, 14, 12, 4);
|
||||
g.fillRect(4, 22, 12, 4);
|
||||
g.fillRect(20, 12, 4, 12);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
switch(doorstate)
|
||||
{
|
||||
case 0: // Do nothing
|
||||
break;
|
||||
case 1:
|
||||
room.SetMaterial(15,5,0);
|
||||
doorstate++;
|
||||
break;
|
||||
case 2:
|
||||
room.SetMaterial(15,4,0);
|
||||
doorstate++;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
room.SetMaterial(15,4,7);
|
||||
doorstate++;
|
||||
break;
|
||||
case 5:
|
||||
room.SetMaterial(15,5,7);
|
||||
doorstate=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item.getClass().toString().endsWith("ElevatorKey")) {
|
||||
room = item.room;
|
||||
if (doorstate == 0) {
|
||||
doorstate = 1;
|
||||
}
|
||||
else if (doorstate == 3) {
|
||||
doorstate = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
switch (doorstate) {
|
||||
case 0: // Do nothing
|
||||
break;
|
||||
case 1:
|
||||
room.SetMaterial(15, 5, 0);
|
||||
doorstate++;
|
||||
break;
|
||||
case 2:
|
||||
room.SetMaterial(15, 4, 0);
|
||||
doorstate++;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
room.SetMaterial(15, 4, 7);
|
||||
doorstate++;
|
||||
break;
|
||||
case 5:
|
||||
room.SetMaterial(15, 5, 7);
|
||||
doorstate = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -3,40 +3,34 @@ package com.droidquest.materials;
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class ElevatorOutPortal extends Material
|
||||
{
|
||||
transient static public Room outRoom;
|
||||
public class ElevatorOutPortal extends Material {
|
||||
transient static public Room outRoom;
|
||||
|
||||
public ElevatorOutPortal()
|
||||
{
|
||||
super(true, false);
|
||||
}
|
||||
public ElevatorOutPortal() {
|
||||
super(true, false);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item == level.player)
|
||||
{
|
||||
if (outRoom == null)
|
||||
outRoom = (Room) level.rooms.elementAt(9);
|
||||
if (outRoom == (Room) level.rooms.elementAt(9))
|
||||
{
|
||||
item.x = 15*28;
|
||||
item.y = 5*32;
|
||||
item.SetRoom(outRoom);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.x = 13*28;
|
||||
item.y = 5*32;
|
||||
item.SetRoom(outRoom);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
if (outRoom == null) {
|
||||
outRoom = level.rooms.elementAt(9);
|
||||
}
|
||||
if (outRoom == level.rooms.elementAt(9)) {
|
||||
item.x = 15 * 28;
|
||||
item.y = 5 * 32;
|
||||
item.SetRoom(outRoom);
|
||||
}
|
||||
else {
|
||||
item.x = 13 * 28;
|
||||
item.y = 5 * 32;
|
||||
item.SetRoom(outRoom);
|
||||
}
|
||||
|
||||
static public void SetOutRoom(int roomNum)
|
||||
{
|
||||
outRoom = (Room) level.rooms.elementAt(roomNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public void SetOutRoom(int roomNum) {
|
||||
outRoom = level.rooms.elementAt(roomNum);
|
||||
}
|
||||
|
||||
}
|
@@ -10,62 +10,56 @@ import com.droidquest.avatars.GameCursor;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class ForceField extends Material
|
||||
{
|
||||
String robotClassName=null;
|
||||
public class ForceField extends Material {
|
||||
private String robotClassName = null;
|
||||
|
||||
public ForceField(String rc, Color c)
|
||||
{
|
||||
super(true,false);
|
||||
robotClassName = rc;
|
||||
color = c;
|
||||
GenerateIcons();
|
||||
}
|
||||
public ForceField(String rc, Color c) {
|
||||
super(true, false);
|
||||
robotClassName = rc;
|
||||
color = c;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(color);
|
||||
g.fillRect(12,0,4,32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean Passable(Item item)
|
||||
{
|
||||
if (item == level.player)
|
||||
return false;
|
||||
else if (item instanceof GenericRobot)
|
||||
{
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.getClass().toString().endsWith(robotClassName))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(color);
|
||||
g.fillRect(12, 0, 4, 32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (robotClassName == ((ForceField)mat).robotClassName)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public boolean Passable(Item item) {
|
||||
if (item == level.player) {
|
||||
return false;
|
||||
}
|
||||
else if (item instanceof GenericRobot) {
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !item.getClass().toString().endsWith(robotClassName);
|
||||
|
||||
}
|
||||
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (robotClassName.equals(((ForceField) mat).robotClassName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,90 +10,91 @@ import javax.swing.ImageIcon;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.levels.Level;
|
||||
|
||||
public class HotWires extends Material
|
||||
{
|
||||
// Hot orange wires that burn charge of any object that passes over it.
|
||||
// Cold = white.
|
||||
// Create shape by adding the direction values. UP+DOWN, LEFT+RIGHT, UP+LEFT, etc...
|
||||
public class HotWires extends Material {
|
||||
// Hot orange wires that burn charge of any object that passes over it.
|
||||
// Cold = white.
|
||||
// Create shape by adding the direction values. UP+DOWN, LEFT+RIGHT, UP+LEFT, etc...
|
||||
|
||||
transient ImageIcon images[];
|
||||
public static final int UP=1;
|
||||
public static final int DOWN=2;
|
||||
public static final int LEFT=4;
|
||||
public static final int RIGHT=8;
|
||||
public boolean value;
|
||||
int wall;
|
||||
private transient ImageIcon[] images;
|
||||
public static final int UP = 1;
|
||||
public static final int DOWN = 2;
|
||||
public static final int LEFT = 4;
|
||||
public static final int RIGHT = 8;
|
||||
public boolean value;
|
||||
int wall;
|
||||
|
||||
public HotWires(int w, boolean v)
|
||||
{
|
||||
passable = true;
|
||||
detectable = false;
|
||||
wall = w;
|
||||
value = v;
|
||||
}
|
||||
public HotWires(int w, boolean v) {
|
||||
passable = true;
|
||||
detectable = false;
|
||||
wall = w;
|
||||
value = v;
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
images = new ImageIcon[2];
|
||||
for (int a=0; a<2; a++)
|
||||
{
|
||||
images[a] = new ImageIcon(new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0,0,28,32);
|
||||
if (a==0)
|
||||
g2.setColor(Color.white);
|
||||
else
|
||||
g2.setColor(new Color(255,128,0));
|
||||
if ((wall & UP)==UP)
|
||||
g.fillRect(13,0,2,16);
|
||||
if ((wall & DOWN)==DOWN)
|
||||
g.fillRect(13,16,2,16);
|
||||
if ((wall & LEFT)==LEFT)
|
||||
g.fillRect(0,15,14,2);
|
||||
if ((wall & RIGHT)==RIGHT)
|
||||
g.fillRect(14,15,14,2);
|
||||
}
|
||||
|
||||
icon = images[0];
|
||||
if (value)
|
||||
icon = images[1];
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
images = new ImageIcon[2];
|
||||
for (int a = 0; a < 2; a++) {
|
||||
images[a] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try {
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0, 0, 28, 32);
|
||||
if (a == 0) {
|
||||
g2.setColor(Color.white);
|
||||
}
|
||||
else {
|
||||
g2.setColor(new Color(255, 128, 0));
|
||||
}
|
||||
if ((wall & UP) == UP) {
|
||||
g.fillRect(13, 0, 2, 16);
|
||||
}
|
||||
if ((wall & DOWN) == DOWN) {
|
||||
g.fillRect(13, 16, 2, 16);
|
||||
}
|
||||
if ((wall & LEFT) == LEFT) {
|
||||
g.fillRect(0, 15, 14, 2);
|
||||
}
|
||||
if ((wall & RIGHT) == RIGHT) {
|
||||
g.fillRect(14, 15, 14, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (value)
|
||||
if (item.charge>0)
|
||||
{
|
||||
item.charge=0;
|
||||
level.PlaySound(item.room, Level.DISCHARGESOUND);
|
||||
}
|
||||
}
|
||||
icon = images[0];
|
||||
if (value) {
|
||||
icon = images[1];
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
icon = images[0];
|
||||
if (value)
|
||||
icon = images[1];
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (value) {
|
||||
if (item.charge > 0) {
|
||||
item.charge = 0;
|
||||
level.PlaySound(item.room, Level.DISCHARGESOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (value == ((HotWires)mat).value
|
||||
&& wall == ((HotWires)mat).wall)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void Animate() {
|
||||
icon = images[0];
|
||||
if (value) {
|
||||
icon = images[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (value == ((HotWires) mat).value
|
||||
&& wall == ((HotWires) mat).wall) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,235 +11,236 @@ import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Key;
|
||||
|
||||
public class Lock extends Material
|
||||
{
|
||||
// Generic Lock; Used to redefine materials in the local room.
|
||||
public class Lock extends Material {
|
||||
// Generic Lock; Used to redefine materials in the local room.
|
||||
|
||||
int doorState=0;
|
||||
Color keyColor;
|
||||
transient Key latchKey = null;
|
||||
transient Room room;
|
||||
transient Room currentRoom;
|
||||
static public int NARROW = -1;
|
||||
static public int WIDE = -2;
|
||||
static public int REMOVE = -3;
|
||||
static public int RESET = -4;
|
||||
static public int LEFT = -5;
|
||||
static public int RIGHT = -6;
|
||||
static public int UP = -7;
|
||||
static public int DOWN = -8;
|
||||
int[][] program;
|
||||
private int doorState = 0;
|
||||
private Color keyColor;
|
||||
private transient Key latchKey = null;
|
||||
private transient Room room;
|
||||
private transient Room currentRoom;
|
||||
static public int NARROW = -1;
|
||||
static public int WIDE = -2;
|
||||
static public int REMOVE = -3;
|
||||
private static int RESET = -4;
|
||||
static public int LEFT = -5;
|
||||
static public int RIGHT = -6;
|
||||
static public int UP = -7;
|
||||
static public int DOWN = -8;
|
||||
private int[][] program;
|
||||
|
||||
// program[][] is an array of arrays. Each array holds the behavior of a
|
||||
// single value of doorState.
|
||||
//
|
||||
// A single array can hold one of the following:
|
||||
// program[][] is an array of arrays. Each array holds the behavior of a
|
||||
// single value of doorState.
|
||||
//
|
||||
// A single array can hold one of the following:
|
||||
// A single value of Lock.NARROW, Lock.WIDE, or Lock.REMOVE to define a pause
|
||||
// A single value of RESET, LEFT, RIGHT, UP, or DOWN to change rooms
|
||||
// A series of triplets (X,Y,M) with the XY position and the Materials
|
||||
// Index.
|
||||
//
|
||||
// Pause value can be one of the following:
|
||||
// Lock.NARROW = Pause until the key is placed once more precisely into the lock.
|
||||
// Lock.WIDE = Pause until the key is placed ANYWHERE into the lock
|
||||
// Lock.REMOVE = Pause until the key is removed.
|
||||
//
|
||||
// Pause values automatically reset the current Room to the original value.
|
||||
//
|
||||
// Lock.RESET = Set current room to the original room value
|
||||
// Lock.LEFT = Change the current room to the room's left room
|
||||
// Lock.RIGHT = Same, but right
|
||||
// Lock.UP = Same, but up
|
||||
// Lock.DOWN = Same, but down
|
||||
//
|
||||
// The room is normally the key's rom when the key touches the lock, and
|
||||
// the triplets change the materials within the current room. With these
|
||||
// commands the current room can be changed so other rooms can be
|
||||
// manipulated.
|
||||
//
|
||||
// Here's a sample program[][]
|
||||
//
|
||||
// int[][] = {
|
||||
//
|
||||
// Pause value can be one of the following:
|
||||
// Lock.NARROW = Pause until the key is placed once more precisely into the lock.
|
||||
// Lock.WIDE = Pause until the key is placed ANYWHERE into the lock
|
||||
// Lock.REMOVE = Pause until the key is removed.
|
||||
//
|
||||
// Pause values automatically reset the current Room to the original value.
|
||||
//
|
||||
// Lock.RESET = Set current room to the original room value
|
||||
// Lock.LEFT = Change the current room to the room's left room
|
||||
// Lock.RIGHT = Same, but right
|
||||
// Lock.UP = Same, but up
|
||||
// Lock.DOWN = Same, but down
|
||||
//
|
||||
// The room is normally the key's rom when the key touches the lock, and
|
||||
// the triplets change the materials within the current room. With these
|
||||
// commands the current room can be changed so other rooms can be
|
||||
// manipulated.
|
||||
//
|
||||
// Here's a sample program[][]
|
||||
//
|
||||
// int[][] = {
|
||||
// {Lock.NARROW}, // Wait for precise placement
|
||||
// {10,5,0, 11,5,0}, // Converts two spots to holes
|
||||
// {10,6,0, 11,6,0}, // Same, but lower
|
||||
// {Lock.NARROW}, // Wait again
|
||||
// {10,6,1, 11,6,1}, // Converts two spots to wall
|
||||
// {10,5,1, 11,5,1} // same, in reverse, go to pause.
|
||||
// };
|
||||
//
|
||||
// };
|
||||
//
|
||||
|
||||
public Lock(Color lc, Color kc, int[][] prg)
|
||||
{
|
||||
super(true, false);
|
||||
color = lc;
|
||||
keyColor = kc;
|
||||
program = prg;
|
||||
GenerateIcons();
|
||||
}
|
||||
public Lock(Color lc, Color kc, int[][] prg) {
|
||||
super(true, false);
|
||||
color = lc;
|
||||
keyColor = kc;
|
||||
program = prg;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(color);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,14,16,2);
|
||||
g.fillRect(0,16,12,2);
|
||||
g.fillRect(2,18,6,2);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (keyColor == ((Lock)mat).keyColor
|
||||
&& program == ((Lock)mat).program)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
g.setColor(color);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 14, 16, 2);
|
||||
g.fillRect(0, 16, 12, 2);
|
||||
g.fillRect(2, 18, 6, 2);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
if (doorState == program.length)
|
||||
doorState = 0;
|
||||
|
||||
if (latchKey==null)
|
||||
{
|
||||
if (program[doorState][0]==Lock.REMOVE)
|
||||
{
|
||||
for (int a=0; a<level.items.size(); a++)
|
||||
{
|
||||
Item item = (Item) level.items.elementAt(a);
|
||||
if (item instanceof Key)
|
||||
{
|
||||
Key testKey = (Key) item;
|
||||
if (testKey.color.equals(keyColor))
|
||||
{
|
||||
latchKey=testKey;
|
||||
room = latchKey.room;
|
||||
currentRoom = room;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (latchKey==null)
|
||||
return;
|
||||
|
||||
|
||||
if (program[doorState].length > 1)
|
||||
{
|
||||
for (int a=0; a<program[doorState].length/3; a++)
|
||||
currentRoom.SetMaterial(program[doorState][a*3],
|
||||
program[doorState][a*3+1],
|
||||
program[doorState][a*3+2]);
|
||||
doorState++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (program[doorState][0]==REMOVE)
|
||||
{
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int bigXL = d.width/28;
|
||||
int bigXR = (d.width + latchKey.getWidth()) / 28;
|
||||
int bigYT = d.height/32;
|
||||
int bigYB = (d.height + latchKey.getHeight()) / 32;
|
||||
boolean flag = false;
|
||||
if (room.MaterialArray[bigYT][bigXL] == this) flag=true;
|
||||
if (room.MaterialArray[bigYT][bigXR] == this) flag=true;
|
||||
if (room.MaterialArray[bigYB][bigXL] == this) flag=true;
|
||||
if (room.MaterialArray[bigYB][bigXR] == this) flag=true;
|
||||
if (!flag)
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==RESET)
|
||||
{
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==LEFT)
|
||||
{
|
||||
currentRoom = currentRoom.leftRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==RIGHT)
|
||||
{
|
||||
currentRoom = currentRoom.rightRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==UP)
|
||||
{
|
||||
currentRoom = currentRoom.upRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==DOWN)
|
||||
{
|
||||
currentRoom = currentRoom.downRoom;
|
||||
if (currentRoom== null) currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length)
|
||||
doorState = 0;
|
||||
}
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (keyColor == ((Lock) mat).keyColor
|
||||
&& program == ((Lock) mat).program) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item instanceof Key)
|
||||
{
|
||||
if (((Key)item).color.equals(keyColor))
|
||||
{
|
||||
latchKey = (Key) item;
|
||||
room = latchKey.room;
|
||||
}
|
||||
}
|
||||
|
||||
if (latchKey==null)
|
||||
return;
|
||||
|
||||
if (latchKey != item)
|
||||
return;
|
||||
|
||||
if (program[doorState].length==1)
|
||||
{
|
||||
if (program[doorState][0]==NARROW)
|
||||
{
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int X = d.width % 28;
|
||||
int Y = d.height % 32;
|
||||
if (X>=16 && X <=20
|
||||
&& Y>=10 && Y<=14)
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0]==WIDE)
|
||||
{
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length)
|
||||
doorState = 0;
|
||||
|
||||
}
|
||||
public void Animate() {
|
||||
if (doorState == program.length) {
|
||||
doorState = 0;
|
||||
}
|
||||
|
||||
}
|
||||
if (latchKey == null) {
|
||||
if (program[doorState][0] == Lock.REMOVE) {
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
Item item = level.items.elementAt(a);
|
||||
if (item instanceof Key) {
|
||||
Key testKey = (Key) item;
|
||||
if (testKey.color.equals(keyColor)) {
|
||||
latchKey = testKey;
|
||||
room = latchKey.room;
|
||||
currentRoom = room;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (latchKey == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (program[doorState].length > 1) {
|
||||
for (int a = 0; a < program[doorState].length / 3; a++) {
|
||||
currentRoom.SetMaterial(program[doorState][a * 3],
|
||||
program[doorState][a * 3 + 1],
|
||||
program[doorState][a * 3 + 2]);
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else {
|
||||
if (program[doorState][0] == REMOVE) {
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int bigXL = d.width / 28;
|
||||
int bigXR = (d.width + latchKey.getWidth()) / 28;
|
||||
int bigYT = d.height / 32;
|
||||
int bigYB = (d.height + latchKey.getHeight()) / 32;
|
||||
boolean flag = false;
|
||||
if (room.MaterialArray[bigYT][bigXL] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (room.MaterialArray[bigYT][bigXR] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (room.MaterialArray[bigYB][bigXL] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (room.MaterialArray[bigYB][bigXR] == this) {
|
||||
flag = true;
|
||||
}
|
||||
if (!flag) {
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
else if (program[doorState][0] == RESET) {
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == LEFT) {
|
||||
currentRoom = currentRoom.leftRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == RIGHT) {
|
||||
currentRoom = currentRoom.rightRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == UP) {
|
||||
currentRoom = currentRoom.upRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
else if (program[doorState][0] == DOWN) {
|
||||
currentRoom = currentRoom.downRoom;
|
||||
if (currentRoom == null) {
|
||||
currentRoom = room;
|
||||
}
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length) {
|
||||
doorState = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item instanceof Key) {
|
||||
if (((Key) item).color.equals(keyColor)) {
|
||||
latchKey = (Key) item;
|
||||
room = latchKey.room;
|
||||
}
|
||||
}
|
||||
|
||||
if (latchKey == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (latchKey != item) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (program[doorState].length == 1) {
|
||||
if (program[doorState][0] == NARROW) {
|
||||
currentRoom = room;
|
||||
Dimension d = latchKey.GetXY();
|
||||
int X = d.width % 28;
|
||||
int Y = d.height % 32;
|
||||
if (X >= 16 && X <= 20
|
||||
&& Y >= 10 && Y <= 14) {
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
else if (program[doorState][0] == WIDE) {
|
||||
currentRoom = room;
|
||||
doorState++;
|
||||
}
|
||||
}
|
||||
|
||||
if (doorState == program.length) {
|
||||
doorState = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,49 +1,41 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Date;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Magnet;
|
||||
|
||||
public class LockS1 extends Material
|
||||
{
|
||||
Date timeout;
|
||||
transient Item magnet=null;
|
||||
transient Room room = null;
|
||||
import java.awt.*;
|
||||
import java.util.Date;
|
||||
|
||||
public LockS1()
|
||||
{
|
||||
super(new Color(0,0,128),false,true);
|
||||
}
|
||||
public class LockS1 extends Material {
|
||||
private Date timeout;
|
||||
private transient Item magnet = null;
|
||||
private transient Room room = null;
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item instanceof Magnet)
|
||||
{
|
||||
magnet = item;
|
||||
room = item.room;
|
||||
timeout = new Date(new Date().getTime() + 10000);
|
||||
}
|
||||
}
|
||||
public LockS1() {
|
||||
super(new Color(0, 0, 128), false, true);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
if (magnet != null)
|
||||
{
|
||||
Date now = new Date();
|
||||
if (now.getTime() > timeout.getTime())
|
||||
{
|
||||
if (magnet.room == room)
|
||||
{
|
||||
level.LinkRoomsLeftRight(11,30);
|
||||
level.LinkRoomsLeftRight(30,11);
|
||||
room.SetMaterial(10,3,0);
|
||||
room.SetMaterial(11,3,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item instanceof Magnet) {
|
||||
magnet = item;
|
||||
room = item.room;
|
||||
timeout = new Date(new Date().getTime() + 10000);
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
if (magnet != null) {
|
||||
Date now = new Date();
|
||||
if (now.getTime() > timeout.getTime()) {
|
||||
if (magnet.room == room) {
|
||||
level.LinkRoomsLeftRight(11, 30);
|
||||
level.LinkRoomsLeftRight(30, 11);
|
||||
room.SetMaterial(10, 3, 0);
|
||||
room.SetMaterial(11, 3, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,130 +1,101 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.RoomDisplay;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.levels.Level;
|
||||
|
||||
public class Material implements Serializable, Cloneable
|
||||
{
|
||||
public transient static Level level;
|
||||
public transient ImageIcon icon;
|
||||
public String file;
|
||||
public boolean passable;
|
||||
public boolean detectable;
|
||||
public Color color;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
public Material(){}
|
||||
public class Material implements Serializable, Cloneable {
|
||||
public transient static Level level;
|
||||
public transient ImageIcon icon;
|
||||
private String file;
|
||||
public boolean passable;
|
||||
boolean detectable;
|
||||
Color color;
|
||||
|
||||
public Material(String filename, boolean p, boolean d)
|
||||
{
|
||||
// icon=Toolkit.getDefaultToolkit().getImage(filename);
|
||||
icon = new ImageIcon(filename);
|
||||
passable = p;
|
||||
detectable = d;
|
||||
}
|
||||
Material() {
|
||||
}
|
||||
|
||||
public Material(boolean p, boolean d)
|
||||
{
|
||||
passable = p;
|
||||
detectable = d;
|
||||
color = Color.black;
|
||||
}
|
||||
Material(String filename, boolean p, boolean d) {
|
||||
icon = new ImageIcon(filename);
|
||||
passable = p;
|
||||
detectable = d;
|
||||
}
|
||||
|
||||
public Material (Color c, boolean p, boolean d)
|
||||
{
|
||||
passable=p;
|
||||
detectable = d;
|
||||
color=c;
|
||||
}
|
||||
public Material(boolean p, boolean d) {
|
||||
passable = p;
|
||||
detectable = d;
|
||||
color = Color.black;
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
if (file != null)
|
||||
icon = new ImageIcon(file);
|
||||
}
|
||||
public Material(Color c, boolean p, boolean d) {
|
||||
passable = p;
|
||||
detectable = d;
|
||||
color = c;
|
||||
}
|
||||
|
||||
public void Draw(Graphics g, RoomDisplay rd, int x, int y)
|
||||
{
|
||||
if (icon==null)
|
||||
{
|
||||
// Blank Background
|
||||
g.setColor(color);
|
||||
g.fillRect(x*28,y*32,28,32);
|
||||
// if (color!=Color.BLACK){
|
||||
// g.setColor(color.brighter());
|
||||
// g.drawLine(x*28, y*32, x*28+27, y*32);
|
||||
// g.drawLine(x*28, y*32, x*28, y*32+31);
|
||||
// g.setColor(color.darker());
|
||||
// g.drawLine(x*28+27, y*32, x*28+27, y*32+31);
|
||||
// g.drawLine(x*28, y*32+31, x*28+27, y*32+31);
|
||||
// }
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Material Background
|
||||
g.drawImage(icon.getImage(), x*28, y*32, rd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
if (file != null) {
|
||||
icon = new ImageIcon(file);
|
||||
}
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
}
|
||||
public void Draw(Graphics g, RoomDisplay rd, int x, int y) {
|
||||
if (icon == null) {
|
||||
// Blank Background
|
||||
g.setColor(color);
|
||||
g.fillRect(x * 28, y * 32, 28, 32);
|
||||
}
|
||||
else {
|
||||
// Material Background
|
||||
g.drawImage(icon.getImage(), x * 28, y * 32, rd);
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
}
|
||||
|
||||
public boolean Passable(Item item)
|
||||
{
|
||||
return passable;
|
||||
}
|
||||
public void Animate() {
|
||||
}
|
||||
|
||||
public boolean Detectable(Item item)
|
||||
{
|
||||
return detectable;
|
||||
}
|
||||
public boolean Passable(Item item) {
|
||||
return passable;
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (getClass() == mat.getClass()
|
||||
&& color == mat.color
|
||||
&& passable == mat.passable
|
||||
&& detectable == mat.detectable
|
||||
&& file == mat.file)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public boolean Detectable(Item item) {
|
||||
return detectable;
|
||||
}
|
||||
|
||||
public static Material FindSimiliar(Material mat1)
|
||||
{
|
||||
for (int a=0; a<level.materials.size(); a++)
|
||||
{
|
||||
Material mat2 = (Material) level.materials.elementAt(a);
|
||||
if (mat1.equals(mat2))
|
||||
return mat2;
|
||||
}
|
||||
level.materials.addElement(mat1);
|
||||
return mat1;
|
||||
}
|
||||
public boolean equals(Material mat) {
|
||||
return getClass() == mat.getClass()
|
||||
&& color == mat.color
|
||||
&& passable == mat.passable
|
||||
&& detectable == mat.detectable
|
||||
&& (file == null ? mat.file == null : file.equals(mat.file));
|
||||
}
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
Object newObject = null;
|
||||
try
|
||||
{
|
||||
newObject = super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e) {}
|
||||
return newObject;
|
||||
}
|
||||
public static Material FindSimiliar(Material mat1) {
|
||||
for (int a = 0; a < level.materials.size(); a++) {
|
||||
Material mat2 = level.materials.elementAt(a);
|
||||
if (mat1.equals(mat2)) {
|
||||
return mat2;
|
||||
}
|
||||
}
|
||||
level.materials.addElement(mat1);
|
||||
return mat1;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
Object newObject = null;
|
||||
try {
|
||||
newObject = super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
}
|
||||
return newObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,44 +1,40 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.Wire;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class MineField extends Material
|
||||
{
|
||||
int hit=0;
|
||||
Item target = null;
|
||||
import java.awt.*;
|
||||
|
||||
public MineField()
|
||||
{
|
||||
super(Color.black, false, false);
|
||||
}
|
||||
public class MineField extends Material {
|
||||
private int hit = 0;
|
||||
private Item target = null;
|
||||
|
||||
public boolean Passable(Item item)
|
||||
{
|
||||
hit += 2;
|
||||
target = item;
|
||||
return false;
|
||||
}
|
||||
public MineField() {
|
||||
super(Color.black, false, false);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
if (hit>0)
|
||||
hit--;
|
||||
if (hit>=2)
|
||||
{
|
||||
target.room = (Room) level.rooms.elementAt(58);
|
||||
target.charge=0;
|
||||
if (target.InternalRoom != null)
|
||||
{
|
||||
Room room = target.InternalRoom;
|
||||
if (room.wires.size()>0)
|
||||
for(int a=0; a<room.wires.size(); a++)
|
||||
((Wire) room.wires.elementAt(0)).Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean Passable(Item item) {
|
||||
hit += 2;
|
||||
target = item;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
if (hit > 0) {
|
||||
hit--;
|
||||
}
|
||||
if (hit >= 2) {
|
||||
target.room = level.rooms.elementAt(58);
|
||||
target.charge = 0;
|
||||
if (target.InternalRoom != null) {
|
||||
Room room = target.InternalRoom;
|
||||
if (room.wires.size() > 0) {
|
||||
for (int a = 0; a < room.wires.size(); a++) {
|
||||
room.wires.elementAt(0).Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,11 +2,9 @@ package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class Monitor extends Material
|
||||
{
|
||||
public Monitor()
|
||||
{
|
||||
super(Color.red,true,false);
|
||||
}
|
||||
public class Monitor extends Material {
|
||||
public Monitor() {
|
||||
super(Color.red, true, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,139 +1,135 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class MultiButton extends Material
|
||||
{
|
||||
public int number; //0=starter, 1,2,3,4,5,6,7,8,9 = buttons
|
||||
transient ImageIcon images[];
|
||||
static int[] states = new int[10]; //0=Blue, 1=White, 2=Orange
|
||||
public Date timeout;
|
||||
transient Room room=null;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
public MultiButton(int n, int s)
|
||||
{
|
||||
super(true, false);
|
||||
number = n;
|
||||
states[number] = s;
|
||||
}
|
||||
public class MultiButton extends Material {
|
||||
private int number; //0=starter, 1,2,3,4,5,6,7,8,9 = buttons
|
||||
private transient ImageIcon[] images;
|
||||
private static int[] states = new int[10]; //0=Blue, 1=White, 2=Orange
|
||||
private Date timeout;
|
||||
private transient Room room = null;
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
images = new ImageIcon[3];
|
||||
for (int a=0; a<3; a++)
|
||||
{
|
||||
images[a] = new ImageIcon(new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
Color c = Color.blue;
|
||||
if (a==1)
|
||||
c = Color.white;
|
||||
else if (a==2)
|
||||
c = new Color(255,128,0);
|
||||
g2.setColor(c);
|
||||
g.fillRect(0,0,28,32);
|
||||
g2.setColor(Color.black);
|
||||
g.fillRect(4,14,20,4);
|
||||
g.fillRect(8,12,12,8);
|
||||
g.fillRect(12,8,4,16);
|
||||
g2.setColor(c);
|
||||
g.fillRect(12,14,4,4);
|
||||
}
|
||||
|
||||
icon = images[0];
|
||||
}
|
||||
public MultiButton(int n, int s) {
|
||||
super(true, false);
|
||||
number = n;
|
||||
states[number] = s;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (room==null)
|
||||
room = item.room;
|
||||
|
||||
if (number==0)
|
||||
{
|
||||
if (states[0]==1)
|
||||
{
|
||||
states[0]=2;
|
||||
for (int a=1; a<10; a++)
|
||||
states[a]=1;
|
||||
timeout = new Date(new Date().getTime() + 30000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean okay = true;
|
||||
if (states[0]<2) okay=false;
|
||||
for (int a=1; a<number; a++)
|
||||
if (states[a]!=2) okay=false;
|
||||
if (okay)
|
||||
{
|
||||
states[number]=2;
|
||||
timeout = new Date(new Date().getTime() + 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
images = new ImageIcon[3];
|
||||
for (int a = 0; a < 3; a++) {
|
||||
images[a] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try {
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
Color c = Color.blue;
|
||||
if (a == 1) {
|
||||
c = Color.white;
|
||||
}
|
||||
else if (a == 2) {
|
||||
c = new Color(255, 128, 0);
|
||||
}
|
||||
g2.setColor(c);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g2.setColor(Color.black);
|
||||
g.fillRect(4, 14, 20, 4);
|
||||
g.fillRect(8, 12, 12, 8);
|
||||
g.fillRect(12, 8, 4, 16);
|
||||
g2.setColor(c);
|
||||
g.fillRect(12, 14, 4, 4);
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
icon = images[states[number]];
|
||||
|
||||
if (number!=0)
|
||||
return;
|
||||
|
||||
if (states[0]==0)
|
||||
{
|
||||
states[0] = 1;
|
||||
for (int a=1; a<10; a++)
|
||||
states[a]=0;
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
for (int a=0; a<10; a++)
|
||||
if (states[a]!=2)
|
||||
flag=false;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
Portal ptl = new Portal("ROEndGame.lvl",true,true);
|
||||
level.materials.addElement(ptl);
|
||||
room.SetMaterial(10,9,ptl);
|
||||
}
|
||||
|
||||
if (states[0]==2)
|
||||
{
|
||||
Date now = new Date();
|
||||
if (now.getTime() > timeout.getTime())
|
||||
{
|
||||
states[0]=1;
|
||||
for (int a=1; a<10; a++)
|
||||
states[a]=0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
icon = images[0];
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (number == ((MultiButton)mat).number)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (room == null) {
|
||||
room = item.room;
|
||||
}
|
||||
|
||||
if (number == 0) {
|
||||
if (states[0] == 1) {
|
||||
states[0] = 2;
|
||||
for (int a = 1; a < 10; a++) {
|
||||
states[a] = 1;
|
||||
}
|
||||
timeout = new Date(new Date().getTime() + 30000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
boolean okay = true;
|
||||
if (states[0] < 2) {
|
||||
okay = false;
|
||||
}
|
||||
for (int a = 1; a < number; a++) {
|
||||
if (states[a] != 2) {
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
states[number] = 2;
|
||||
timeout = new Date(new Date().getTime() + 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
icon = images[states[number]];
|
||||
|
||||
if (number != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (states[0] == 0) {
|
||||
states[0] = 1;
|
||||
for (int a = 1; a < 10; a++) {
|
||||
states[a] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
for (int a = 0; a < 10; a++) {
|
||||
if (states[a] != 2) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
Portal ptl = new Portal("ROEndGame.lvl", true, true);
|
||||
level.materials.addElement(ptl);
|
||||
room.SetMaterial(10, 9, ptl);
|
||||
}
|
||||
|
||||
if (states[0] == 2) {
|
||||
Date now = new Date();
|
||||
if (now.getTime() > timeout.getTime()) {
|
||||
states[0] = 1;
|
||||
for (int a = 1; a < 10; a++) {
|
||||
states[a] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (number == ((MultiButton) mat).number) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,157 +1,149 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class MultiSwitch extends Material
|
||||
{
|
||||
public int number; //0=starter, 1,2,3,4=pistons
|
||||
transient ImageIcon images[];
|
||||
static int[] states = {0,0,0,0,0}; //0=Blue, 1=White, 2=Orange
|
||||
public Date timeout;
|
||||
transient Room room=null;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
public MultiSwitch(int n, int s)
|
||||
{
|
||||
super(true, false);
|
||||
number = n;
|
||||
states[number] = s;
|
||||
}
|
||||
public class MultiSwitch extends Material {
|
||||
private int number; //0=starter, 1,2,3,4=pistons
|
||||
private transient ImageIcon[] images;
|
||||
private static int[] states = {0, 0, 0, 0, 0}; //0=Blue, 1=White, 2=Orange
|
||||
private Date timeout;
|
||||
private transient Room room = null;
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
images = new ImageIcon[3];
|
||||
for (int a=0; a<3; a++)
|
||||
{
|
||||
images[a] = new ImageIcon(new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0,0,28,32);
|
||||
if (a==0)
|
||||
g2.setColor(Color.blue);
|
||||
else if (a==1)
|
||||
g2.setColor(Color.white);
|
||||
else if (a==2)
|
||||
g2.setColor(new Color(255,128,0));
|
||||
|
||||
g2.fillRect(12,4,6,24);
|
||||
g2.fillRect(18,12,10,8);
|
||||
}
|
||||
|
||||
icon = images[0];
|
||||
}
|
||||
public MultiSwitch(int n, int s) {
|
||||
super(true, false);
|
||||
number = n;
|
||||
states[number] = s;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (room==null)
|
||||
room = item.room;
|
||||
|
||||
if (number==0)
|
||||
{
|
||||
if (states[0]!=2)
|
||||
{
|
||||
states[0]=2;
|
||||
states[1]=1;
|
||||
states[2]=1;
|
||||
states[3]=1;
|
||||
states[4]=1;
|
||||
timeout = new Date(new Date().getTime() + 5000);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean okay = true;
|
||||
if (states[0]<2) okay=false;
|
||||
for (int a=1; a<number; a++)
|
||||
if (states[a]!=2) okay=false;
|
||||
if (okay)
|
||||
states[number]=2;
|
||||
else
|
||||
{
|
||||
states[0]=0;
|
||||
states[1]=0;
|
||||
states[2]=0;
|
||||
states[3]=0;
|
||||
states[4]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
images = new ImageIcon[3];
|
||||
for (int a = 0; a < 3; a++) {
|
||||
images[a] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try {
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0, 0, 28, 32);
|
||||
if (a == 0) {
|
||||
g2.setColor(Color.blue);
|
||||
}
|
||||
else if (a == 1) {
|
||||
g2.setColor(Color.white);
|
||||
}
|
||||
else if (a == 2) {
|
||||
g2.setColor(new Color(255, 128, 0));
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
icon = images[states[number]];
|
||||
|
||||
if (number!=0)
|
||||
return;
|
||||
|
||||
boolean flag = true;
|
||||
for (int a=0; a<5; a++)
|
||||
if (states[a]!=2)
|
||||
flag=false;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
for (int a=0; a<level.materials.size(); a++)
|
||||
{
|
||||
Material mat = (Material) level.materials.elementAt(a);
|
||||
if (mat instanceof BinaryLock)
|
||||
{
|
||||
BinaryLock bl = (BinaryLock) mat;
|
||||
if (bl.program.length==1)
|
||||
{
|
||||
int[][] program = {
|
||||
{BinaryLock.NARROW},
|
||||
{2,10,0, 3,10,0, 4,10,0, 5,10,0, 2,9,4, 3,8,4, 4,8,4, 5,9,4},
|
||||
{2,9,0, 3,8,0, 4,8,0, 5,9,0, 1,9,4, 1,8,4, 6,9,4, 6,8,4},
|
||||
{BinaryLock.NARROW},
|
||||
{2,9,4, 3,8,4, 4,8,4, 5,9,4, 1,9,0, 1,8,0, 6,9,0, 6,8,0},
|
||||
{2,10,4, 3,10,4, 4,10,4, 5,10,4, 2,9,0, 3,8,0, 4,8,0, 5,9,0}
|
||||
};
|
||||
bl.program = program;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (states[0]==2)
|
||||
{
|
||||
Date now = new Date();
|
||||
if (now.getTime() > timeout.getTime())
|
||||
{
|
||||
states[0]=0;
|
||||
states[1]=0;
|
||||
states[2]=0;
|
||||
states[3]=0;
|
||||
states[4]=0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
g2.fillRect(12, 4, 6, 24);
|
||||
g2.fillRect(18, 12, 10, 8);
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (number == ((MultiSwitch)mat).number)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
icon = images[0];
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (room == null) {
|
||||
room = item.room;
|
||||
}
|
||||
|
||||
if (number == 0) {
|
||||
if (states[0] != 2) {
|
||||
states[0] = 2;
|
||||
states[1] = 1;
|
||||
states[2] = 1;
|
||||
states[3] = 1;
|
||||
states[4] = 1;
|
||||
timeout = new Date(new Date().getTime() + 5000);
|
||||
}
|
||||
}
|
||||
else {
|
||||
boolean okay = true;
|
||||
if (states[0] < 2) {
|
||||
okay = false;
|
||||
}
|
||||
for (int a = 1; a < number; a++) {
|
||||
if (states[a] != 2) {
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
states[number] = 2;
|
||||
}
|
||||
else {
|
||||
states[0] = 0;
|
||||
states[1] = 0;
|
||||
states[2] = 0;
|
||||
states[3] = 0;
|
||||
states[4] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
icon = images[states[number]];
|
||||
|
||||
if (number != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean flag = true;
|
||||
for (int a = 0; a < 5; a++) {
|
||||
if (states[a] != 2) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
for (int a = 0; a < level.materials.size(); a++) {
|
||||
Material mat = level.materials.elementAt(a);
|
||||
if (mat instanceof BinaryLock) {
|
||||
BinaryLock bl = (BinaryLock) mat;
|
||||
if (bl.program.length == 1) {
|
||||
bl.program = new int[][]{
|
||||
{BinaryLock.NARROW},
|
||||
{2, 10, 0, 3, 10, 0, 4, 10, 0, 5, 10, 0, 2, 9, 4, 3, 8, 4, 4, 8, 4, 5, 9, 4},
|
||||
{2, 9, 0, 3, 8, 0, 4, 8, 0, 5, 9, 0, 1, 9, 4, 1, 8, 4, 6, 9, 4, 6, 8, 4},
|
||||
{BinaryLock.NARROW},
|
||||
{2, 9, 4, 3, 8, 4, 4, 8, 4, 5, 9, 4, 1, 9, 0, 1, 8, 0, 6, 9, 0, 6, 8, 0},
|
||||
{2, 10, 4, 3, 10, 4, 4, 10, 4, 5, 10, 4, 2, 9, 0, 3, 8, 0, 4, 8, 0, 5, 9, 0}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (states[0] == 2) {
|
||||
Date now = new Date();
|
||||
if (now.getTime() > timeout.getTime()) {
|
||||
states[0] = 0;
|
||||
states[1] = 0;
|
||||
states[2] = 0;
|
||||
states[3] = 0;
|
||||
states[4] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (number == ((MultiSwitch) mat).number) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,101 +10,92 @@ import javax.swing.ImageIcon;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Sentry;
|
||||
|
||||
public class PanicButton extends Material
|
||||
{
|
||||
boolean state = true;
|
||||
transient ImageIcon images[];
|
||||
transient Sentry sentry;
|
||||
int number;
|
||||
public class PanicButton extends Material {
|
||||
private boolean state = true;
|
||||
private transient ImageIcon[] images;
|
||||
private transient Sentry sentry;
|
||||
private int number;
|
||||
|
||||
// image[0] = blue, off, Sentry alive
|
||||
// image[1] = orange, on, Sentry dead
|
||||
|
||||
public PanicButton(int n)
|
||||
{
|
||||
super(true, false);
|
||||
number = n;
|
||||
GenerateIcons();
|
||||
}
|
||||
public PanicButton(int n) {
|
||||
super(true, false);
|
||||
number = n;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
images = new ImageIcon[2];
|
||||
for (int a=0; a<2; a++)
|
||||
{
|
||||
images[a] = new ImageIcon(new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0,0,28,32);
|
||||
Color color;
|
||||
if (a==0)
|
||||
color = Color.blue;
|
||||
else
|
||||
color = new Color(255,128,0);
|
||||
|
||||
g.setColor(color);
|
||||
g.fillRect(8,0,12,26);
|
||||
g.fillRect(4,2,20,22);
|
||||
g.fillRect(0,4,28,18);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(8,6,12,14);
|
||||
g.fillRect(4,8,20,10);
|
||||
g.setColor(color);
|
||||
g.fillRect(12,8,4,10);
|
||||
g.fillRect(8,10,12,6);
|
||||
}
|
||||
icon = images[0];
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
images = new ImageIcon[2];
|
||||
for (int a = 0; a < 2; a++) {
|
||||
images[a] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try {
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0, 0, 28, 32);
|
||||
Color color;
|
||||
if (a == 0) {
|
||||
color = Color.blue;
|
||||
}
|
||||
else {
|
||||
color = new Color(255, 128, 0);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item == level.player && level.player.carriedBy == null)
|
||||
{
|
||||
if (sentry==null)
|
||||
{
|
||||
for (int a=0; a<level.items.size(); a++)
|
||||
{
|
||||
Item i = (Item) level.items.elementAt(a);
|
||||
if (i instanceof Sentry && i.room == item.room)
|
||||
sentry = (Sentry) i;
|
||||
}
|
||||
}
|
||||
if (sentry != null)
|
||||
{
|
||||
if (state)
|
||||
{ // turn off
|
||||
sentry.previousBehavior = sentry.behavior;
|
||||
sentry.behavior = -2;
|
||||
icon = images[1];
|
||||
state = false;
|
||||
}
|
||||
else
|
||||
{ // turn on
|
||||
sentry.behavior = sentry.previousBehavior;
|
||||
icon = images[0];
|
||||
state = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
g.setColor(color);
|
||||
g.fillRect(8, 0, 12, 26);
|
||||
g.fillRect(4, 2, 20, 22);
|
||||
g.fillRect(0, 4, 28, 18);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(8, 6, 12, 14);
|
||||
g.fillRect(4, 8, 20, 10);
|
||||
g.setColor(color);
|
||||
g.fillRect(12, 8, 4, 10);
|
||||
g.fillRect(8, 10, 12, 6);
|
||||
}
|
||||
icon = images[0];
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (number == ((PanicButton)mat).number)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player && level.player.carriedBy == null) {
|
||||
if (sentry == null) {
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
Item i = level.items.elementAt(a);
|
||||
if (i instanceof Sentry && i.room == item.room) {
|
||||
sentry = (Sentry) i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sentry != null) {
|
||||
if (state) { // turn off
|
||||
sentry.previousBehavior = sentry.behavior;
|
||||
sentry.behavior = -2;
|
||||
icon = images[1];
|
||||
state = false;
|
||||
}
|
||||
else { // turn on
|
||||
sentry.behavior = sentry.previousBehavior;
|
||||
icon = images[0];
|
||||
state = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (number == ((PanicButton) mat).number) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,39 +9,34 @@ import javax.swing.ImageIcon;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class PeriscopeDown extends Material
|
||||
{
|
||||
public PeriscopeDown()
|
||||
{
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public class PeriscopeDown extends Material {
|
||||
public PeriscopeDown() {
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
|
||||
if (item == level.player)
|
||||
if (item.x < 462 || item.y > 80)
|
||||
{
|
||||
GenericRobot gr = (GenericRobot) level.player.room.portalItem;
|
||||
level.currentViewer = level.player;
|
||||
gr.periscope = false;
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
|
||||
if (item == level.player) {
|
||||
if (item.x < 462 || item.y > 80) {
|
||||
GenericRobot gr = (GenericRobot) level.player.room.portalItem;
|
||||
level.currentViewer = level.player;
|
||||
gr.periscope = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,53 +9,47 @@ import javax.swing.ImageIcon;
|
||||
import com.droidquest.items.GenericRobot;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class PeriscopeUp extends Material
|
||||
{
|
||||
public PeriscopeUp()
|
||||
{
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
public class PeriscopeUp extends Material {
|
||||
public PeriscopeUp() {
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(8,9,12,2);
|
||||
g.fillRect(8,21,12,2);
|
||||
g.fillRect(4,11,4,2);
|
||||
g.fillRect(4,19,4,2);
|
||||
g.fillRect(20,11,4,2);
|
||||
g.fillRect(20,19,4,2);
|
||||
g.fillRect(0,13,4,6);
|
||||
g.fillRect(24,13,4,6);
|
||||
g.fillRect(8,13,12,6);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item == level.player)
|
||||
if (item.x > 462 && item.y < 80)
|
||||
{
|
||||
GenericRobot gr = (GenericRobot) level.player.room.portalItem;
|
||||
level.currentViewer = gr;
|
||||
gr.periscope = true;
|
||||
}
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(8, 9, 12, 2);
|
||||
g.fillRect(8, 21, 12, 2);
|
||||
g.fillRect(4, 11, 4, 2);
|
||||
g.fillRect(4, 19, 4, 2);
|
||||
g.fillRect(20, 11, 4, 2);
|
||||
g.fillRect(20, 19, 4, 2);
|
||||
g.fillRect(0, 13, 4, 6);
|
||||
g.fillRect(24, 13, 4, 6);
|
||||
g.fillRect(8, 13, 12, 6);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
if (item.x > 462 && item.y < 80) {
|
||||
GenericRobot gr = (GenericRobot) level.player.room.portalItem;
|
||||
level.currentViewer = gr;
|
||||
gr.periscope = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,68 +1,59 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.avatars.GameCursor;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class PlayerBlocker extends Material
|
||||
{
|
||||
transient ImageIcon images[];
|
||||
String[] filenames;
|
||||
int animationState=0;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public PlayerBlocker(Color col)
|
||||
{
|
||||
color = col;
|
||||
detectable = false;
|
||||
}
|
||||
public class PlayerBlocker extends Material {
|
||||
private transient ImageIcon[] images;
|
||||
private String[] filenames;
|
||||
private int animationState = 0;
|
||||
|
||||
public PlayerBlocker(String[] files)
|
||||
{
|
||||
detectable = false;
|
||||
filenames = files;
|
||||
GenerateIcons();
|
||||
}
|
||||
public PlayerBlocker(Color col) {
|
||||
color = col;
|
||||
detectable = false;
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
if (filenames != null)
|
||||
{
|
||||
int numfiles = filenames.length;
|
||||
images = new ImageIcon[numfiles];
|
||||
for (int a=0; a<filenames.length; a++)
|
||||
images[a] = new ImageIcon("images/"+ filenames[a]);
|
||||
icon = images[0];
|
||||
}
|
||||
else
|
||||
super.GenerateIcons();
|
||||
}
|
||||
public PlayerBlocker(String[] files) {
|
||||
detectable = false;
|
||||
filenames = files;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
if (images!=null)
|
||||
{
|
||||
animationState++;
|
||||
if (animationState==images.length)
|
||||
animationState=0;
|
||||
icon = images[animationState];
|
||||
}
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
if (filenames != null) {
|
||||
int numfiles = filenames.length;
|
||||
images = new ImageIcon[numfiles];
|
||||
for (int a = 0; a < filenames.length; a++) {
|
||||
images[a] = new ImageIcon("images/" + filenames[a]);
|
||||
}
|
||||
icon = images[0];
|
||||
}
|
||||
else {
|
||||
super.GenerateIcons();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean Passable(Item item)
|
||||
{
|
||||
if (level.gameCursor.getClass().toString().endsWith("GameCursor"))
|
||||
{
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item)
|
||||
return false;
|
||||
}
|
||||
if (item == level.player)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
public void Animate() {
|
||||
if (images != null) {
|
||||
animationState++;
|
||||
if (animationState == images.length) {
|
||||
animationState = 0;
|
||||
}
|
||||
icon = images[animationState];
|
||||
}
|
||||
}
|
||||
|
||||
public boolean Passable(Item item) {
|
||||
if (level.gameCursor.getClass().toString().endsWith("GameCursor")) {
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == item) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return item != level.player;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,68 +1,61 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class Portal extends Material
|
||||
{
|
||||
public String levelName;
|
||||
public boolean bringStuff;
|
||||
public boolean initLevel;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public Portal(String ln, boolean bs, boolean il)
|
||||
{
|
||||
super("",true, false);
|
||||
levelName = ln;
|
||||
bringStuff = bs;
|
||||
initLevel = il;
|
||||
GenerateIcons();
|
||||
}
|
||||
public class Portal extends Material {
|
||||
public String levelName;
|
||||
public boolean bringStuff;
|
||||
public boolean initLevel;
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0,0,28,2);
|
||||
g.fillRect(0,0,2,32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public Portal(String ln, boolean bs, boolean il) {
|
||||
super("", true, false);
|
||||
levelName = ln;
|
||||
bringStuff = bs;
|
||||
initLevel = il;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item == level.player && level.player.carriedBy == null)
|
||||
{
|
||||
if (item.x%28==0 && item.y%32==0)
|
||||
level.portal = this;
|
||||
}
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (levelName == ((Portal)mat).levelName
|
||||
&& bringStuff == ((Portal)mat).bringStuff
|
||||
&& initLevel == ((Portal)mat).initLevel)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, 28, 2);
|
||||
g.fillRect(0, 0, 2, 32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player && level.player.carriedBy == null) {
|
||||
if (item.x % 28 == 0 && item.y % 32 == 0) {
|
||||
level.portal = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (levelName.equals(((Portal) mat).levelName)
|
||||
&& bringStuff == ((Portal) mat).bringStuff
|
||||
&& initLevel == ((Portal) mat).initLevel) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -2,11 +2,9 @@ package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class PrototypeBurner extends Material
|
||||
{
|
||||
public PrototypeBurner()
|
||||
{
|
||||
color = Color.black;
|
||||
passable = true;
|
||||
}
|
||||
public class PrototypeBurner extends Material {
|
||||
public PrototypeBurner() {
|
||||
color = Color.black;
|
||||
passable = true;
|
||||
}
|
||||
}
|
@@ -5,31 +5,25 @@ import java.awt.Color;
|
||||
import com.droidquest.avatars.GameCursor;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class RobotBlocker extends Material
|
||||
{
|
||||
// Creates a Material that blocks one particular Class of Robot.
|
||||
Item robot;
|
||||
public class RobotBlocker extends Material {
|
||||
// Creates a Material that blocks one particular Class of Robot.
|
||||
private Item robot;
|
||||
|
||||
public RobotBlocker(Item rob, Color col)
|
||||
{
|
||||
robot = rob;
|
||||
color = col;
|
||||
passable = true;
|
||||
detectable = false;
|
||||
}
|
||||
public RobotBlocker(Item rob, Color col) {
|
||||
robot = rob;
|
||||
color = col;
|
||||
passable = true;
|
||||
detectable = false;
|
||||
}
|
||||
|
||||
public boolean Passable(Item item)
|
||||
{
|
||||
if (level.gameCursor.getClass().toString().endsWith("GameCursor"))
|
||||
{
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == robot)
|
||||
return false;
|
||||
}
|
||||
if (item == robot || item == level.player)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
public boolean Passable(Item item) {
|
||||
if (level.gameCursor.getClass().toString().endsWith("GameCursor")) {
|
||||
GameCursor gc = (GameCursor) level.gameCursor;
|
||||
if (gc.PlayerInRobot(null) == robot) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !(item == robot || item == level.player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -8,33 +8,27 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class SecretReset extends Material
|
||||
{
|
||||
public SecretReset()
|
||||
{
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public class SecretReset extends Material {
|
||||
public SecretReset() {
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item==level.player)
|
||||
{
|
||||
level.LinkRoomsUpDown(8,7);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
level.LinkRoomsUpDown(8, 7);
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,34 +8,28 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class SecretSet extends Material
|
||||
{
|
||||
public SecretSet()
|
||||
{
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public class SecretSet extends Material {
|
||||
public SecretSet() {
|
||||
super(true, false);
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item==level.player)
|
||||
{
|
||||
level.LinkRoomsUpDown(2,7);
|
||||
level.LinkRoomsUpDown(8,2);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
level.LinkRoomsUpDown(2, 7);
|
||||
level.LinkRoomsUpDown(8, 2);
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,75 +11,72 @@ import com.droidquest.devices.DirectionalSensor;
|
||||
import com.droidquest.devices.RoomSensor;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class ShapeEditor extends Material
|
||||
{
|
||||
Item target;
|
||||
public class ShapeEditor extends Material {
|
||||
private Item target;
|
||||
|
||||
public ShapeEditor(Item item)
|
||||
{
|
||||
super(true, false);
|
||||
target = item;
|
||||
GenerateIcons();
|
||||
}
|
||||
public ShapeEditor(Item item) {
|
||||
super(true, false);
|
||||
target = item;
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
target.GenerateIcons();
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.drawImage(target.currentIcon, 14-target.getWidth()/2, 16-target.getHeight()/2, level);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
target.GenerateIcons();
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + "Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
Item newItem = null;
|
||||
if (item.editable)
|
||||
{
|
||||
if (item.getClass().toString().endsWith("Sensor"))
|
||||
{
|
||||
Item newTarget = (Item) target.clone();
|
||||
if (item.getClass().toString().endsWith("ContactSensor"))
|
||||
newItem = new ContactSensor(0,0,null,newTarget);
|
||||
else if (item.getClass().toString().endsWith("RoomSensor"))
|
||||
newItem = new RoomSensor(0,0,null,newTarget);
|
||||
else if (item.getClass().toString().endsWith("DirectionalSensor"))
|
||||
newItem = new DirectionalSensor(0,0,null,newTarget);
|
||||
}
|
||||
else
|
||||
newItem = (Item) target.clone();
|
||||
Item carrier = item.carriedBy;
|
||||
carrier.Drops();
|
||||
int itemX = item.x;
|
||||
int itemY = item.y;
|
||||
level.items.removeElement(item);
|
||||
newItem.x=itemX;
|
||||
newItem.y=itemY;
|
||||
newItem.room = carrier.room;
|
||||
level.items.addElement(newItem);
|
||||
carrier.PicksUp(newItem);
|
||||
}
|
||||
}
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.drawImage(target.currentIcon, 14 - target.getWidth() / 2, 16 - target.getHeight() / 2, level);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (target == ((ShapeEditor)mat).target)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
Item newItem = null;
|
||||
if (item.editable) {
|
||||
if (item.getClass().toString().endsWith("Sensor")) {
|
||||
Item newTarget = (Item) target.clone();
|
||||
if (item.getClass().toString().endsWith("ContactSensor")) {
|
||||
newItem = new ContactSensor(0, 0, null, newTarget);
|
||||
}
|
||||
else if (item.getClass().toString().endsWith("RoomSensor")) {
|
||||
newItem = new RoomSensor(0, 0, null, newTarget);
|
||||
}
|
||||
else if (item.getClass().toString().endsWith("DirectionalSensor")) {
|
||||
newItem = new DirectionalSensor(0, 0, null, newTarget);
|
||||
}
|
||||
}
|
||||
else {
|
||||
newItem = (Item) target.clone();
|
||||
}
|
||||
Item carrier = item.carriedBy;
|
||||
carrier.Drops();
|
||||
int itemX = item.x;
|
||||
int itemY = item.y;
|
||||
level.items.removeElement(item);
|
||||
newItem.x = itemX;
|
||||
newItem.y = itemY;
|
||||
newItem.room = carrier.room;
|
||||
level.items.addElement(newItem);
|
||||
carrier.PicksUp(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (target == ((ShapeEditor) mat).target) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -3,22 +3,18 @@ package com.droidquest.materials;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.levels.Level;
|
||||
|
||||
public class SkyGuardMat extends Material
|
||||
{
|
||||
public SkyGuardMat()
|
||||
{
|
||||
super(true,false);
|
||||
}
|
||||
public class SkyGuardMat extends Material {
|
||||
public SkyGuardMat() {
|
||||
super(true, false);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (item==level.player)
|
||||
{
|
||||
level.PlaySound(level.player.room, Level.DISCHARGESOUND);
|
||||
level.player.x = 2*28;
|
||||
level.player.y = 8*32;
|
||||
level.player.SetRoom(level.player.room.downRoom);
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (item == level.player) {
|
||||
level.PlaySound(level.player.room, Level.DISCHARGESOUND);
|
||||
level.player.x = 2 * 28;
|
||||
level.player.y = 8 * 32;
|
||||
level.player.SetRoom(level.player.room.downRoom);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -2,11 +2,9 @@ package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class SmallChipBurner extends Material
|
||||
{
|
||||
public SmallChipBurner()
|
||||
{
|
||||
color = Color.black;
|
||||
passable = true;
|
||||
}
|
||||
public class SmallChipBurner extends Material {
|
||||
public SmallChipBurner() {
|
||||
color = Color.black;
|
||||
passable = true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,247 +1,240 @@
|
||||
package com.droidquest.materials;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.Room;
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class Switch extends Material
|
||||
{
|
||||
// Programmable wall switch, normally used for opening doors when
|
||||
// touched. Each line in the program is an array of numbers, with the
|
||||
// first explaining what function the array of numbers performs.
|
||||
//
|
||||
// Wait4Contact
|
||||
// Wait4Removal
|
||||
// Wait4Time x
|
||||
// SetValueHigh
|
||||
// SetValueLow
|
||||
// Replace (x,y,m)...
|
||||
// LeftRoom
|
||||
// RightRoom
|
||||
// UpRoom
|
||||
// DownRoom
|
||||
// ResetRoom
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Date;
|
||||
|
||||
public static final int ROT_UP =0; // Rotation refers to which wall the switch is attached to
|
||||
public static final int ROT_RIGHT =1;
|
||||
public static final int ROT_DOWN =2;
|
||||
public static final int ROT_LEFT =3;
|
||||
int rotation;
|
||||
transient ImageIcon images[];
|
||||
protected boolean value;
|
||||
public class Switch extends Material {
|
||||
// Programmable wall switch, normally used for opening doors when
|
||||
// touched. Each line in the program is an array of numbers, with the
|
||||
// first explaining what function the array of numbers performs.
|
||||
//
|
||||
// Wait4Contact
|
||||
// Wait4Removal
|
||||
// Wait4Time x
|
||||
// SetValueHigh
|
||||
// SetValueLow
|
||||
// Replace (x,y,m)...
|
||||
// LeftRoom
|
||||
// RightRoom
|
||||
// UpRoom
|
||||
// DownRoom
|
||||
// ResetRoom
|
||||
|
||||
public static final int WAIT4CONTACT =-1;
|
||||
public static final int WAIT4REMOVAL =-2;
|
||||
public static final int WAIT4TIME =-3;
|
||||
public static final int SETVALUEHIGH =-4;
|
||||
public static final int SETVALUELOW =-5;
|
||||
public static final int REPLACE =-6;
|
||||
public static final int LEFTROOM =-7;
|
||||
public static final int RIGHTROOM =-8;
|
||||
public static final int UPROOM =-9;
|
||||
public static final int DOWNROOM =-10;
|
||||
public static final int RESETROOM =-11;
|
||||
//public static final int WAIT4PLAYERCONTACT = -12;
|
||||
//If I actually add this, it'll change the signature.
|
||||
public static final int ROT_UP = 0; // Rotation refers to which wall the switch is attached to
|
||||
public static final int ROT_RIGHT = 1;
|
||||
public static final int ROT_DOWN = 2;
|
||||
protected static final int ROT_LEFT = 3;
|
||||
private int rotation;
|
||||
private transient ImageIcon[] images;
|
||||
protected boolean value;
|
||||
|
||||
int switchState=0;
|
||||
transient Room room;
|
||||
transient Room currentRoom;
|
||||
int[][] program;
|
||||
Item trigger=null;
|
||||
Date timeout;
|
||||
boolean timing=false;
|
||||
public static final int WAIT4CONTACT = -1;
|
||||
public static final int WAIT4REMOVAL = -2;
|
||||
public static final int WAIT4TIME = -3;
|
||||
public static final int SETVALUEHIGH = -4;
|
||||
public static final int SETVALUELOW = -5;
|
||||
public static final int REPLACE = -6;
|
||||
private static final int LEFTROOM = -7;
|
||||
private static final int RIGHTROOM = -8;
|
||||
private static final int UPROOM = -9;
|
||||
public static final int DOWNROOM = -10;
|
||||
private static final int RESETROOM = -11;
|
||||
//public static final int WAIT4PLAYERCONTACT = -12;
|
||||
//If I actually add this, it'll change the signature.
|
||||
|
||||
public Switch(int rot)
|
||||
{
|
||||
super(true,false);
|
||||
int[][] p = {{0}};
|
||||
program = p;
|
||||
GenerateIcons();
|
||||
rotation = rot;
|
||||
}
|
||||
private int switchState = 0;
|
||||
private transient Room room;
|
||||
private transient Room currentRoom;
|
||||
private int[][] program;
|
||||
private Item trigger = null;
|
||||
private Date timeout;
|
||||
private boolean timing = false;
|
||||
|
||||
public Switch(int rot, int[][] p)
|
||||
{
|
||||
super(true,false);
|
||||
program = p;
|
||||
GenerateIcons();
|
||||
rotation = rot;
|
||||
}
|
||||
protected Switch(int rot) {
|
||||
super(true, false);
|
||||
program = new int[][]{{0}};
|
||||
GenerateIcons();
|
||||
rotation = rot;
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
images = new ImageIcon[2];
|
||||
for (int a=0; a<2; a++)
|
||||
{
|
||||
images[a] = new ImageIcon(new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0,0,28,32);
|
||||
if (a==0)
|
||||
g2.setColor(Color.white);
|
||||
else
|
||||
g2.setColor(new Color(255,128,0));
|
||||
|
||||
switch (rotation)
|
||||
{
|
||||
case ROT_UP:
|
||||
g2.fillRect(2,10,24,6);
|
||||
g2.fillRect(10,0,8,10);
|
||||
break;
|
||||
case ROT_RIGHT:
|
||||
g2.fillRect(12,4,6,24);
|
||||
g2.fillRect(18,12,10,8);
|
||||
break;
|
||||
case ROT_DOWN:
|
||||
g2.fillRect(2,16,24,6);
|
||||
g2.fillRect(10,22,8,10);
|
||||
break;
|
||||
case ROT_LEFT:
|
||||
g2.fillRect(10,4,6,24);
|
||||
g2.fillRect(0,12,10,8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public Switch(int rot, int[][] p) {
|
||||
super(true, false);
|
||||
program = p;
|
||||
GenerateIcons();
|
||||
rotation = rot;
|
||||
}
|
||||
|
||||
public boolean equals(Material mat)
|
||||
{
|
||||
if (super.equals(mat))
|
||||
if (rotation == ((Switch)mat).rotation
|
||||
&& value == ((Switch)mat).value
|
||||
&& program == ((Switch)mat).program)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
images = new ImageIcon[2];
|
||||
for (int a = 0; a < 2; a++) {
|
||||
images[a] = new ImageIcon(new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
Graphics g;
|
||||
try {
|
||||
g = images[a].getImage().getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setBackground(Color.black);
|
||||
g2.clearRect(0, 0, 28, 32);
|
||||
if (a == 0) {
|
||||
g2.setColor(Color.white);
|
||||
}
|
||||
else {
|
||||
g2.setColor(new Color(255, 128, 0));
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (switchState == program.length)
|
||||
switchState=0;
|
||||
|
||||
if (program[switchState][0]==WAIT4CONTACT)
|
||||
{
|
||||
trigger = item;
|
||||
room = item.room;
|
||||
currentRoom = room;
|
||||
switchState++;
|
||||
}
|
||||
|
||||
if (program[switchState][0]== -12) // == WAIT4PLAYERCONTACT
|
||||
if (item == level.player)
|
||||
{
|
||||
trigger = item;
|
||||
room = item.room;
|
||||
currentRoom = room;
|
||||
switchState++;
|
||||
}
|
||||
}
|
||||
switch (rotation) {
|
||||
case ROT_UP:
|
||||
g2.fillRect(2, 10, 24, 6);
|
||||
g2.fillRect(10, 0, 8, 10);
|
||||
break;
|
||||
case ROT_RIGHT:
|
||||
g2.fillRect(12, 4, 6, 24);
|
||||
g2.fillRect(18, 12, 10, 8);
|
||||
break;
|
||||
case ROT_DOWN:
|
||||
g2.fillRect(2, 16, 24, 6);
|
||||
g2.fillRect(10, 22, 8, 10);
|
||||
break;
|
||||
case ROT_LEFT:
|
||||
g2.fillRect(10, 4, 6, 24);
|
||||
g2.fillRect(0, 12, 10, 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
if (switchState == program.length)
|
||||
switchState=0;
|
||||
|
||||
if (value)
|
||||
icon = images[1];
|
||||
else
|
||||
icon = images[0];
|
||||
|
||||
switch (program[switchState][0])
|
||||
{
|
||||
case WAIT4REMOVAL:
|
||||
{
|
||||
Dimension d = trigger.GetXY();
|
||||
int bigXL = d.width / 28;
|
||||
int bigXR = (d.width + trigger.getWidth() ) / 28;
|
||||
int bigYT = d.height / 32;
|
||||
int bigYB = (d.height + trigger.getHeight()) /32;
|
||||
boolean removed = true;
|
||||
for (int Y=bigYT; Y<bigYB; Y++)
|
||||
for (int X=bigXL; X<bigXR; X++)
|
||||
if (trigger.room.MaterialArray[Y][X]==this)
|
||||
removed=false;
|
||||
if (removed)
|
||||
switchState++;
|
||||
currentRoom = room;
|
||||
}
|
||||
break;
|
||||
case WAIT4TIME:
|
||||
if (timing)
|
||||
{
|
||||
Date now = new Date();
|
||||
if (now.getTime() >= timeout.getTime())
|
||||
{
|
||||
switchState++;
|
||||
timing = false;
|
||||
currentRoom = room;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timeout = new Date(new Date().getTime() + 1000*program[switchState][1]);
|
||||
timing = true;
|
||||
}
|
||||
break;
|
||||
case SETVALUEHIGH:
|
||||
value=true;
|
||||
switchState++;
|
||||
break;
|
||||
case SETVALUELOW:
|
||||
value=false;
|
||||
switchState++;
|
||||
break;
|
||||
case REPLACE:
|
||||
if (currentRoom == null)
|
||||
currentRoom = trigger.room;
|
||||
for (int a=0; a<(program[switchState].length-1)/3; a++)
|
||||
currentRoom.SetMaterial(program[switchState][a*3+1],
|
||||
program[switchState][a*3+2],
|
||||
program[switchState][a*3+3]);
|
||||
switchState++;
|
||||
break;
|
||||
case LEFTROOM:
|
||||
currentRoom = currentRoom.leftRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case RIGHTROOM:
|
||||
currentRoom = currentRoom.rightRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case UPROOM:
|
||||
currentRoom = currentRoom.upRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case DOWNROOM:
|
||||
currentRoom = currentRoom.downRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case RESETROOM:
|
||||
currentRoom = room;
|
||||
switchState++;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public boolean equals(Material mat) {
|
||||
if (super.equals(mat)) {
|
||||
if (rotation == ((Switch) mat).rotation
|
||||
&& value == ((Switch) mat).value
|
||||
&& program == ((Switch) mat).program) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item) {
|
||||
if (switchState == program.length) {
|
||||
switchState = 0;
|
||||
}
|
||||
|
||||
if (program[switchState][0] == WAIT4CONTACT) {
|
||||
trigger = item;
|
||||
room = item.room;
|
||||
currentRoom = room;
|
||||
switchState++;
|
||||
}
|
||||
|
||||
if (program[switchState][0] == -12) // == WAIT4PLAYERCONTACT
|
||||
{
|
||||
if (item == level.player) {
|
||||
trigger = item;
|
||||
room = item.room;
|
||||
currentRoom = room;
|
||||
switchState++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
if (switchState == program.length) {
|
||||
switchState = 0;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
icon = images[1];
|
||||
}
|
||||
else {
|
||||
icon = images[0];
|
||||
}
|
||||
|
||||
switch (program[switchState][0]) {
|
||||
case WAIT4REMOVAL: {
|
||||
Dimension d = trigger.GetXY();
|
||||
int bigXL = d.width / 28;
|
||||
int bigXR = (d.width + trigger.getWidth()) / 28;
|
||||
int bigYT = d.height / 32;
|
||||
int bigYB = (d.height + trigger.getHeight()) / 32;
|
||||
boolean removed = true;
|
||||
for (int Y = bigYT; Y < bigYB; Y++) {
|
||||
for (int X = bigXL; X < bigXR; X++) {
|
||||
if (trigger.room.MaterialArray[Y][X] == this) {
|
||||
removed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removed) {
|
||||
switchState++;
|
||||
}
|
||||
currentRoom = room;
|
||||
}
|
||||
break;
|
||||
case WAIT4TIME:
|
||||
if (timing) {
|
||||
Date now = new Date();
|
||||
if (now.getTime() >= timeout.getTime()) {
|
||||
switchState++;
|
||||
timing = false;
|
||||
currentRoom = room;
|
||||
}
|
||||
}
|
||||
else {
|
||||
timeout = new Date(new Date().getTime() + 1000 * program[switchState][1]);
|
||||
timing = true;
|
||||
}
|
||||
break;
|
||||
case SETVALUEHIGH:
|
||||
value = true;
|
||||
switchState++;
|
||||
break;
|
||||
case SETVALUELOW:
|
||||
value = false;
|
||||
switchState++;
|
||||
break;
|
||||
case REPLACE:
|
||||
if (currentRoom == null) {
|
||||
currentRoom = trigger.room;
|
||||
}
|
||||
for (int a = 0; a < (program[switchState].length - 1) / 3; a++) {
|
||||
currentRoom.SetMaterial(program[switchState][a * 3 + 1],
|
||||
program[switchState][a * 3 + 2],
|
||||
program[switchState][a * 3 + 3]);
|
||||
}
|
||||
switchState++;
|
||||
break;
|
||||
case LEFTROOM:
|
||||
currentRoom = currentRoom.leftRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case RIGHTROOM:
|
||||
currentRoom = currentRoom.rightRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case UPROOM:
|
||||
currentRoom = currentRoom.upRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case DOWNROOM:
|
||||
currentRoom = currentRoom.downRoom;
|
||||
switchState++;
|
||||
break;
|
||||
case RESETROOM:
|
||||
currentRoom = room;
|
||||
switchState++;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -3,32 +3,30 @@ package com.droidquest.materials;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Train;
|
||||
|
||||
public class Switch1 extends Switch
|
||||
{
|
||||
transient Train train;
|
||||
public class Switch1 extends Switch {
|
||||
private transient Train train;
|
||||
|
||||
public Switch1()
|
||||
{
|
||||
super(Switch.ROT_UP);
|
||||
}
|
||||
public Switch1() {
|
||||
super(Switch.ROT_UP);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
if (train==null)
|
||||
for (int a=0; a<level.items.size(); a++)
|
||||
{
|
||||
Item t = (Item) level.items.elementAt(a);
|
||||
if (t.getClass().toString().endsWith("Train"))
|
||||
train = (Train) t;
|
||||
}
|
||||
if (train==null)
|
||||
return;
|
||||
if (train.room==null)
|
||||
{
|
||||
train.x = 108;
|
||||
train.y = 250;
|
||||
train.room = item.room;
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
if (train == null) {
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
Item t = level.items.elementAt(a);
|
||||
if (t.getClass().toString().endsWith("Train")) {
|
||||
train = (Train) t;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (train == null) {
|
||||
return;
|
||||
}
|
||||
if (train.room == null) {
|
||||
train.x = 108;
|
||||
train.y = 250;
|
||||
train.room = item.room;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -2,23 +2,20 @@ package com.droidquest.materials;
|
||||
|
||||
import com.droidquest.items.Item;
|
||||
|
||||
public class SwitchA extends Switch
|
||||
{
|
||||
// Classes SwitchA & SwitchB are used in the double switch puzzle in
|
||||
// Level 3. SwitchA simply reacts to being touched and turns its value
|
||||
// to true. SwitchB does the same, but also looks for the existence of
|
||||
// SwitchA and polls its value. When both are true, SwitchB removes the
|
||||
// Sentry and changes the textbox to say "KLAATA BARADA NIKTU", or
|
||||
// something like that.
|
||||
public class SwitchA extends Switch {
|
||||
// Classes SwitchA & SwitchB are used in the double switch puzzle in
|
||||
// Level 3. SwitchA simply reacts to being touched and turns its value
|
||||
// to true. SwitchB does the same, but also looks for the existence of
|
||||
// SwitchA and polls its value. When both are true, SwitchB removes the
|
||||
// Sentry and changes the textbox to say "KLAATA BARADA NIKTU", or
|
||||
// something like that.
|
||||
|
||||
public SwitchA()
|
||||
{
|
||||
super(Switch.ROT_LEFT);
|
||||
}
|
||||
public SwitchA() {
|
||||
super(Switch.ROT_LEFT);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
value=true;
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
value = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -4,52 +4,49 @@ import com.droidquest.decorations.TextBox;
|
||||
import com.droidquest.items.Item;
|
||||
import com.droidquest.items.Sentry;
|
||||
|
||||
public class SwitchB extends Switch
|
||||
{
|
||||
transient SwitchA switchA=null;
|
||||
boolean flipped=false;
|
||||
transient Sentry sentry=null;
|
||||
public class SwitchB extends Switch {
|
||||
private transient SwitchA switchA = null;
|
||||
private boolean flipped = false;
|
||||
private transient Sentry sentry = null;
|
||||
|
||||
public SwitchB()
|
||||
{
|
||||
super(Switch.ROT_LEFT);
|
||||
}
|
||||
public SwitchB() {
|
||||
super(Switch.ROT_LEFT);
|
||||
}
|
||||
|
||||
public void TouchedByItem(Item item)
|
||||
{
|
||||
value=true;
|
||||
for (int a=0; a<level.materials.size(); a++)
|
||||
{
|
||||
Material mat = (Material) level.materials.elementAt(a);
|
||||
if (mat.getClass().toString().endsWith("SwitchA"))
|
||||
switchA = (SwitchA) mat;
|
||||
}
|
||||
for (int a=0; a<level.items.size(); a++)
|
||||
{
|
||||
Item item2 = (Item) level.items.elementAt(a);
|
||||
if (item2.room==item.room)
|
||||
if (item2.getClass().toString().endsWith("Sentry"))
|
||||
sentry = (Sentry) item2;
|
||||
}
|
||||
}
|
||||
public void TouchedByItem(Item item) {
|
||||
value = true;
|
||||
for (int a = 0; a < level.materials.size(); a++) {
|
||||
Material mat = level.materials.elementAt(a);
|
||||
if (mat.getClass().toString().endsWith("SwitchA")) {
|
||||
switchA = (SwitchA) mat;
|
||||
}
|
||||
}
|
||||
for (int a = 0; a < level.items.size(); a++) {
|
||||
Item item2 = level.items.elementAt(a);
|
||||
if (item2.room == item.room) {
|
||||
if (item2.getClass().toString().endsWith("Sentry")) {
|
||||
sentry = (Sentry) item2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
super.Animate();
|
||||
if (!flipped)
|
||||
if (value)
|
||||
{
|
||||
if (switchA!=null)
|
||||
if (switchA.value)
|
||||
{
|
||||
flipped=true;
|
||||
TextBox textbox = (TextBox) sentry.room.textBoxes.elementAt(0);
|
||||
textbox.textString="KLAATA BARADA NIKTO!";
|
||||
textbox.y=6*32;
|
||||
textbox.width = 400;
|
||||
level.items.removeElement(sentry);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Animate() {
|
||||
super.Animate();
|
||||
if (!flipped) {
|
||||
if (value) {
|
||||
if (switchA != null) {
|
||||
if (switchA.value) {
|
||||
flipped = true;
|
||||
TextBox textbox = sentry.room.textBoxes.elementAt(0);
|
||||
textbox.textString = "KLAATA BARADA NIKTO!";
|
||||
textbox.y = 6 * 32;
|
||||
textbox.width = 400;
|
||||
level.items.removeElement(sentry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -6,33 +6,28 @@ import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class VendingSlot extends Material
|
||||
{
|
||||
public VendingSlot()
|
||||
{
|
||||
super(false, true);
|
||||
GenerateIcons();
|
||||
}
|
||||
public class VendingSlot extends Material {
|
||||
public VendingSlot() {
|
||||
super(false, true);
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(new Color(0,0,128));
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0,24,28,4);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(new Color(0, 0, 128));
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 24, 28, 4);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,68 +8,61 @@ import javax.swing.ImageIcon;
|
||||
|
||||
import com.droidquest.Room;
|
||||
|
||||
public class XitSlot extends Material
|
||||
{
|
||||
public int doorState=0;
|
||||
public class XitSlot extends Material {
|
||||
public int doorState = 0;
|
||||
|
||||
public Room room=null;
|
||||
public Room room = null;
|
||||
|
||||
public XitSlot()
|
||||
{
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
public XitSlot() {
|
||||
super(true, false);
|
||||
GenerateIcons();
|
||||
}
|
||||
|
||||
public void GenerateIcons()
|
||||
{
|
||||
BufferedImage bi = new BufferedImage(28,32,BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try
|
||||
{
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0,0,28,32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12,4,4,24);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
public void GenerateIcons() {
|
||||
BufferedImage bi = new BufferedImage(28, 32, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
Graphics g;
|
||||
try {
|
||||
g = bi.getGraphics();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
|
||||
return;
|
||||
}
|
||||
|
||||
public void Animate()
|
||||
{
|
||||
switch (doorState)
|
||||
{
|
||||
case 1:
|
||||
room.SetMaterial(11,8,0);
|
||||
room.SetMaterial(14,5,0);
|
||||
room.SetMaterial(17,2,0);
|
||||
room.SetMaterial(12,7,2);
|
||||
room.SetMaterial(15,4,2);
|
||||
doorState=2;
|
||||
break;
|
||||
case 2:
|
||||
room.SetMaterial(12,7,0);
|
||||
room.SetMaterial(15,4,0);
|
||||
room.SetMaterial(13,6,2);
|
||||
room.SetMaterial(16,3,2);
|
||||
doorState=3;
|
||||
break;
|
||||
case 3:
|
||||
room.SetMaterial(13,6,0);
|
||||
room.SetMaterial(16,3,0);
|
||||
room.SetMaterial(11,8,2);
|
||||
room.SetMaterial(14,5,2);
|
||||
room.SetMaterial(17,2,2);
|
||||
doorState=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
g.setColor(Color.blue);
|
||||
g.fillRect(0, 0, 28, 32);
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(12, 4, 4, 24);
|
||||
icon = new ImageIcon(bi);
|
||||
}
|
||||
|
||||
public void Animate() {
|
||||
switch (doorState) {
|
||||
case 1:
|
||||
room.SetMaterial(11, 8, 0);
|
||||
room.SetMaterial(14, 5, 0);
|
||||
room.SetMaterial(17, 2, 0);
|
||||
room.SetMaterial(12, 7, 2);
|
||||
room.SetMaterial(15, 4, 2);
|
||||
doorState = 2;
|
||||
break;
|
||||
case 2:
|
||||
room.SetMaterial(12, 7, 0);
|
||||
room.SetMaterial(15, 4, 0);
|
||||
room.SetMaterial(13, 6, 2);
|
||||
room.SetMaterial(16, 3, 2);
|
||||
doorState = 3;
|
||||
break;
|
||||
case 3:
|
||||
room.SetMaterial(13, 6, 0);
|
||||
room.SetMaterial(16, 3, 0);
|
||||
room.SetMaterial(11, 8, 2);
|
||||
room.SetMaterial(14, 5, 2);
|
||||
room.SetMaterial(17, 2, 2);
|
||||
doorState = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user