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


C# SpriteBatch.FillRectangle方法代码示例

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


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

示例1: 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

示例2: 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

示例3: DrawMiniMap

		/// <summary>
		/// Draws the minimap
		/// </summary>
		/// <param name="batch">Spritebatch handle</param>
		/// <param name="location">Location on the screen</param>
		public void DrawMiniMap(SpriteBatch batch, Point location)
		{
			if (batch == null)
				return;

			Team team = GameScreen.Team;

			Color color;

			for (int y = 0; y < Size.Height; y++)
				for (int x = 0; x < Size.Width; x++)
				{
					Square block = GetSquare(new Point(x, y));

					switch (block.Type)
					{
						case SquareType.Wall:
						color = Color.Black;
						break;
						case SquareType.Illusion:
						color = Color.Gray;
						break;
						default:
						color = Color.White;
						break;
					}



					if (block.MonsterCount > 0)
						color = Color.Red;
					if (block.Actor is Door)
						color = Color.Yellow;
					if (block.Actor is Pit)
						color = Color.DarkBlue;
					if (block.Actor is Stair)
						color = Color.LightGreen;
					if (block.MonsterCount > 0)
						color = Color.Red;


					if (team.Location.Coordinate.X == x && team.Location.Coordinate.Y == y && team.Maze == this)
						color = Color.Blue;

					batch.FillRectangle(new Rectangle(location.X + x * 4, location.Y + y * 4, 4, 4), color);

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

示例4: DrawProgressBar

		/// <summary>
		/// Draws a progress bar
		/// </summary>
		/// <param name="batch">SpriteBatch to use</param>
		/// <param name="value">Current value</param>
		/// <param name="max">Maximum value</param>
		/// <param name="rectangle">Rectangle</param>
		/// <param name="color">Bar color</param>
		public void DrawProgressBar(SpriteBatch batch, int value, int max, Rectangle rectangle, Color color)
		{
			if (value > 0)
			{
				Vector4 zone = new Vector4(
					rectangle.Left + 1,
					rectangle.Top + 1,
					((float)value / (float)max * (rectangle.Width - 1)),
					rectangle.Height - 2
					);
				batch.FillRectangle(zone, color);
			}

			batch.DrawLine(rectangle.Left, rectangle.Top, rectangle.Left, rectangle.Bottom, GameColors.LightBlue);
			batch.DrawLine(rectangle.Left, rectangle.Bottom, rectangle.Right + 2, rectangle.Bottom, GameColors.LightBlue);


			batch.DrawLine(rectangle.Left + 1, rectangle.Top, rectangle.Right + 1, rectangle.Top, GameColors.DarkBlue);
			batch.DrawLine(rectangle.Right + 1, rectangle.Top, rectangle.Right + 1, rectangle.Bottom, GameColors.DarkBlue);
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:28,代码来源:GameScreen.cs

示例5: DrawDoubleBevel

		/// <summary>
		/// Draws a beveled rectangle
		/// </summary>
		/// <param name="batch">SpriteBatch to use</param>
		/// <param name="rect">Rectangle</param>
		/// <param name="bg">Background color</param>
		/// <param name="light">Light color</param>
		/// <param name="dark">Dark color</param>
		/// <param name="reverse">Inverse the color, giving a raise effect</param>
		public static void DrawDoubleBevel(SpriteBatch batch, Rectangle rect, Color bg, Color light, Color dark, bool reverse)
		{
			batch.FillRectangle(rect, bg);

			Point point = rect.Location;
			Size size = rect.Size;

				batch.FillRectangle(new Rectangle(point.X + 2, point.Y, size.Width - 2, 2), reverse ? dark : light);
				batch.FillRectangle(new Rectangle(point.X + 4, point.Y + 2, size.Width - 4, 2), reverse ? dark : light);
				batch.FillRectangle(new Rectangle(rect.Right - 4, point.Y + 4, 2, size.Height - 8), reverse ? dark : light);
				batch.FillRectangle(new Rectangle(rect.Right - 2, point.Y + 4, 2, size.Height - 6), reverse ? dark : light);

				batch.FillRectangle(new Rectangle(point.X, point.Y + 2, 2, size.Height - 4), reverse ? light : dark);
				batch.FillRectangle(new Rectangle(point.X + 2, point.Y + 4, 2, size.Height - 6), reverse ? light : dark);
				batch.FillRectangle(new Rectangle(point.X, point.Y + size.Height - 2, size.Width - 2, 2), reverse ? light : dark);
				batch.FillRectangle(new Rectangle(point.X, point.Y + size.Height - 4, size.Width - 4, 2), reverse ? light : dark);
		}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:26,代码来源:GUI.cs


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