134
|
1 package alice.test.topology.aquarium;
|
92
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
|
6
|
|
7
|
|
8 public class SendLocation extends CodeSegment {
|
|
9
|
97
|
10 public Receiver position = ids.create(CommandType.PEEK);
|
|
11 float x;
|
|
12 float y;
|
119
|
13 float max = 3.3f;
|
|
14 float min = -1.3f;
|
92
|
15
|
97
|
16 public SendLocation(float x,float y){
|
|
17 this.x = x;
|
|
18 this.y = y;
|
92
|
19 }
|
|
20
|
|
21 @Override
|
|
22 public void run() {
|
127
|
23 FishPoint fp = this.position.asClass(FishPoint.class);
|
115
|
24
|
127
|
25 fp.setXY(fp.getX()+this.x, fp.getY()+this.y);
|
119
|
26 /*
|
127
|
27 if (fp.getX()+this.x>max){
|
132
|
28 fp.setXY(-1.0f, fp.getY()+this.y);
|
127
|
29 } else if (fp.getX()+this.x< min){
|
|
30 fp.setXY(max, fp.getY()+this.y);
|
115
|
31 }
|
|
32 else {
|
127
|
33 fp.setXY(fp.getX()+this.x, fp.getY()+this.y);
|
115
|
34 }
|
119
|
35 */
|
115
|
36
|
127
|
37 ods.update("local", "fish", fp);
|
92
|
38
|
|
39 }
|
|
40
|
|
41 }
|