예제 #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);
        }
예제 #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);
        }
예제 #3
0
        public void PackTwoInts()
        {
            int  aResult, bResult;
            int  a          = short.MaxValue + 4126;
            int  b          = short.MinValue - 9999;
            long packedLong = BitCruncher.PackTwoInts(a, b);

            BitCruncher.UnpackTwoInts(packedLong, out aResult, out bResult);
            Assert.AreEqual(a, aResult);
            Assert.AreEqual(b, bResult);
        }
예제 #4
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);
        }
예제 #5
0
        public void PackFour()
        {
            int  a = 10, b = -12, c = 24, d = 99;
            int  ar, br, cr, dr;
            long packed = BitCruncher.PackFourShorts(a, b, c, d);

            BitCruncher.UnpackFourShorts(packed, out ar, out br, out cr, out dr);
            Assert.AreEqual(a, ar);
            Assert.AreEqual(b, br);
            Assert.AreEqual(c, cr);
            Assert.AreEqual(d, dr);
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
 public override long GetUniqueID()
 {
     return(BitCruncher.PackTwoInts(position.roomName.GetHashCode(), position.localPosition.GetHashCode()));
 }
예제 #10
0
 public virtual long GetUniqueID()
 {
     return(BitCruncher.PackTwoInts(localPosition.x, localPosition.y));
 }
예제 #11
0
 public virtual long GetUniqueID()
 {
     return(BitCruncher.PackTwoInts(_localPoint.x, _localPoint.y));
 }