2014-02-02 18:39:08 -03:00
|
|
|
package com.droidquest.materials;
|
|
|
|
|
|
|
|
import java.awt.Color;
|
|
|
|
import java.awt.Graphics;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
|
|
|
|
import com.droidquest.avatars.GameCursor;
|
|
|
|
import com.droidquest.items.GenericRobot;
|
|
|
|
import com.droidquest.items.Item;
|
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public class ForceField extends Material {
|
|
|
|
private String robotClassName = null;
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public ForceField(String rc, Color c) {
|
|
|
|
super(true, false);
|
|
|
|
robotClassName = rc;
|
|
|
|
color = c;
|
|
|
|
GenerateIcons();
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
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;
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
g.setColor(Color.black);
|
|
|
|
g.fillRect(0, 0, 28, 32);
|
|
|
|
g.setColor(color);
|
|
|
|
g.fillRect(12, 0, 4, 32);
|
|
|
|
icon = new ImageIcon(bi);
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
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;
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
|
|
|
}
|