Exemplo n.º 1
0
        private static bool isStairCandidate(Level level, Location location)
        {
            if (!isChestCandidate(level, location)) return false;

            Entity interactable = level.getWalkable(location);
            return interactable == null;
        }
Exemplo n.º 2
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]));
        }