91
|
1 package alice.test.topology.movement;
|
|
2
|
|
3 import java.util.regex.Matcher;
|
|
4 import java.util.regex.Pattern;
|
|
5
|
|
6 import alice.codesegment.CodeSegment;
|
|
7 import alice.datasegment.CommandType;
|
|
8 import alice.datasegment.Receiver;
|
|
9
|
|
10
|
|
11 public class CheckFishLocation extends CodeSegment{
|
|
12
|
97
|
13 private Receiver position = ids.create(CommandType.PEEK);
|
94
|
14 private Receiver host = ids.create(CommandType.PEEK);
|
91
|
15 MakeObject obj;
|
105
|
16 String key;
|
91
|
17 Pattern pattern = Pattern.compile("^(cli)([0-9]+)$");
|
|
18
|
105
|
19 public CheckFishLocation(MakeObject MO ,String key,int index){
|
91
|
20 this.obj = MO;
|
105
|
21 this.key = key;
|
94
|
22 this.host.setKey("local","host");
|
105
|
23 this.position.setKey("local",key,index);
|
91
|
24 }
|
|
25
|
|
26 @Override
|
|
27 public void run(){
|
|
28 String name = host.asString();
|
|
29 Matcher matcher = pattern.matcher(name);
|
|
30 matcher.find();
|
|
31 int num = new Integer(matcher.group(2));
|
|
32
|
|
33 float startX = 2*num - 3.0f;
|
|
34 float endX = 2*num -0.9f;
|
97
|
35 FishPoint FP = this.position.asClass(FishPoint.class);
|
105
|
36 obj.setLocation(FP.getX(), FP.getY());
|
|
37 /*
|
97
|
38 if (startX <= FP.getX() && FP.getX() < endX){
|
|
39 obj.setLocation(FP.getX() - 2*(num-1), FP.getY());
|
105
|
40 if(this.position.key!="fish3X")
|
|
41 ods.update("parent", this.position.key, this.position.asInteger()+1);
|
91
|
42 }
|
105
|
43 */
|
|
44 new CheckFishLocation(this.obj,this.key,this.position.index);
|
94
|
45
|
|
46
|
91
|
47
|
|
48 }
|
|
49
|
|
50
|
|
51 }
|