Пример #1
0
        public void FOVCurrentHash()
        {
            var map = new BoxResMap(50, 50);
            var fov = new FOV(map);

            fov.Calculate(20, 20, 10);

            // Inefficient copy but fine for testing
            HashSet <Coord> currentFov = new HashSet <Coord>(fov.CurrentFOV);

            for (int x = 0; x < map.Width; x++)
            {
                for (int y = 0; y < map.Height; y++)
                {
                    if (fov[x, y] > 0.0)
                    {
                        Assert.AreEqual(true, currentFov.Contains(Coord.Get(x, y)));
                    }
                    else
                    {
                        Assert.AreEqual(false, currentFov.Contains(Coord.Get(x, y)));
                    }
                }
            }
        }
Пример #2
0
        public void RippleCircleValue()
        {
            int    MAP_SIZE   = 30;
            int    RADIUS     = 10;
            Radius RAD_TYPE   = Radius.CIRCLE;
            Coord  SOURCE_POS = Coord.Get(15, 15);

            BoxResMap resMap   = new BoxResMap(MAP_SIZE, MAP_SIZE);
            SenseMap  senseMap = new SenseMap(resMap);

            var source = new SenseSource(SourceType.RIPPLE, SOURCE_POS, RADIUS, RAD_TYPE);

            senseMap.AddSenseSource(source);

            senseMap.Calculate();

            Console.WriteLine("Map on 10x10, light source at (2, 3), 3 circle radius, using ripple is: ");
            for (int x = 0; x < MAP_SIZE; x++)
            {
                for (int y = 0; y < MAP_SIZE; y++)
                {
                    Console.Write($"{senseMap[x, y].ToString("N4")} ");
                }
                Console.WriteLine();
            }
        }
Пример #3
0
        public void SenseMapCurrentHash()
        {
            var map      = new BoxResMap(50, 50);
            var senseMap = new SenseMap(map);

            senseMap.AddSenseSource(new SenseSource(SourceType.RIPPLE, Coord.Get(20, 20), 10, Radius.CIRCLE));

            senseMap.Calculate();

            // Inefficient copy but fine for testing
            HashSet <Coord> currentSenseMap = new HashSet <Coord>(senseMap.CurrentSenseMap);

            for (int x = 0; x < map.Width; x++)
            {
                for (int y = 0; y < map.Height; y++)
                {
                    if (senseMap[x, y] > 0.0)
                    {
                        Assert.AreEqual(true, currentSenseMap.Contains(Coord.Get(x, y)));
                    }
                    else
                    {
                        Assert.AreEqual(false, currentSenseMap.Contains(Coord.Get(x, y)));
                    }
                }
            }
        }
Пример #4
0
        public void FOVNewlySeenUnseen()
        {
            var map = new BoxResMap(50, 50);
            var fov = new FOV(map);

            fov.Calculate(20, 20, 10, Radius.SQUARE);
            var prevFov = new HashSet <Coord>(fov.CurrentFOV);

            fov.Calculate(19, 19, 10, Radius.SQUARE);
            var curFov      = new HashSet <Coord>(fov.CurrentFOV);
            var newlySeen   = new HashSet <Coord>(fov.NewlySeen);
            var newlyUnseen = new HashSet <Coord>(fov.NewlyUnseen);

            foreach (var pos in prevFov)
            {
                if (!curFov.Contains(pos))
                {
                    Assert.AreEqual(true, newlyUnseen.Contains(pos));
                }
                else
                {
                    Assert.AreEqual(false, newlyUnseen.Contains(pos));
                }
            }

            foreach (var pos in curFov)
            {
                if (!prevFov.Contains(pos))
                {
                    Assert.AreEqual(true, newlySeen.Contains(pos));
                }
                else
                {
                    Assert.AreEqual(false, newlySeen.Contains(pos));
                }
            }
        }