コード例 #1
0
        public void TestOneDiagonalObject4()
        {
            var expectedMap = @"***." +
                              "****" +
                              "..**" +
                              "..**";

            var map          = CreateMap(4, 4, false, new Point(2, 1));
            var visibleCells = ShadowCasting.For(new Point(3, 0), 4, map).GetVisibleCells().Distinct().ToList();

            AssertMap(4, 4, expectedMap, visibleCells);
        }
コード例 #2
0
        public void TestOneCloseObject2()
        {
            var expectedMap = @"****.****" +
                              "*********" +
                              "***...***" +
                              "**.....**" +
                              "*.......*";

            var map          = CreateMap(9, 5, false, new Point(4, 1));
            var visibleCells = ShadowCasting.For(new Point(4, 0), 4, map).GetVisibleCells().Distinct().ToList();

            AssertMap(9, 5, expectedMap, visibleCells);
        }
コード例 #3
0
        public void TestCornerObjects4()
        {
            var expectedMap = @".*****" +
                              "******" +
                              "******" +
                              "***..*" +
                              "***..." +
                              "****..";

            var map          = CreateMap(6, 6, false, new Point(2, 3), new Point(3, 2), new Point(2, 2));
            var visibleCells = ShadowCasting.For(new Point(0, 0), 7, map).GetVisibleCells().Distinct().ToList();

            AssertMap(6, 6, expectedMap, visibleCells);
        }
コード例 #4
0
        public void TestTwoDiagonalObjects3()
        {
            var expectedMap = @"*****." +
                              "******" +
                              "******" +
                              "*.****" +
                              ".*.***" +
                              "*.****";

            var map          = CreateMap(6, 6, false, new Point(2, 2), new Point(3, 3));
            var visibleCells = ShadowCasting.For(new Point(5, 0), 7, map).GetVisibleCells().Distinct().ToList();

            AssertMap(6, 6, expectedMap, visibleCells);
        }
コード例 #5
0
        public void TestOneDistantObject1()
        {
            var expectedMap = @"**************" +
                              "*.************" +
                              "**************" +
                              "******..******" +
                              "********......" +
                              "**********...." +
                              "***********..." +
                              "*************." +
                              "**************";

            var map          = CreateMap(14, 9, false, new Point(4, 2));
            var visibleCells = ShadowCasting.For(new Point(1, 1), 15, map).GetVisibleCells().Distinct().ToList();

            AssertMap(14, 9, expectedMap, visibleCells);
        }
コード例 #6
0
        public void TestOneCloseObject4()
        {
            var expectedMap = @"*****" +
                              "****." +
                              "***.." +
                              "**..." +
                              ".*..." +
                              "**..." +
                              "***.." +
                              "****." +
                              "*****";

            var map          = CreateMap(5, 9, false, new Point(1, 4));
            var visibleCells = ShadowCasting.For(new Point(0, 4), 4, map).GetVisibleCells().Distinct().ToList();

            AssertMap(5, 9, expectedMap, visibleCells);
        }
コード例 #7
0
        public void TestOneCornerPicker2()
        {
            var expectedMap = @"..........." +
                              "...*****..." +
                              "....***...." +
                              "....*.*...." +
                              "....***...." +
                              "...*****..." +
                              "..*******.." +
                              ".*********.";

            var map = CreateMap(11, 8, false, new Point(4, 3), new Point(6, 3), new Point(0, 1), new Point(1, 1), new Point(2, 1), new Point(3, 1),
                                new Point(4, 1), new Point(5, 1), new Point(6, 1), new Point(7, 1), new Point(8, 1), new Point(9, 1), new Point(10, 1));
            var visibleCells = ShadowCasting.For(new Point(5, 3), 6, map).GetVisibleCells().Distinct().ToList();

            AssertMap(11, 8, expectedMap, visibleCells);
        }
コード例 #8
0
        public void TestOneCornerPicker4()
        {
            var expectedMap = @"........" +
                              ".......*" +
                              "......**" +
                              ".*...***" +
                              ".*******" +
                              ".**.****" +
                              ".*******" +
                              ".*...***" +
                              "......**" +
                              ".......*" +
                              "........";

            var map = CreateMap(8, 11, false, new Point(3, 4), new Point(3, 6), new Point(1, 0), new Point(1, 1), new Point(1, 2), new Point(1, 3),
                                new Point(1, 4), new Point(1, 5), new Point(1, 6), new Point(1, 7), new Point(1, 8), new Point(1, 9), new Point(1, 10));
            var visibleCells = ShadowCasting.For(new Point(3, 5), 6, map).GetVisibleCells().Distinct().ToList();

            AssertMap(8, 11, expectedMap, visibleCells);
        }
コード例 #9
0
ファイル: Dikabryozik.cs プロジェクト: alex-fomin/Game
        public override bool CheckForUnExpected()
        {
            if (_bundle.IsFull || !(State is Resting || State is Wondering))
            {
                return(true);
            }

            var visibleCells = ShadowCasting.For(PositionCell, ViewRadius - 1, Game.Map).GetVisibleCells().OrderBy(p => p.Distance).ToList();

            var eatableCell = visibleCells.FirstOrDefault(p =>
            {
                var obj = Game.Map.GetObjectFromCell(p);
                if ((obj is Berry && obj.Name == Resource.Apple) || obj is Mushroom)
                {
                    return(true);
                }

                return(false);
            });

            if (eatableCell != null)
            {
                _stateQueue.Clear();
                EnqueueMovingToDestinationObject(eatableCell, Game.Map.GetObjectFromCell(eatableCell));
                _stateQueue.Enqueue(new Doing(this, () =>
                {
                    var obj = Game.Map.GetObjectFromCell(eatableCell);
                    if (obj != null)
                    {
                        _bundle.Add(obj);
                    }
                }));

                StateEvent.FireEvent();
                return(false);
            }

            return(true);
        }