1 import java.awt.*;
2 import javax.swing.*;
3 import java.applet.*;
4 import java.awt.image.*;
5 import java.awt.geom.*;
6 import java.net.*;
7
16 public class Redirect extends MapObject
17 {
18
21 protected static Image img;
22
25 protected int numBadgesReq;
26
29 String mapTo;
30
36 static MapObject behind;
37
41 public Redirect()
42 {
43 enterable = false;
44 type = MapObject.REDIRECT;
45 mapTo = "Saphire";
46 numBadgesReq = 0;
47 }
48
54 public Redirect(String mapTo)
55 {
56 enterable = false;
57 type = MapObject.REDIRECT;
58 if(mapTo != null)
59 this.mapTo = mapTo;
60 else
61 this.mapTo = "Saphire";
62 numBadgesReq = 0;
63 }
64
69 public void setImage(Image[] img)
70 {
71 if(img.length == 1)
72 this.img = img[0];
73 }
74
79 public void setMapTo(String mapTo)
80 {
81 if(mapTo != null)
82 this.mapTo = mapTo;
83 }
84
89 public String getMapTo() { return mapTo; }
90
91
96 public void setNumberBadgesRequired(int numBadges)
97 {
98 if(numBadges >= 0)
99 numBadgesReq = numBadges;
100 }
101
106 public int getNumberBadgesRequired() { return numBadgesReq; }
107
112 public MapObject getClone() { return new Redirect(mapTo); }
113
118 public void setBehind(MapObject m)
119 {
120 if(m == null)
121 return;
122 else if(m.canBeEntered())
123 {
124 this.behind = m;
125 }
126 }
127
132 public void paint(Graphics g)
133 {
134 behind.paint(g);
135 g.drawImage(img, 0, 0, this);
136 }
137 }