Example #1
0
        /// <summary>
        /// Adds a new decoration
        /// </summary>
        /// <param name="id">Id of the decoration</param>
        /// <returns>Decoration handle</returns>
        public Decoration AddDecoration(int id)
        {
            Decoration deco = new Decoration();

            Decorations[id] = deco;

            return(deco);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="field"></param>
        /// <param name="position"></param>
        /// <param name="direction"></param>
        public override void Draw(SpriteBatch batch, ViewField field, ViewFieldPosition position, CardinalPoint direction)
        {
            if (Decoration == null || IsHidden)
            {
                return;
            }

            TileDrawing td = DisplayCoordinates.GetFloorPlate(position);

            if (td == null)
            {
                return;
            }

            Decoration.Draw(batch, DecorationPrimary, position);
        }
Example #3
0
        /// <summary>
        /// Draws all alcoves according to the view point
        /// </summary>
        /// <param name="batch">Spritebatch handle</param>
        /// <param name="field">Field of view handle</param>
        /// <param name="position">Position in the field of view</param>
        /// <param name="direction">Looking direction</param>
        public override void Draw(SpriteBatch batch, ViewField field, ViewFieldPosition position, CardinalPoint direction)
        {
            if (field.Maze.Decoration == null)
            {
                return;
            }

            // For each wall side, draws the decoration
            foreach (CardinalPoint side in DisplayCoordinates.DrawingWallSides[(int)position])
            {
                Alcove alcove = GetAlcove(Compass.GetDirectionFromView(direction, side));

                // Get the decoration
                Decoration deco = field.Maze.Decoration.GetDecoration(alcove.Decoration);
                if (deco == null)
                {
                    continue;
                }

                // Draw the decoration
                deco.DrawDecoration(batch, field.Maze.Decoration, position, side == CardinalPoint.South);


                // Hide items
                if (alcove.HideItems || side != CardinalPoint.South)
                {
                    continue;
                }



                // Offset the item locations according to the distance
                Vector2 vect = DisplayCoordinates.GetMonsterScaleFactor(position);
                Point   loc  = deco.PrepareLocation(position);
                loc.Offset((int)(deco.ItemLocation.X * vect.X), (int)(deco.ItemLocation.Y * vect.Y));


                // Draw items in the alcove in front of the team
                foreach (Item item in Square.GetItemsFromSide(direction, side))
                {
                    batch.DrawTile(Square.Maze.Dungeon.ItemTileSet, item.GroundTileID, loc,
                                   DisplayCoordinates.GetDistantColor(position), 0.0f,
                                   DisplayCoordinates.GetItemScaleFactor(position), SpriteEffects.None, 0.0f);
                }
            }
        }
Example #4
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);
        }
Example #5
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));
        }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="writer"></param>
        /// <returns></returns>
        public bool Save(XmlWriter writer)
        {
            if (writer == null)
            {
                return(false);
            }

            writer.WriteAttributeString("deco", Decoration.ToString());
            writer.WriteAttributeString("hide", HideItems.ToString());
            writer.WriteAttributeString("bigitems", AcceptBigItems.ToString());
            //writer.WriteAttributeString("x", ItemLocation.X.ToString());
            //writer.WriteAttributeString("y", ItemLocation.Y.ToString());


            if (OnAddedItem.Count > 0)
            {
                writer.WriteStartElement("onaddeditem");
                foreach (AlcoveScript action in OnAddedItem)
                {
                    action.Save(writer);
                }

                writer.WriteEndElement();
            }


            if (OnRemovedItem.Count > 0)
            {
                writer.WriteStartElement("onremoveditem");
                foreach (AlcoveScript action in OnRemovedItem)
                {
                    action.Save(writer);
                }

                writer.WriteEndElement();
            }

            return(true);
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public bool Load(XmlNode xml)
        {
            if (xml == null || xml.Name != XmlTag)
            {
                return(false);
            }

            Name = xml.Attributes["name"].Value;
            BackgroundTileset = xml.Attributes["background"] != null ? xml.Attributes["background"].Value : string.Empty;
            TileSetName       = xml.Attributes["tileset"] != null ? xml.Attributes["tileset"].Value : string.Empty;
            foreach (XmlNode node in xml)
            {
                if (node.NodeType == XmlNodeType.Comment)
                {
                    continue;
                }


                switch (node.Name.ToLower())
                {
                case "decoration":
                {
                    Decoration deco = new Decoration();
                    deco.Load(node);
                    int id = int.Parse(node.Attributes["id"].Value);
                    Decorations[id] = deco;
                }
                break;
                }
            }


            // Load tileset
            LoadTileSet(TileSetName);


            return(true);
        }
Example #8
0
        /// <summary>
        /// A hero interacted with a side of the block
        /// </summary>
        /// <param name="location">Location of the mouse</param>
        /// <param name="side">Wall side</param>
        /// <param name="button">Mouse buttons</param>
        /// <returns>True if the event is processed</returns>
        public bool OnClick(Point location, CardinalPoint side, MouseButtons button)
        {
            // Actor interaction
            if (Actor != null)
            {
                return(Actor.OnClick(location, side, button));
            }


            // Decoration interaction
            Team       team       = GameScreen.Team;
            Decoration decoration = team.Maze.GetDecoration(team.FrontLocation.Coordinate, Compass.GetOppositeDirection(team.Direction));

            if (decoration != null)
            {
                GameMessage.AddMessage("Decoration: OnClick()");

                return(false);
            }



            return(false);
        }
Example #9
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="xml"></param>
		/// <returns></returns>
		public bool Load(XmlNode xml)
		{
			if (xml == null || xml.Name != XmlTag)
				return false;

			Name = xml.Attributes["name"].Value;
			BackgroundTileset = xml.Attributes["background"] != null ? xml.Attributes["background"].Value : string.Empty;
			TileSetName = xml.Attributes["tileset"] != null ? xml.Attributes["tileset"].Value : string.Empty;
			foreach (XmlNode node in xml)
			{
				if (node.NodeType == XmlNodeType.Comment)
					continue;


				switch (node.Name.ToLower())
				{
					case "decoration":
					{
						Decoration deco = new Decoration();
						deco.Load(node);
						int id = int.Parse(node.Attributes["id"].Value);
						Decorations[id] = deco;
					}
					break;
				}
			}


			// Load tileset
			LoadTileSet(TileSetName);


			return true;
		}
Example #10
0
		/// <summary>
		/// Adds a new decoration
		/// </summary>
		/// <param name="id">Id of the decoration</param>
		/// <returns>Decoration handle</returns>
		public Decoration AddDecoration(int id)
		{
			Decoration deco = new Decoration();
			Decorations[id] = deco;

			return deco;
		}