Exemplo n.º 1
0
        /// <summary> Calculates if the given specific tile at the <paramref name="x"/> and <paramref name="y"/> position is valid for this object's placement. Note that this does not necessarily mean that the entire object can be placed. </summary>
        /// <param name="objectMap"> The tilemap. </param>
        /// <param name="x"> The x axis of the position. </param>
        /// <param name="y"> The y axis of the position. </param>
        /// <returns> True if the tile is valid, otherwise; false. </returns>
        public bool TileIsValid(BaseTilemap <ObjectTileData> objectMap, int x, int y)
        {
            // If this tile has an object already, return false.
            if (!objectMap.IsTileEmpty(x, y))
            {
                return(false);
            }

            // If the floor is not valid, return false.
            if (!FloorIsValid(objectMap.WorldMap.GetTilemap <FloorTileData>(), x, y))
            {
                return(false);
            }

            // If the other checks have passed, return true.
            return(true);
        }
Exemplo n.º 2
0
        /// <summary> Calculates if the given tile position has no objects and a valid floor. </summary>
        /// <param name="tilemap"> The tilemap. </param>
        /// <param name="x"> The x axis of the position. </param>
        /// <param name="y"> The y axis of the position. </param>
        /// <returns> True if this tile can be placed, otherwise; false. </returns>
        public override bool CanPlace(BaseTilemap <CropTileData> tilemap, int x, int y)
        {
            // If this tile has a crop on it already, return false.
            if (!tilemap.IsTileEmpty(x, y))
            {
                return(false);
            }

            // If the floor is not valid, return false.
            if (!string.IsNullOrWhiteSpace(requiredFloor) && !tilemap.WorldMap.GetTilemap <FloorTileData>().IsTile(x, y, requiredFloor))
            {
                return(false);
            }

            // If this tile has an object, return false.
            if (!tilemap.WorldMap.GetTilemap <ObjectTileData>().IsTileEmpty(x, y))
            {
                return(false);
            }

            // If the other checks have passed, return true.
            return(true);
        }