// Shallow Copy Constructor public LatAddr (LatAddr src) { this.a = src.a; this.b = src.b; this.c = src.c; this.cleanUpLatAddr(); }
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; }
public static void CreateGrid (int[] tiles, int arrayWidth) { for (int i = 0; i < tiles.Length; i++) { LatAddr lAddr = new LatAddr ((i % arrayWidth), ((int)i / arrayWidth), 0); CanAddr cAddr = CanAddr.convertLatAddrToCanAddr(lAddr); TileTypeController.TileType newTileType = (TileTypeController.TileType)tiles [i]; GridController.getCurInstance ().setState (cAddr, newTileType, Random.Range (0f, (Tile.GROWTH_MAX / 3))); } GridController.CreateVizForCurGrid (); }
public static Vector2 convertLatAddrToVector (LatAddr lAddr) { Vector2 result = new Vector2(); result += BasisVectors.getBasisVector(0) * lAddr.a; result += BasisVectors.getBasisVector(1) * lAddr.b; result += BasisVectors.getBasisVector(2) * lAddr.c; return result; }
public static void applyBMatrixToLatAddr (LatAddr lAddr) { int a = lAddr.A; int b = lAddr.B; int c = lAddr.C; lAddr.A = (2*a)-c; lAddr.B = (2*b)-a; lAddr.C = (2*c)-b; lAddr.cleanUpLatAddr(); }
/* ****************** * STATIC MEMBERS * ******************/ public static LatAddr convertVectorToLatAddr (Vector2 inVec) { LatAddr result = null; float[,] mat = BasisVectors.getBasisVectorMatrix(1f); mat[0,2] = inVec.x; mat[1,2] = inVec.y; LinearEquationSolver.Solve(mat); result = new LatAddr ((int) Mathf.Round (mat[0,2]), (int) Mathf.Round (mat[1,2]), (0)); return result; }
// 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; }
// This method should not be called directly // Instead, change the properties to be the desired values and then call updateState public void igniteTile() { //Debug.Log("IgniteTile " + this.addr.ToString()); // Guard for already burned tiles if (this.isBurned()) { return; } // Set state to include onFire this.state = (byte) (this.state | Tile.FIRE_MASK); LatAddr lAddr = CanAddr.convertCanAddrToLatAddr(this.addr); for (int i = 0; i < NUM_NEIGHBORS; i++) { LatAddr nAddr = new LatAddr(lAddr); nAddr.addLatAddr(Tile.getNeighborLatOffset(i)); this.outRef[i] = SpaceTree.getTile(CanAddr.convertLatAddrToCanAddr(nAddr)); this.outRef[i].notifyReferenceAddition(i); } }
public void addLatAddr(LatAddr op) { this.a += op.a; this.b += op.b; this.c += op.c; this.cleanUpLatAddr(); }