Пример #1
0
        /// <summary>
        /// Draws a decoration
        /// </summary>
        /// <param name="batch">Spritebatch handle</param>
        /// <param name="id">Decoration id</param>
        /// <param name="position">View position</param>
        public void Draw(SpriteBatch batch, int id, ViewFieldPosition position)
        {
            if (batch == null || id == -1)
            {
                return;
            }

            Decoration deco = GetDecoration(id);

            if (deco == null)
            {
                return;
            }

            batch.DrawTile(Tileset, deco.GetTileId(position), deco.GetLocation(position),
                           Color.White, 0.0f,
                           deco.GetSwap(position) ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
                           0.0f);
        }
Пример #2
0
        /// <summary>
        /// Checks if a point is inside the decoration
        /// </summary>
        /// <param name="id">Decoration id</param>
        /// <param name="location">Location to check</param>
        /// <returns>True if point is inside the alcove</returns>
        public bool IsPointInside(int id, Point location)
        {
            Decoration deco = GetDecoration(id);

            if (deco == null)
            {
                return(false);
            }

            Tile tile = Tileset.GetTile(deco.GetTileId(ViewFieldPosition.L));

            if (tile == null)
            {
                return(false);
            }

            Rectangle zone = new Rectangle(
                deco.GetLocation(ViewFieldPosition.L),
                tile.Size);

            return(zone.Contains(location));
        }