2014-02-02 18:39:08 -03:00
|
|
|
package com.droidquest.materials;
|
|
|
|
|
|
|
|
import com.droidquest.items.Item;
|
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.image.BufferedImage;
|
2014-02-02 18:39:08 -03:00
|
|
|
|
2014-04-09 00:04:44 -03:00
|
|
|
public class Portal extends Material {
|
|
|
|
public String levelName;
|
|
|
|
public boolean bringStuff;
|
|
|
|
public boolean initLevel;
|
|
|
|
|
|
|
|
public Portal(String ln, boolean bs, boolean il) {
|
|
|
|
super("", true, false);
|
|
|
|
levelName = ln;
|
|
|
|
bringStuff = bs;
|
|
|
|
initLevel = il;
|
|
|
|
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.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;
|
|
|
|
}
|
2014-02-02 18:39:08 -03:00
|
|
|
|
|
|
|
|
|
|
|
}
|