Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }