1 import java.awt.*;
2 import java.applet.*;
3 import javax.swing.*;
4 import java.awt.image.*;
5 import java.awt.geom.*;
6 import java.net.*;
7 import java.util.*;
8
14 public class Person extends People
15 {
16
19 protected static Image img, bimg, limg, rimg;
26 protected PersonAI ai;
27
41 public Person()
42 {
43 enterable = false;
44 type = MapObject.PERSON;
45 activeMon = 0;
46 money = 0;
47 behind = new Grass();
48 name = "NPC";
49 ai = new PersonAI(this);
50 mon = new Vector();
51 hmon = new Vector();
52 items = new Vector();
53 activeMon = 0;
54 dlg = "";
55 }
56
72 public Person(int dir)
73 {
74 if(!setDirection(dir))
75 this.dir = Grid.DOWN;
76 enterable = false;
77 type = MapObject.PERSON;
78 activeMon = 0;
79 money = 0;
80 behind = new Grass();
81 name = "NPC";
82 ai = new PersonAI(this);
83 mon = new Vector();
84 hmon = new Vector();
85 items = new Vector();
86 activeMon = 0;
87 dlg = "";
88 }
89
104 public Person(MapObject behind)
105 {
106 if(behind.canBeEntered())
107 this.behind = behind;
108 else
109 this.behind = new Grass();
110 enterable = false;
111 type = MapObject.PERSON;
112 activeMon = 0;
113 money = 0;
114 name = "NPC";
115 ai = new PersonAI(this);
116 mon = new Vector();
117 hmon = new Vector();
118 items = new Vector();
119 }
120
136 public Person(MapObject behind, int dir)
137 {
138 if(!setDirection(dir))
139 this.dir = Grid.DOWN;
140 if(behind.canBeEntered())
141 this.behind = behind;
142 else
143 this.behind = new Grass();
144 enterable = false;
145 type = MapObject.PERSON;
146 activeMon = 0;
147 money = 0;
148 name = "NPC";
149 ai = new PersonAI(this);
150 mon = new Vector();
151 hmon = new Vector();
152 items = new Vector();
153 }
154
170 public Person(String name)
171 {
172 this.dir = Grid.DOWN;
173 this.behind = new Grass();
174 enterable = false;
175 type = MapObject.PERSON;
176 activeMon = 0;
177 money = 0;
178 this.name = name;
179 ai = new PersonAI(this);
180 mon = new Vector();
181 hmon = new Vector();
182 items = new Vector();
183 }
184
202 public Person(String name, MapObject behind, int dir)
203 {
204 if(!setDirection(dir))
205 this.dir = Grid.DOWN;
206 if(behind.canBeEntered())
207 this.behind = behind;
208 else
209 this.behind = new Grass();
210 enterable = false;
211 type = MapObject.PERSON;
212 activeMon = 0;
213 money = 0;
214 this.name = "name";
215 ai = new PersonAI(this);
216 mon = new Vector();
217 hmon = new Vector();
218 items = new Vector();
219 }
220
221
227 public void setImage(Image[] img)
228 {
229 if(img.length == 4)
230 {
231 this.img = img[0];
232 this.bimg = img[1];
233 this.limg = img[2];
234 this.rimg = img[3];
235 }
236 }
237
244 public void setGrid(Grid g)
245 {
246 ai.setGrid(g);
247 }
248
253 public MapObject getClone() { return new Person(name, behind, dir); }
254
259 public void paint(Graphics g)
260 {
261 behind.paint(g);
262
263 int wi, he;
264 switch(dir)
265 {
266 case Grid.LEFT:
267 {
268 g.drawImage(limg, 0, 0, this);
269 break;
270 }
271 case Grid.RIGHT:
272 {
273 g.drawImage(rimg, 0, 0, this);
274 break;
275 }
276 case Grid.UP:
277 {
278 g.drawImage(bimg, 0, 0, this);
279 break;
280 }
281 default:
282 {
283 g.drawImage(img, 0, 0, this);
284 break;
285 }
286 }
287 }
288 }