public void Any_EntitiesAtPosition_ReturnsTrue()
        {
            MapCoordinate testMapCoordinate = GetTestMapCoordinate();

            positionSystem.SetPosition(mover, testMapCoordinate);

            positionSystem.Any(testMapCoordinate).Should().BeTrue();
        }
Esempio 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);
        }
Esempio 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);
        }