Exemplo n.º 1
0
        private static bool isDark(Level level, Location location)
        {
            if (level.getTile(location) == null || !level.getTile(location).blocksMovement)
                return false;

            Location[] neighbors =
            {
                location.getAdjLocation(Direction.North),
                location.getAdjLocation(Direction.South),
                location.getAdjLocation(Direction.West),
                location.getAdjLocation(Direction.East),
                location.getAdjLocation(Direction.NorthWest),
                location.getAdjLocation(Direction.SouthWest),
                location.getAdjLocation(Direction.NorthEast),
                location.getAdjLocation(Direction.SouthEast),
            };

            int countBlockedNeighbors = 0;

            for (int i = 0; i < neighbors.Length; i++)
            {
                Tile tile = level.getTile(neighbors[i]);
                if (tile == null || tile.blocksMovement)
                {
                    countBlockedNeighbors++;
                }
            }

            return countBlockedNeighbors == 8;
        }
Exemplo n.º 2
0
        private static bool isDoorCandidate(Level level, Location location)
        {
            if (!level.getTile(location).blocksMovement)
                return false;

            Location[] neighbors =
            {
                location.getAdjLocation(Direction.North),
                location.getAdjLocation(Direction.South),
                location.getAdjLocation(Direction.West),
                location.getAdjLocation(Direction.East)
            };

            for (int i = 0; i < 4; i++)
            {
                Tile tile = level.getTile(neighbors[i]);
                if (tile != null && !tile.blocksMovement)
                    return true;
            }
            return false;
        }
Exemplo n.º 3
0
        private static bool isChestCandidate(Level level, Location location)
        {
            if (level.getTile(location).blocksMovement)
                return false;

            Direction[] directions = {Direction.North, Direction.South, Direction.West, Direction.East};
            bool[] blocked = new bool[4];

            for (int i = 0; i < directions.Length; i++)
            {
                Location adj = location.getAdjLocation(directions[i]);
                if (level.getWalkable(adj) is Door)
                    return false;

                Tile tile = level.getTile(adj);
                if (tile != null && tile.blocksMovement)
                {
                    blocked[i] = true;
                }
            }

            return !((blocked[0] && blocked[1]) || (blocked[2] && blocked[3]));
        }