1 package erland.game.tileadventure;
2
3 import erland.util.ParameterSerializable;
4 import erland.util.ParameterValueStorageExInterface;
5 import erland.util.StringUtil;
6
7 import java.util.StringTokenizer;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class AnimationExtendedLevelInfo implements ParameterSerializable {
29 private int speed = 1;
30 private int[] images;
31
32 public void write(ParameterValueStorageExInterface out) {
33 out.setParameter("speed",""+speed);
34 StringBuffer sb = new StringBuffer();
35 for (int i = 0; i < images.length; i++) {
36 sb.append(images[i]);
37 if(i<images.length-1) {
38 sb.append(' ');
39 }
40 }
41 out.setParameter("images",sb.toString());
42 }
43
44 public void read(ParameterValueStorageExInterface in) {
45 speed = StringUtil.asInteger(in.getParameter("speed"),new Integer(1)).intValue();
46 StringTokenizer tokens = new StringTokenizer(StringUtil.asEmpty(in.getParameter("images")));
47 images = new int[tokens.countTokens()];
48 int i=0;
49 while (tokens.hasMoreTokens()) {
50 String s = (String) tokens.nextToken();
51 images[i++] = StringUtil.asInteger(s,new Integer(0)).intValue();
52 }
53 }
54
55 public int getSpeed() {
56 return speed;
57 }
58
59 public void setSpeed(int speed) {
60 this.speed = speed;
61 }
62
63 public int[] getImages() {
64 return images;
65 }
66
67 public void setImages(int[] images) {
68 this.images = images;
69 }
70 }