Ejemplo n.º 1
0
        public void Any_EntitiesAtPosition_ReturnsTrue()
        {
            MapCoordinate testMapCoordinate = GetTestMapCoordinate();

            positionSystem.SetPosition(mover, testMapCoordinate);

            positionSystem.Any(testMapCoordinate).Should().BeTrue();
        }
Ejemplo n.º 2
0
        public static MapCoordinate GetEmptyPosition(this IMap map, IPositionSystem positionSystem, IRandom random)
        {
            var emptyPositions = map.Cells
                                 .Where(c => c.Value.Get <Physical>().Passable&& c.Value.Get <Physical>().Transparent)
                                 .Where(c => !positionSystem.Any(c.Key))
                                 .ToList();

            return(random.PickOne(emptyPositions).Key);
        }
Ejemplo n.º 3
0
        public static MapCoordinate GetQuickEmptyPosition(this IMap map, IPositionSystem positionSystem, IRandom random, int tries = 5)
        {
            for (int i = 0; i < tries; i++)
            {
                var emptyPositions = map.Cells
                                     .ToList();
                var cell = random.PickOne(emptyPositions);

                if (cell.Value.Get <Physical>().Passable&& cell.Value.Get <Physical>().Transparent&& !positionSystem.Any(cell.Key))
                {
                    return(cell.Key);
                }
            }

            return(null);
        }