Esempio n. 1
0
        public void ShortestPathSearchWithMobileObject()
        {
            GameSetter.SetMapAndFillWithDecors(3, 3, new List <Tuple <Point, IDecor> >());
            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature>
            {
                MobileObjectsManager.GetCreatureByNameAndInitParams(
                    CreatureTypes.Guard, new MobileObjectInitialization(new Point(1, 1), Direction.Down))
            });

            var from      = new Point(1, 0);
            var to        = new Point(1, 2);
            var direction = Direction.Down;

            var answer = new List <Query>
            {
                Query.Move,
                Query.Move
            };
            var result = PathFinder.GetPathFromTo(from, to, direction);

            CheckPath(from, to, direction, answer, result);
        }
Esempio n. 2
0
        public static void CreateLevel(GameState gameState)
        {
            SetMapAndFillWithDecors(26, 14, new List <Tuple <Point, IDecor> >
            {
                Tuple.Create(new Point(8, 0), (IDecor) new Window()),
                Tuple.Create(new Point(17, 0), (IDecor) new Window()),
                Tuple.Create(new Point(15, 13), (IDecor) new Window()),
                Tuple.Create(new Point(20, 13), (IDecor) new Window()),
                Tuple.Create(new Point(12, 0), (IDecor) new Mirror()),
                Tuple.Create(new Point(13, 0), (IDecor) new Mirror()),
                Tuple.Create(new Point(19, 3), (IDecor) new Chair()),
                Tuple.Create(new Point(21, 3), (IDecor) new Chair()),
                Tuple.Create(new Point(18, 3), (IDecor) new Plant()),
                Tuple.Create(new Point(22, 3), (IDecor) new Plant()),
                Tuple.Create(new Point(20, 4), (IDecor) new Table()),
                Tuple.Create(new Point(20, 4), (IDecor) new Jewel()),
                Tuple.Create(new Point(11, 12), (IDecor) new Jewel()),
                Tuple.Create(new Point(4, 0), (IDecor) new PaintingFlowers()),
                Tuple.Create(new Point(21, 0), (IDecor) new PaintingFlowers()),
                Tuple.Create(new Point(5, 7), (IDecor) new ClosedDoor()),
                Tuple.Create(new Point(2, 7), (IDecor) new PaintingHouse()),
                Tuple.Create(new Point(1, 10), (IDecor) new Barrel()),
                Tuple.Create(new Point(1, 11), (IDecor) new Barrel()),
                Tuple.Create(new Point(1, 12), (IDecor) new Barrel()),
                Tuple.Create(new Point(2, 11), (IDecor) new Barrel()),
                Tuple.Create(new Point(2, 12), (IDecor) new Barrel()),
                Tuple.Create(new Point(3, 12), (IDecor) new Barrel()),
                Tuple.Create(new Point(6, 12), (IDecor) new Treasure()),
                Tuple.Create(new Point(7, 12), (IDecor) new Treasure()),
                Tuple.Create(new Point(7, 8), (IDecor) new Barrel()),
                Tuple.Create(new Point(8, 8), (IDecor) new Barrel()),
                Tuple.Create(new Point(8, 9), (IDecor) new Barrel()),
                Tuple.Create(new Point(9, 8), (IDecor) new Barrel()),
                Tuple.Create(new Point(9, 9), (IDecor) new Barrel()),
                Tuple.Create(new Point(9, 10), (IDecor) new Barrel()),
                Tuple.Create(new Point(24, 9), (IDecor) new Plant()),
                Tuple.Create(new Point(24, 10), (IDecor) new Plant()),
                Tuple.Create(new Point(24, 11), (IDecor) new Plant()),
                Tuple.Create(new Point(24, 12), (IDecor) new Plant()),
                Tuple.Create(new Point(23, 11), (IDecor) new Plant()),
                Tuple.Create(new Point(23, 12), (IDecor) new Plant()),
                Tuple.Create(new Point(22, 12), (IDecor) new Plant()),
                Tuple.Create(new Point(21, 12), (IDecor) new Plant()),
            });

            for (var i = 0; i < 26; i++)
            {
                MapManager.Map[i, 0].ObjectContainer.AddDecor(new Wall());
                MapManager.Map[i, 13].ObjectContainer.AddDecor(new Wall());
            }

            for (var j = 0; j < 14; j++)
            {
                MapManager.Map[0, j].ObjectContainer.AddDecor(new Wall());
                MapManager.Map[25, j].ObjectContainer.AddDecor(new Wall());
            }

            for (var i = 1; i < 11; i++)
            {
                if (i != 5)
                {
                    MapManager.Map[i, 7].ObjectContainer.AddDecor(new Wall());
                }
            }

            for (var j = 8; j < 13; j++)
            {
                MapManager.Map[10, j].ObjectContainer.AddDecor(new Wall());
            }

            GameInformationManager.CreateTrackByName(new Dictionary <string, List <Instruction> >
            {
                { "path", new List <Instruction>
                  {
                      new Instruction(new List <string> {
                            "MoveTo", "18", "8"
                        }),
                      new Instruction(new List <string> {
                            "MoveTo", "3", "1"
                        })
                  } }
            });

            MobileObjectsManager.InitializationMobileOjects(new HashSet <ICreature>
            {
                gameState.Player,
                MobileObjectsManager.GetCreatureByNameAndInitParams(CreatureTypes.Guard,
                                                                    new MobileObjectInitialization(new Point(3, 1), 10, 10, Direction.Right, 1, 5, 2, 3,
                                                                                                   new Inventory(new HashSet <IItem>(), 10), new List <Tuple <string, string> > {
                    Tuple.Create("path", "path")
                }))
            });

            MapManager.LevelCost = CountLevelCost();
        }