Mercurial > hg > Database > Alice
view src/alice/test/topology/aquarium/SetLocation.java @ 138:87f1a30a8c82 working
change range automatic
author | sugi |
---|---|
date | Tue, 18 Sep 2012 11:46:38 +0900 |
parents | 53aff28cde6b |
children | b51d3bf971e7 |
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); } }