public static CanAddr convertLatAddrToCanAddr(LatAddr lAddr) { CanAddr result = new CanAddr(); LatAddr tmp = new LatAddr(lAddr); byte curTup = 0x00; int i = 0; while ((tmp.A != tmp.B || tmp.A != tmp.C) && (i < Config.TREE_DEPTH)) { curTup = (byte) ((tmp.A + (2 * tmp.B) + (4 * tmp.C)) % 7); curTup &= TUPLE_MASK; result.setTuple(curTup, i); tmp.A = tmp.A - ((curTup >> 0) & 0x01); tmp.B = tmp.B - ((curTup >> 1) & 0x01); tmp.C = tmp.C - ((curTup >> 2) & 0x01); int a = tmp.A; int b = tmp.B; int c = tmp.C; tmp.A = ((4*a)+b+(2*c))/7; tmp.B = ((2*a)+(4*b)+c)/7; tmp.C = (a+(2*b)+(4*c))/7; i++; } return result; }
/* ****************** * TREEOBJ MEMBERS * ******************/ public override Tile getTile (CanAddr cAddr) { int childIndex = (int) cAddr.getTuple(this.aggLev - 1); if (children[childIndex] == null) { if (this.aggLev == 1) { children[childIndex] = new Tile (this, childIndex); } else { children[childIndex] = new Node(this, childIndex); } } return children[childIndex].getTile(cAddr); }
// Use this for initialization void Start() { Tile t = SpaceTree.getTile(new CanAddr()); t.curTemp = 300; //SpaceTree.setState(new CanAddr(), (byte) 0x02); CanAddr cAddr = new CanAddr(); cAddr.setTuple (3, 3); //SpaceTree.setState(cAddr, 0x04); this.StartCoroutine(SimUpdate(0.1f)); }
public override void updateProperties (CanAddr cAddr) { int childIndex = (int) cAddr.getTuple(this.aggLev - 1); if (this.children [childIndex] != null) { this.children [childIndex].updateProperties (cAddr); } /* for (int i = 0; i < NUM_CHILDREN; i++) { if (children[i] != null) { children[i].updateProperties(cAddr); } } */ }
public override void RegisterController (CanAddr cAddr, TileTypeController tTCont) { int childIndex = (int) cAddr.getTuple(this.aggLev - 1); if (children[childIndex] == null) { if (this.aggLev == 1) { this.children[childIndex] = new Tile (this, childIndex); this.children[childIndex].RegisterController(cAddr, tTCont); } else { this.children[childIndex] = new Node (this, childIndex); this.children[childIndex].RegisterController(cAddr, tTCont); } } else { children[childIndex].RegisterController(cAddr, tTCont); } }
public override void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel) { int childIndex = (int) cAddr.getTuple(this.aggLev - 1); if (children[childIndex] == null) { if (this.aggLev == 1) { this.children[childIndex] = new Tile (this, childIndex); this.children[childIndex].setState(cAddr, tileType, growthLevel); } else { this.children[childIndex] = new Node (this, childIndex); this.children[childIndex].setState(cAddr, tileType, growthLevel); } } else { children[childIndex].setState(cAddr, tileType, growthLevel); } }
public override void setState(CanAddr cAddr, byte state) { int childIndex = (int) cAddr.getTuple(this.aggLev - 1); if (children[childIndex] == null) { if (this.aggLev == 1) { this.childState[childIndex] = state; } else { this.children[childIndex] = new Node (this, childIndex); this.children[childIndex].inheritState (this.childState[childIndex]); this.children[childIndex].setState(cAddr, state); } } else { children[childIndex].setState(cAddr, state); } }
// TODO: ordering check public static LatAddr convertCanAddrToLatAddr (CanAddr cAddr) { LatAddr result = new LatAddr(); LatAddr tmp = new LatAddr(); for (int i = 0; i < Config.TREE_DEPTH; i++) { byte curTup = cAddr.getTuple(i); tmp.A = (curTup >> 0) & 0x01; tmp.B = (curTup >> 1) & 0x01; tmp.C = (curTup >> 2) & 0x01; for (int j = i; j > 0; j--) { BasisVectors.applyBMatrixToLatAddr(tmp); } result.A += tmp.A; result.B += tmp.B; result.C += tmp.C; } result.cleanUpLatAddr(); return result; }
public abstract void updateProperties (CanAddr cAddr);
// Shallow Copy Constructor public CanAddr(CanAddr cAddr) { this.val = cAddr.val; }
public override void RegisterController (CanAddr cAddr, TileTypeController tTCont) { this.tileCont = tTCont; }
public override void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel) { if (tileType == TileTypeController.TileType.TILE_BLANK || tileType == TileTypeController.TileType.TILE_FLOWERS || tileType == TileTypeController.TileType.TILE_WEEDS || tileType == TileTypeController.TileType.TILE_VINE || tileType == TileTypeController.TileType.TILE_TREE) { this.isActiveType = true; } else { this.isActiveType = false; } if (tileType != TileTypeController.TileType.TILE_VINE && this.tileType == TileTypeController.TileType.TILE_VINE) { this.tileType = tileType; this.presentVine.killChildren(); this.presentVine = null; } if (this.tileType != TileTypeController.TileType.TILE_VINE && tileType == TileTypeController.TileType.TILE_VINE) { this.presentVine = new Vine (); this.presentVine.owningTile = this; } this.tileType = tileType; this.growthLevel = growthLevel; this.growthState = Tile.getGrowthStateForLevel (this.growthLevel); this.fillOutRef (); this.UpdateTileViz (this.tileCont); }
public abstract void setState(CanAddr cAddr, byte state);
public static Vector3 GridToWorld (CanAddr addr) { Vector2 tmp = LatAddr.convertLatAddrToVector (CanAddr.convertCanAddrToLatAddr(addr)); Vector3 result = new Vector3 (tmp.y, 0, tmp.x); return (result * Config.WorldToGridScale); }
public override void setState(CanAddr cAddr, byte state) { this.state = state; this.prnt.notifyStateChange(this.addr.getTuple(this.aggLev), this.state); }
public Tile getTile (CanAddr cAddr) { if (rootNode == null) { rootNode = new Node(); } return rootNode.getTile(cAddr); }
public StateChangeEvent (CanAddr cAddr, byte state) { this.tileAddr = cAddr; this.state = state; }
public override void updateProperties (CanAddr cAddr) { if (!this.isActiveType) { return; } this.updateGrowth (); this.AffectNeighbors (); }
public void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel) { if (rootNode == null) { rootNode = new Node(); } rootNode.setState(cAddr, tileType, growthLevel); }
public abstract void setState (CanAddr cAddr, TileTypeController.TileType tileType, float growthLevel);
/* ****************** * TREEOBJ MEMBERS * ******************/ public override Tile getTile(CanAddr cAddr) { return this; }
public abstract void RegisterController (CanAddr cAddr, TileTypeController tTCont);
public abstract Tile getTile(CanAddr cAddr);
public static void setState(CanAddr cAddr, byte state) { if (rootNode == null) { rootNode = new Node(); } rootNode.setState(cAddr, state); }