Mercurial > hg > Database > Alice
view src/alice/test/topology/movement/CheckFishLocation.java @ 94:38f4021353c5 working
"setKey" is in the instance
author | sugi |
---|---|
date | Mon, 18 Jun 2012 17:10:23 +0900 |
parents | 6601f8854126 |
children | df786bf8f036 |
line wrap: on
line source
package alice.test.topology.movement; import java.util.regex.Matcher; import java.util.regex.Pattern; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; public class CheckFishLocation extends CodeSegment{ private Receiver nowX = ids.create(CommandType.PEEK); private Receiver host = ids.create(CommandType.PEEK); MakeObject obj; Pattern pattern = Pattern.compile("^(cli)([0-9]+)$"); public CheckFishLocation(MakeObject MO ,String str){ this.obj = MO; this.nowX.key = str; this.host.setKey("local","host"); this.nowX.setKey("parent",this.nowX.key,this.nowX.index); } @Override public void run(){ String name = host.asString(); Matcher matcher = pattern.matcher(name); matcher.find(); int num = new Integer(matcher.group(2)); float startX = 2*num - 3.0f; float endX = 2*num -0.9f; float x = (float)this.nowX.asInteger()/1000; System.out.println(this.nowX.key+" :" + x); if (startX <= x && x < endX){ obj.setLocation(x - 2*(num-1), 0); if(this.nowX.key!="fish3X") ods.update("parent", this.nowX.key, this.nowX.asInteger()+1); } new CheckFishLocation(this.obj,this.nowX.key); } }