package com.droidquest.devices; import java.awt.Color; import java.awt.Dimension; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import javax.swing.ImageIcon; import com.droidquest.Room; import com.droidquest.chipstuff.Port; import com.droidquest.decorations.Spark; import com.droidquest.items.GenericRobot; public class Thruster extends Device { public int rotation; public Color color; public transient GenericRobot robot; public Thruster(int X, int Y, Room r, int direction, Color col) { x=X; y=Y; room = r; if (room.portalItem!=null) if (room.portalItem.getClass().toString().endsWith("Robot")) robot = (GenericRobot) room.portalItem; rotation = direction; color = col; grabbable = false; GenerateIcons(); } public void writeRef(ObjectOutputStream s) throws IOException { super.writeRef(s); s.writeInt(level.items.indexOf(robot)); } public void readRef(ObjectInputStream s) throws IOException { super.readRef(s); robot = (GenericRobot) level.FindItem(s.readInt()); } public void GenerateIcons() { robot = (GenericRobot) room.portalItem; if (ports==null) { ports = new Port[1]; switch(rotation) { case Port.ROT_UP: // Thrusts Up, moves Down ports[0] = new Port(16,35,Port.TYPE_INPUT,20,Port.ROT_DOWN,this); break; case Port.ROT_RIGHT: // Thrusts Right, moves Left ports[0] = new Port(4,11,Port.TYPE_INPUT,28,Port.ROT_LEFT,this); break; case Port.ROT_DOWN: // Thrusts Down, moves Up ports[0] = new Port(13,2,Port.TYPE_INPUT,12,Port.ROT_UP,this); break; case Port.ROT_LEFT: // Thrusts Left, moves Right ports[0] = new Port(47,8,Port.TYPE_INPUT,26,Port.ROT_RIGHT,this); break; } } else for (int a=0; a