Mercurial > hg > Database > Alice
view src/alice/test/topology/aquarium/SetLocation.java @ 140:b51d3bf971e7 working
add function (refresh)
author | sugi |
---|---|
date | Thu, 20 Sep 2012 01:32:46 +0900 |
parents | 87f1a30a8c82 |
children | 0651fb36a369 |
line wrap: on
line source
package alice.test.topology.aquarium; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class SetLocation extends CodeSegment{ private Receiver position = ids.create(CommandType.PEEK); private MakeObject obj; private String key; int range; public SetLocation(MakeObject obj ,String key,int index,int range){ this.obj = obj; this.key = key; this.range = range; this.position.setKey("local",key,index); } @Override public void run(){ FishPoint fp = this.position.asClass(FishPoint.class); //obj.setLocation(fp.getX() - 2*range, fp.getY()); float startX = 2*range - 1.5f; float endX = 2*range + 1.5f; if (startX <= fp.getX() && fp.getX() < endX) obj.setLocation(fp.getX() - 2*range, fp.getY()); new SetLocation(this.obj, this.key, this.position.index, this.range); } }