public TileNode GetTile(int x, int y) { // Console.WriteLine("x" + x + ", y" + y); TileNode t = null; _tiles.TryGetValue(BitCruncher.PackTwoShorts(x, y), out t); return(t); }
public PointTileNode GetTile(int x, int y) { // Console.WriteLine("x" + x + ", y" + y); PointTileNode t = null; _tilesByLocalPositionHash.TryGetValue(BitCruncher.PackTwoShorts(x, y), out t); return(t); }
public TileType GetTileType(int x, int y) { // Console.WriteLine("x" + x + ", y" + y); TileNode t = null; if (!_tiles.TryGetValue(BitCruncher.PackTwoShorts(x, y), out t)) { return(TileType.NOT_SET); } return(t.type); }
public void PackTwoMixedNumbers() { int a = 1234; int b = -4567; int packed = BitCruncher.PackTwoShorts(a, b); int aResult; int bResult; BitCruncher.UnpackTwoShorts(packed, out aResult, out bResult); Assert.AreEqual(a, aResult); Assert.AreEqual(b, bResult); }
public void PackTwoPositiveNumbers() { int a = 1234; int b = 4567; int packedInt = BitCruncher.PackTwoShorts(a, b); int aResult; int bResult; BitCruncher.UnpackTwoShorts(packedInt, out aResult, out bResult); Assert.AreEqual(a, aResult); Assert.AreEqual(b, bResult); }
public void PackTwoUnderflowAndOverflow() { int a = int.MaxValue; int b = int.MinValue; int packed = 99; Assert.Throws <BitCruncherException>( () => { packed = BitCruncher.PackTwoShorts(a, 0); } ); Assert.Throws <BitCruncherException>( () => { packed = BitCruncher.PackTwoShorts(0, b); } ); Assert.AreEqual(99, packed); }