当前位置: 首页>>代码示例>>C#>>正文


C# SpriteBatch.DrawTile方法代码示例

本文整理汇总了C#中SpriteBatch.DrawTile方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawTile方法的具体用法?C# SpriteBatch.DrawTile怎么用?C# SpriteBatch.DrawTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.DrawTile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

		/// <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 (TileSet == null)
				return;

			// Upstair or downstair ?
			int delta = Type == StairType.Up ? 0 : 13;

			foreach (TileDrawing tmp in DisplayCoordinates.GetStairs(position))
				batch.DrawTile(TileSet, tmp.ID + delta, tmp.Location, Color.White, 0.0f, tmp.Effect, 0.0f);
		
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:19,代码来源:Stair.cs

示例2: Draw

		/// <summary>
		/// Display the window
		/// </summary>
		/// <param name="batch">Spritebatch to use</param>
		public void Draw(SpriteBatch batch)
		{
			if (!IsVisible)
				return;

			Color color;

			// Main window
			batch.DrawTile(Tileset, 23, new Point(MainRectangle.Location.X, MainRectangle.Location.Y - 2));

			// Levels
			for (int level = 1; level <= 6; level++)
			{
				int id = SpellLevel == level ? 24 : 25;
				batch.DrawTile(Tileset, id, new Point(MainRectangle.X + level * 36 - 36, MainRectangle.Top - 20));
				batch.DrawString(GUI.DialogFont, new Point(MainRectangle.X + level * 36 + 12 - 36, MainRectangle.Top - 20 + 4), Color.Black, level.ToString());
			}


			// Get a list of available spells for this level
			List<Spell> spells = Hero.GetSpells(Class, SpellLevel);


			// Display at max 6 spells
			Point pos = new Point(146, 264);
			for (int id = 0; id < Math.Min(spells.Count, 6); id++)
			{
				color = GameColors.White;

				if (new Rectangle(pos.X, pos.Y, 212, 12).Contains(Mouse.Location))
					color = GameColors.Black;

				batch.DrawString(GUI.DialogFont, pos, color, spells[id].Name);
				pos.Offset(0, 12);
			}


			// Abort spell
			batch.DrawTile(Tileset, 30, new Point(142, 336));

			// Abort spell
			if (new Rectangle(MainRectangle.X + 2, MainRectangle.Bottom - 14, MainRectangle.Width - 56, 18).Contains(Mouse.Location))
				color = GameColors.Red;
			else
				color = GameColors.White;
			batch.DrawString(GUI.DialogFont, new Point(146, 340), color, "Abort spell");

			// Next & previous buttons
			batch.DrawTile(Tileset, 28, new Point(298, 336));
			batch.DrawTile(Tileset, 29, new Point(326, 336));
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:55,代码来源:SpellBook.cs

示例3: DrawStatistics

		/// <summary>
		/// Draws hero statistic
		/// </summary>
		/// <param name="batch"></param>
		void DrawStatistics(SpriteBatch batch)
		{
			// Background
			batch.DrawTile(TileSet, 18, new Point(352, 0));
			batch.FillRectangle(new Rectangle(360, 70, 182, 30), GameColors.LightGrey);
			batch.FillRectangle(new Rectangle(360, 100, 276, 194), GameColors.LightGrey);
			batch.FillRectangle(new Rectangle(360, 294, 242, 36), GameColors.LightGrey);


			// Hero head
			batch.DrawTile(Heads, Team.SelectedHero.Head, new Point(360, 4));


			batch.DrawString(OutlinedFont, new Point(430, 12), GameColors.White, Team.SelectedHero.Name);
			batch.DrawString(OutlinedFont, new Point(370, 80), GameColors.White, "Character info");

			// HP and Food
			batch.DrawString(InventoryFont, new Point(500, 30), GameColors.Black, Team.SelectedHero.HitPoint.Current + " of " + Team.SelectedHero.HitPoint.Max);

			// Food
			Color color;
			if (Team.SelectedHero.Food > 50)
				color = GameColors.Green;
			else if (Team.SelectedHero.Food > 25)
				color = GameColors.Yellow;
			else
				color = GameColors.Red;

			batch.FillRectangle(new Rectangle(498, 48, Team.SelectedHero.Food, 10), color);

			string txt = string.Empty;
			foreach (Profession prof in Team.SelectedHero.Professions)
				txt += prof.Class.ToString() + "/";
			txt = txt.Substring(0, txt.Length - 1);

			batch.DrawString(InventoryFont, new Point(366, 110), GameColors.Black, txt);
			batch.DrawString(InventoryFont, new Point(366, 124), GameColors.Black, Team.SelectedHero.Alignment.ToString());
			batch.DrawString(InventoryFont, new Point(366, 138), GameColors.Black, Team.SelectedHero.Race.ToString() + " / " + Team.SelectedHero.Gender.ToString());

			batch.DrawString(InventoryFont, new Point(366, 166), GameColors.Black, "Strength");
			batch.DrawString(InventoryFont, new Point(366, 180), GameColors.Black, "Intelligence");
			batch.DrawString(InventoryFont, new Point(366, 194), GameColors.Black, "Wisdom");
			batch.DrawString(InventoryFont, new Point(366, 208), GameColors.Black, "Dexterity");
			batch.DrawString(InventoryFont, new Point(366, 222), GameColors.Black, "Constitution");
			batch.DrawString(InventoryFont, new Point(366, 236), GameColors.Black, "Charisma");
			batch.DrawString(InventoryFont, new Point(366, 250), GameColors.Black, "Armor class");


			batch.DrawString(InventoryFont, new Point(552, 166), GameColors.Black, Team.SelectedHero.Strength.Value.ToString());// + "/" + Team.SelectedHero.MaxStrength.ToString());
			batch.DrawString(InventoryFont, new Point(552, 180), GameColors.Black, Team.SelectedHero.Intelligence.Value.ToString());
			batch.DrawString(InventoryFont, new Point(552, 194), GameColors.Black, Team.SelectedHero.Wisdom.Value.ToString());
			batch.DrawString(InventoryFont, new Point(552, 208), GameColors.Black, Team.SelectedHero.Dexterity.Value.ToString());
			batch.DrawString(InventoryFont, new Point(552, 222), GameColors.Black, Team.SelectedHero.Constitution.Value.ToString());
			batch.DrawString(InventoryFont, new Point(552, 236), GameColors.Black, Team.SelectedHero.Charisma.Value.ToString());
			batch.DrawString(InventoryFont, new Point(552, 250), GameColors.Black, Team.SelectedHero.ArmorClass.ToString());


			batch.DrawString(InventoryFont, new Point(470, 270), GameColors.Black, "EXP");
			batch.DrawString(InventoryFont, new Point(550, 270), GameColors.Black, "LVL");
			int y = 0;
			foreach (Profession prof in Team.SelectedHero.Professions)
			{
				batch.DrawString(InventoryFont, new Point(366, 290 + y), GameColors.Black, prof.Class.ToString());
				batch.DrawString(InventoryFont, new Point(460, 290 + y), GameColors.White, prof.Experience.ToString());
				batch.DrawString(InventoryFont, new Point(560, 290 + y), GameColors.White, prof.Level.ToString());

				y += 12;
			}

		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:74,代码来源:GameScreen.cs

示例4: DrawInventory

		/// <summary>
		/// Draws the inventory
		/// </summary>
		/// <param name="batch"></param>
		void DrawInventory(SpriteBatch batch)
		{
			// Background
			batch.DrawTile(TileSet, 18, new Point(352, 0));

			// Name
			batch.DrawString(OutlinedFont, new Point(430, 12), GameColors.White, Team.SelectedHero.Name);

			// HP and Food
			batch.DrawString(InventoryFont, new Point(500, 30), GameColors.Black, Team.SelectedHero.HitPoint.Current + " of " + Team.SelectedHero.HitPoint.Max);

			// Dead or uncounscious
			if (Team.SelectedHero.IsUnconscious)
			{
				batch.DrawString(OutlinedFont, new Point(450, 316), GameColors.Yellow, "UNCONSCIOUS");
				batch.DrawTile(TileSet, 2, new Point(360, 4));
			}
			else if (Team.SelectedHero.IsDead)
			{
				batch.DrawString(OutlinedFont, new Point(500, 316), GameColors.Red, "DEAD");
				batch.DrawTile(TileSet, 4, new Point(360, 4));
			}
			else
				batch.DrawTile(Heads, Team.SelectedHero.Head, new Point(360, 4));


			// Food
			if (Team.SelectedHero.Food > 0)
			{
				Color color;
				if (Team.SelectedHero.Food > 50)
					color = GameColors.Green;
				else if (Team.SelectedHero.Food > 25)
					color = GameColors.Yellow;
				else
					color = GameColors.Red;

				batch.FillRectangle(new Rectangle(500, 48, Team.SelectedHero.Food, 10), color);
			}

			// Draw inventory
			int pos = 0;
			for (int y = 94; y < 346; y += 36)
				for (int x = 376; x < 448; x += 36)
				{
					if (Team.SelectedHero.GetBackPackItem(pos) != null)
						batch.DrawTile(Items, Team.SelectedHero.GetBackPackItem(pos).TileID, new Point(x, y));

					pos++;
				}


			// Quiver count
			if (Team.SelectedHero.Quiver > 99)
				batch.DrawString(InventoryFont, new Point(452, 128), GameColors.White, "++");
			else
				batch.DrawString(InventoryFont, new Point(452, 128), GameColors.White, Team.SelectedHero.Quiver.ToString());

			// Armor
			if (Team.SelectedHero.GetInventoryItem(InventoryPosition.Armor) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetInventoryItem(InventoryPosition.Armor).TileID, new Point(462, 166));

			// Wrists
			if (Team.SelectedHero.GetInventoryItem(InventoryPosition.Wrist) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetInventoryItem(InventoryPosition.Wrist).TileID, new Point(464, 206));

			// Primary
			if (Team.SelectedHero.GetInventoryItem(InventoryPosition.Primary) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetInventoryItem(InventoryPosition.Primary).TileID, new Point(474, 244));

			// Fingers 1
			if (Team.SelectedHero.GetInventoryItem(InventoryPosition.Ring_Left) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetInventoryItem(InventoryPosition.Ring_Left).TileID, new Point(462, 278));

			// Fingers 2
			if (Team.SelectedHero.GetInventoryItem(InventoryPosition.Ring_Right) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetInventoryItem(InventoryPosition.Ring_Right).TileID, new Point(486, 278));

			// Feet
			if (Team.SelectedHero.GetInventoryItem(InventoryPosition.Feet) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetInventoryItem(InventoryPosition.Feet).TileID, new Point(568, 288));

			// Secondary
			if (Team.SelectedHero.GetInventoryItem(InventoryPosition.Secondary) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetInventoryItem(InventoryPosition.Secondary).TileID, new Point(568, 246));

			// Back 1 598,184,36,36
			if (Team.SelectedHero.GetWaistPackItem(0) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetWaistPackItem(0).TileID, new Point(614, 202));

			// Back 2 598,220,36,36
			if (Team.SelectedHero.GetWaistPackItem(1) != null)
				batch.DrawTile(Items, Team.SelectedHero.GetWaistPackItem(1).TileID, new Point(614, 238));

			// Back 3 598,256,36,36
			if (Team.SelectedHero.GetWaistPackItem(2) != null)
//.........这里部分代码省略.........
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:101,代码来源:GameScreen.cs

示例5: DrawMain

		/// <summary>
		/// Draws the right side of the panel
		/// </summary>
		/// <param name="batch"></param>
		private void DrawMain(SpriteBatch batch)
		{

			// Draw heroes
			Point pos;
			for (int y = 0; y < 3; y++)
			{
				for (int x = 0; x < 2; x++)
				{
					Hero hero = Team.Heroes[y * 2 + x];
					if (hero == null)
						continue;

					pos = new Point(366 + 144 * x, y * 104 + 2);

					// Backdrop
					batch.DrawTile(TileSet, 17, pos);

					// Head
					if (hero.IsDead)
						batch.DrawTile(TileSet, 4, new Point(pos.X + 2, pos.Y + 20));
					else
						batch.DrawTile(Heads, hero.Head, new Point(pos.X + 2, pos.Y + 20));

					// Hero uncouncious
					if (hero.IsUnconscious)
						batch.DrawTile(TileSet, 2, new Point(pos.X + 4, pos.Y + 20));

					// Name
					if (HeroToSwap == hero)
					{
						batch.DrawString(InventoryFont, new Point(pos.X + 6, pos.Y + 6), GameColors.Red, " Swapping");
					}
					else if (Team.SelectedHero == hero)
					{
						batch.DrawString(InventoryFont, new Point(pos.X + 6, pos.Y + 6), GameColors.White, hero.Name);
					}
					else
					{
						batch.DrawString(InventoryFont, new Point(pos.X + 6, pos.Y + 6), GameColors.Black, hero.Name);
					}

					// HP
					if (GameSettings.DrawHPAsBar)
					{
						float percent = (float)hero.HitPoint.Current / (float)hero.HitPoint.Max;
						Color color = GameColors.Green;
						if (percent < 0.15)
							color = GameColors.Red;
						else if (percent < 0.4)
							color = GameColors.Yellow;

						batch.DrawString(InventoryFont, new Point(pos.X + 6, pos.Y + 88), GameColors.Black, "HP");
						DrawProgressBar(batch, hero.HitPoint.Current, hero.HitPoint.Max, new Rectangle(pos.X + 30, pos.Y + 88, 92, 10), color);
					}
					else
						batch.DrawString(InventoryFont, new Point(pos.X + 6, pos.Y + 88), GameColors.Black, hero.HitPoint.Current + " of " + hero.HitPoint.Max);


					#region Hands
					for (int i = 0; i < 2; i++)
					{
						HeroHand hand = (HeroHand)i;
						int yoffset = i * 32;

						// Hand
						Item item = hero.GetInventoryItem(hand == HeroHand.Primary ? InventoryPosition.Primary : InventoryPosition.Secondary);
						batch.DrawTile(Items, item != null ? item.TileID : Hands[i].TileID, new Point(pos.X + 96, pos.Y + 36 + yoffset));

						// Ghost hand
						if (!hero.CanUseHand(hand))
							batch.DrawTile(TileSet, 3, new Point(pos.X + 66, pos.Y + 20 + yoffset));


						// Hero hit a monster a few moment ago
						Attack attack = hero.GetLastAttack(hand);
						if (attack != null)
						{

							if (!hero.CanUseHand(hand))
							{
								// Ghost item
								batch.DrawTile(TileSet, 3, new Point(pos.X + 66, pos.Y + 20 + yoffset));

								// Monster hit ?
								if (attack.Target != null && !attack.IsOutdated(DateTime.Now, 1000))
								{
									batch.DrawTile(TileSet, 21, new Point(pos.X + 64, pos.Y + 20 + yoffset));

									if (attack.IsAHit)
										batch.DrawString(InventoryFont, new Point(pos.X + 90, pos.Y + 32 + yoffset), GameColors.White, attack.Hit.ToString());
									else if (attack.IsAMiss)
										batch.DrawString(InventoryFont, new Point(pos.X + 76, pos.Y + 32 + yoffset), GameColors.White, "MISS");
								}
							}

//.........这里部分代码省略.........
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:101,代码来源:GameScreen.cs

示例6: Draw

		/// <summary>
		/// Draw the door
		/// </summary>
		/// <param name="batch">Spritebatch to use</param>
		/// <param name="field">View field</param>
		/// <param name="position">Position in the view filed</param>
		/// <param name="view">Looking direction of the team</param>
		public override void Draw(SpriteBatch batch, ViewField field, ViewFieldPosition position, CardinalPoint view)
		{
			if (TileSet == null)
				return;

			TileDrawing td = null;
			TileSet wall = Square.Maze.WallTileset;


			// TODO: Under the door, draw sides
			if (field.GetBlock(ViewFieldPosition.L).IsWall && position == ViewFieldPosition.Team)
			{
		//		td = DisplayCoordinates.GetDoor(ViewFieldPosition.Team);
		//		if (td != null)
		//			batch.DrawTile(overlay, td.ID, td.Location, Color.White, 0.0f, td.Effect, 0.0f);
				if (field.Maze.Decoration != null)
				{
					field.Maze.Decoration.Draw(batch, field.Maze.DoorDeco, position);
				}
			}

			// Draw the door
			else if (((field.Maze.IsDoorNorthSouth(Square.Location) && (view == CardinalPoint.North || view == CardinalPoint.South)) ||
					(!field.Maze.IsDoorNorthSouth(Square.Location) && (view == CardinalPoint.East || view == CardinalPoint.West))) &&
					position != ViewFieldPosition.Team)
			{
				td = DisplayCoordinates.GetDoor(position);
				if (td != null)
				{
					batch.DrawTile(wall, td.ID, td.Location, Color.White, 0.0f, td.Effect, 0.0f);
					//block.Door.Draw(batch, td.Location, position, view);


					switch (Type)
					{
						case DoorType.Grid:
						DrawSimpleDoor(batch, 1, td.Location, position);
						break;
						case DoorType.Forest:
						DrawSimpleDoor(batch, 6, td.Location, position);
						break;
						case DoorType.Iron:
						DrawSimpleDoor(batch, 0, td.Location, position);
						break;
						case DoorType.Monster:
						DrawUpDownDoor(batch, 2, td.Location, position);
						break;
						case DoorType.Azure:
						DrawSimpleDoor(batch, 8, td.Location, position);
						break;
						case DoorType.Crimson:
						DrawSimpleDoor(batch, 9, td.Location, position);
						break;
						case DoorType.Temple:
						DrawSimpleDoor(batch, 10, td.Location, position);
						break;
						case DoorType.Silver:
						DrawSimpleDoor(batch, 11, td.Location, position);
						break;
						case DoorType.Mantis:
						DrawSimpleDoor(batch, 12, td.Location, position);
						break;
					}
				}
			}


		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:75,代码来源:Door.cs

示例7: DrawUpDownDoor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="location"></param>
		/// <param name="distance"></param>
		void DrawUpDownDoor(SpriteBatch batch, int tileid, Point location, ViewFieldPosition distance)
		{
			Vector2 scale = new Vector2();
			Color color = Color.White;
			Rectangle clip = Rectangle.Empty;
			int[] offset = new int[2];
			Point button = new Point();

			switch (distance)
			{
				case ViewFieldPosition.K:
				case ViewFieldPosition.L:
				case ViewFieldPosition.M:
				{
					location.Offset(56, 14);
					scale = Vector2.One;
					clip = new Rectangle(location, new Size(144, 142));
					offset[0] = VPosition * 5;
					offset[1] = 86 + VPosition * -2;
					button = new Point(252, 90);
				}
				break;

				case ViewFieldPosition.F:
				case ViewFieldPosition.G:
				case ViewFieldPosition.H:
				case ViewFieldPosition.I:
				case ViewFieldPosition.J:
				{
					location.Offset(28, 8);
					scale = new Vector2(0.66f, 0.66f);
					color = Color.FromArgb(130, 130, 130);
					clip = new Rectangle(location, new Size(104, 96));
					offset[0] = VPosition * 3;
					offset[1] = 56 - VPosition;
					button = new Point(230, 86);
				}
				break;

				case ViewFieldPosition.A:
				case ViewFieldPosition.B:
				case ViewFieldPosition.C:
				case ViewFieldPosition.D:
				case ViewFieldPosition.E:
				{
					location.Offset(14, 4);
					scale = new Vector2(0.5f, 0.5f);
					color = Color.FromArgb(40, 40, 40);
					clip = new Rectangle(location, new Size(68, 60));
					offset[0] = VPosition * 2;
					offset[1] = 36 - VPosition;
					button = new Point(210, 84);
				}
				break;

			}


			// Upper part
			InternalDraw(batch, TileSet, tileid,
				new Point(location.X, location.Y + offset[0]),
				clip,
				scale, color);

			// Lower part
			InternalDraw(batch, TileSet, tileid + 1,
				new Point(location.X, location.Y + offset[1]),
				clip,
				scale, color);

			// Button
			if (HasButton)
				batch.DrawTile(TileSet, 13, button, color, 0.0f, scale, SpriteEffects.None, 0.0f);

		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:80,代码来源:Door.cs

示例8: DrawSimpleDoor

		/// <summary>
		/// Draws a simple sliding door
		/// </summary>
		/// <param name="batch">Spritebatch handle</param>
		/// <param name="tileid">Tile id</param>
		/// <param name="location">Location on the screen</param>
		/// <param name="distance">Distance between the view point and the door</param>
		void DrawSimpleDoor(SpriteBatch batch, int tileid, Point location, ViewFieldPosition distance)
		{
			Vector2 scale = new Vector2();
			Color color = Color.White;
			Point button = new Point();

			switch (distance)
			{
				case ViewFieldPosition.K:
				case ViewFieldPosition.L:
				case ViewFieldPosition.M:
				{
					location.Offset(56, 16);
					scale = Vector2.One;
					button = new Point(252, 90);
				}
				break;

				case ViewFieldPosition.F:
				case ViewFieldPosition.G:
				case ViewFieldPosition.H:
				case ViewFieldPosition.I:
				case ViewFieldPosition.J:
				{
					location.Offset(32, 10);
					scale = new Vector2(0.66f, 0.66f);
					color = Color.FromArgb(130, 130, 130);
					button = new Point(230, 86);
				}
				break;

				case ViewFieldPosition.A:
				case ViewFieldPosition.B:
				case ViewFieldPosition.C:
				case ViewFieldPosition.D:
				case ViewFieldPosition.E:
				{
					location.Offset(12, 6);
					scale = new Vector2(0.50f, 0.50f);
					color = Color.FromArgb(40, 40, 40);
					button = new Point(210, 84);
				}
				break;

			}


			InternalDraw(batch, TileSet, tileid,
				new Point(location.X, location.Y + VPosition * 5),
				new Rectangle(location, new Size(144, 150)),
				scale, color);

			if (HasButton)
				batch.DrawTile(TileSet, 15, button, color, 0.0f, scale, SpriteEffects.None, 0.0f);

		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:63,代码来源:Door.cs

示例9: InternalDraw

		/// <summary>
		/// Draw the door with a scissor test
		/// </summary>
		/// <param name="batch">Spritebatch to use</param>
		/// <param name="tileset">Tileset to use</param>
		/// <param name="id">ID of the tile</param>
		/// <param name="location">Location of the tile on the screen</param>
		/// <param name="scissor">Scissor zone</param>
		/// <param name="scale">Scaling factor</param>
		/// <param name="color">Color</param>
		void InternalDraw(SpriteBatch batch, TileSet tileset, int id, Point location, Rectangle scissor, Vector2 scale, Color color)
		{
			if (batch == null)
				return;

			batch.End();

			Display.PushScissor(scissor);

			batch.Begin();
			batch.DrawTile(TileSet, id, location, color, 0.0f, scale, SpriteEffects.None, 0.0f);
			batch.End();

			Display.PopScissor();

			batch.Begin();
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:27,代码来源:Door.cs

示例10: DrawSquare

		/// <summary>
		/// Draws a square
		/// </summary>
		/// <param name="batch">Spritebatch handle</param>
		/// <param name="field">View field</param>
		/// <param name="position">Position of the square in the view field</param>
		/// <param name="view">Looking direction of the team</param>
		void DrawSquare(SpriteBatch batch, ViewField field, ViewFieldPosition position, CardinalPoint view)
		{
			if (field == null)
				return;

			Square square = field.Blocks[(int)position];
			Point point;
			Decoration deco = null;
			List<Item>[] list = square.GetItems(view);


			#region ceiling pit
			if (square.IsPitTarget)
			{
				//TODO
				TileDrawing td = DisplayCoordinates.GetCeilingPit(position);
				//if (td != null)
				//	batch.DrawTile(OverlayTileset, td.ID, td.Location, Color.White, 0.0f, td.Effect, 0.0f);
				//***batch.DrawTile(ItemsTileset, td.ID, td.Location, td.SwapX, td.SwapY);
			}

			#endregion


			#region Items on ground before a door
			// If there is a deco that hide ground items, skip
			deco = GetDecoration(square.Location, Compass.GetOppositeDirection(view));
			if (deco == null || (deco != null && !deco.HideItems))
			{
				if (!square.IsWall || (deco != null && !deco.HideItems))
				{
					for (int i = 0; i < 2; i++)
					{
						if (list[i].Count == 0)
							continue;

						foreach (Item item in list[i])
						{
							point = DisplayCoordinates.GetGroundPosition(position, (SquarePosition)i);
							if (!point.IsEmpty)
							{
								batch.DrawTile(Dungeon.ItemTileSet, item.GroundTileID, point,
									DisplayCoordinates.GetDistantColor(position), 0.0f,
									DisplayCoordinates.GetItemScaleFactor(position), SpriteEffects.None, 0.0f);
							}
						}
					}
				}
			}
			#endregion


			#region Walls
			if (square.IsWall)
			{
				// Walls
				foreach (TileDrawing tmp in DisplayCoordinates.GetWalls(position))
				{
					Color color = Color.White;
					int tileid = tmp.ID;

					//if (swap)
					//{
					//    color = Color.Red;
					//    tileid += 9;
					//}

					batch.DrawTile(WallTileset, tileid, tmp.Location, color, 0.0f, tmp.Effect, 0.0f);
				}
			}

			#endregion


			#region Decoration
			if (square.HasDecorations)
			{
				// Is there a forced decoration
				for (int i = 0; i < 4; i++)
				{
					deco = Decoration.GetDecoration(square.GetDecorationId((CardinalPoint)i));
					if (deco != null && deco.ForceDisplay)
						deco.DrawDecoration(batch, Decoration, position, true);
				}


				// For each directions, draws the decoration
				foreach (CardinalPoint side in DisplayCoordinates.DrawingWallSides[(int)position])
				{
					// Decoration informations
					deco = Decoration.GetDecoration(square.GetDecorationId(view, side));
					if (deco == null)
						continue;
//.........这里部分代码省略.........
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:101,代码来源:Maze.cs

示例11: Draw

		/// <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);
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:20,代码来源:DecorationSet.cs

示例12: Draw

		/// <summary>
		/// Draw the maze
		/// </summary>
		/// <param name="batch">SpriteBatch to use</param>
		/// <param name="location">Location to display from</param>
		/// <see cref="http://eob.wikispaces.com/eob.vmp"/>
		public void Draw(SpriteBatch batch, DungeonLocation location)
		{
			if (WallTileset == null)
				return;

			// Clear the spritebatch
			batch.End();
			Display.PushScissor(new Rectangle(0, 0, 352, 240));
			batch.Begin();


			//
			// 
			//
			ViewField pov = new ViewField(this, location);


			// TODO Backdrop
			// The background is assumed to be x-flipped when party.x & party.y & party.direction = 1.
			// I.e. all kind of moves and rotations from the current position will result in the background being x-flipped.
			bool flipbackdrop = ((location.Coordinate.X + location.Coordinate.Y + (int)location.Direction) & 1) == 0;
			SpriteEffects effect = flipbackdrop ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
			batch.DrawTile(WallTileset, 0, Point.Empty, Color.White, 0.0f, effect, 0.0f);

			// maze block draw order
			// A E B D C
			// F J G I H
			//   K M L
			//   N ^ O

			#region row -3
			DrawSquare(batch, pov, ViewFieldPosition.A, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.E, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.B, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.D, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.C, location.Direction);
			#endregion

			#region row -2
			DrawSquare(batch, pov, ViewFieldPosition.F, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.J, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.G, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.I, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.H, location.Direction);
			#endregion

			#region row -1
			DrawSquare(batch, pov, ViewFieldPosition.K, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.M, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.L, location.Direction);
			#endregion

			#region row 0
			DrawSquare(batch, pov, ViewFieldPosition.N, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.Team, location.Direction);
			DrawSquare(batch, pov, ViewFieldPosition.O, location.Direction);
			#endregion


			// Clear the spritebatch
			batch.End();
			Display.PopScissor();
			batch.Begin();

		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:71,代码来源:Maze.cs

示例13: Draw

		/// <summary>
		/// Draws the window
		/// </summary>
		/// <param name="batch">Spritebatch handle</param>
		public override void Draw(SpriteBatch batch)
		{
			base.Draw(batch);

			Team team = GameScreen.Team;

			// Display message
			if (Hero == null)
			{
				batch.DrawString(GUI.MenuFont, new Point(26, 58), RectangleColor, Message);
			}
			else
			{
				batch.DrawString(GUI.MenuFont, new Point(16, 76), Color.White, "0 of 0 remaining.");
			}

			#region Draw heroes
			for (int y = 0 ; y < 3 ; y++)
			{
				for (int x = 0 ; x < 2 ; x++)
				{
					Hero hero = team.Heroes[y * 2 + x];
					if (hero == null)
						continue;

					// Draw rectangle around the hero
					if (hero == Hero)
					{
						float col = (float)Math.Sin(1.0f);
						batch.DrawRectangle(new Rectangle(366 + x * 144, 2 + y * 104, 130, 104), Color.White);
						batch.DrawRectangle(new Rectangle(367 + x * 144, 4 + y * 104, 128, 101), Color.White);
					}
					else if (!hero.CheckClass(Filter))
					{
						// Ghost name
						batch.DrawTile(Interface, 31, new Point(368 + 144 * x, y * 104 + 4));
					}
				}
			}
			#endregion
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:45,代码来源:SpellWindow.cs

示例14: Draw

		/// <summary>
		/// Draw the monster
		/// </summary>
		/// <param name="batch">SpriteBatch to use</param>
		/// <param name="view">View direction</param>
		/// <param name="pos">Position of the monster in the field of view</param>
		public void Draw(SpriteBatch batch, CardinalPoint view, ViewFieldPosition pos)
		{
			if (batch == null || Tileset == null || Square == null)
				return;


			// Translate subsquare position according looking point
			int[][] sub = new int[][]
			{
				new int[] {0,1,2,3,4},		// North
				new int[] {3,2,1,0,4},		// South
				new int[] {1,3,0,2,4},		// West
				new int[] {2,0,3,1,4},		// East
			};



			// Find the good square location
			SquarePosition squarepos;
			if (Square.MonsterCount == 1)
				squarepos = SquarePosition.Center;
			else
				squarepos = (SquarePosition)sub[(int)view][(int)Position];

			// Screen coordinate
			//Point position = DisplayCoordinates.GetGroundPosition(pos, squarepos);
			Point position = DisplayCoordinates.GetMonsterLocation(pos, squarepos);
			position.Offset(DisplayCoordinates.GetScaleFactor(pos, DrawOffset));

			// Display color
			Color tint = DisplayCoordinates.GetDistantColor(pos);

			// Display in red if monster is hit
			if (LastHit + HitDisplayDuration > DateTime.Now)
				tint = Color.Red;

			// Draw
			batch.DrawTile(Tileset,
				GetTileID(view),
				position,
				tint,
				0.0f,
				DisplayCoordinates.GetMonsterScaleFactor(pos),
				NeedSwapSprite(view) ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
				0.0f);


		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:54,代码来源:Monster.cs

示例15: Draw

		/// <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);
				}
			}

		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:48,代码来源:AlcoveActor.cs


注:本文中的SpriteBatch.DrawTile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。