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


C# Rectangle.Add方法代码示例

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


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

示例1: Draw

		public void Draw(GameTime gameTime) {
			Map map = EditorEngine.Instance.CurrentMap;
			if (lxt < 0 || lyt < 0 || lxt >= map.Width || lyt >= map.Height) return;
			Tileset tileset = EditorEngine.Instance.CurrentMap.Tilesets[TileEditorState.Instance.SelectedTileset].Tileset;
			Stack<Vector2> visitStack = new Stack<Vector2>();
			List<Vector2> visited = new List<Vector2>();
			List<Vector2> points = new List<Vector2>();

			visitStack.Push(new Vector2(lxt, lyt));

			int currentIndex = map.GetTile(lxt, lyt, EditorEngine.Instance.SelectedLayer).tileIndex;
			int currentTilesetIndex = map.GetTile(lxt, lyt, EditorEngine.Instance.SelectedLayer).tilesetIndex;

			while (visitStack.Count > 0) {
				Vector2 point = visitStack.Pop();

				if (!visited.Contains(point)) {
					int cx = (int) point.X;
					int cy = (int) point.Y;

					MockupTile t = EditorEngine.Instance.CurrentMap.GetTile(cx, cy, EditorEngine.Instance.SelectedLayer);

					points.Add(point);

					if (map.GetTile(cx + 1, cy, EditorEngine.Instance.SelectedLayer) != null && cx + 1 < map.Width && map.GetTile(cx + 1, cy, EditorEngine.Instance.SelectedLayer).tileIndex == currentIndex && map.GetTile(cx + 1, cy, EditorEngine.Instance.SelectedLayer).tilesetIndex == currentTilesetIndex)
						visitStack.Push(new Vector2(cx + 1, cy));
					if (map.GetTile(cx - 1, cy, EditorEngine.Instance.SelectedLayer) != null && cx - 1 >= 0 && map.GetTile(cx - 1, cy, EditorEngine.Instance.SelectedLayer).tileIndex == currentIndex && map.GetTile(cx - 1, cy, EditorEngine.Instance.SelectedLayer).tilesetIndex == currentTilesetIndex)
						visitStack.Push(new Vector2(cx - 1, cy));
					if (map.GetTile(cx, cy + 1, EditorEngine.Instance.SelectedLayer) != null && cy + 1 < map.Width && map.GetTile(cx, cy + 1, EditorEngine.Instance.SelectedLayer).tileIndex == currentIndex && map.GetTile(cx, cy + 1, EditorEngine.Instance.SelectedLayer).tilesetIndex == currentTilesetIndex)
						visitStack.Push(new Vector2(cx, cy + 1));
					if (map.GetTile(cx, cy - 1, EditorEngine.Instance.SelectedLayer) != null && cy - 1 < map.Width && map.GetTile(cx, cy - 1, EditorEngine.Instance.SelectedLayer).tileIndex == currentIndex && map.GetTile(cx, cy - 1, EditorEngine.Instance.SelectedLayer).tilesetIndex == currentTilesetIndex)
						visitStack.Push(new Vector2(cx, cy - 1));

					visited.Add(point);
				}
			}

			SpriteBatch spriteBatch = EditorEngine.Instance.World.ViewData.SpriteBatch;

			foreach (Vector2 point in points) {
				Rectangle target = new Rectangle((int) (point.X * 16 * EditorEngine.Instance.World.Camera.Scale), (int) (point.Y * 16 * EditorEngine.Instance.World.Camera.Scale), (int) (16 * EditorEngine.Instance.World.Camera.Scale), (int) (16 * EditorEngine.Instance.World.Camera.Scale));
				Rectangle source = tileset.Texture.GetSource(TileEditorState.Instance.SelectedRegion.X, TileEditorState.Instance.SelectedRegion.Y);
				spriteBatch.Draw(tileset.Texture.Texture, target.Add(EditorEngine.Instance.World.Camera.Location), source, Color.Black * .5f);
			}
		}
开发者ID:Hakua,项目名称:PokeSharp,代码行数:45,代码来源:BucketTool.cs

示例2: Draw

		public void Draw(Microsoft.Xna.Framework.GameTime gameTime) {
			SpriteBatch batch = EditorEngine.Instance.World.ViewData.SpriteBatch;
			if (batch != null) {
				foreach (LogicPathSquare sq in path) {
					float scale = EditorEngine.Instance.World.Camera.Scale;
					Vector2 scroll = EditorEngine.Instance.World.Camera.Location;

					Rectangle target = new Rectangle((int) (sq.x * 16 * scale), (int) (sq.y * 16 * scale), (int) (16 * scale), (int) (16 * scale)).Add(scroll);

					SelectionUtil.DrawRectangle(batch, Color.CornflowerBlue * .7f, target);
					SelectionUtil.DrawRectangle(batch, Color.Black * .8f, target.Add(new Vector2(1, 1)));
				}
			}
		}
开发者ID:Hakua,项目名称:PokeSharp,代码行数:14,代码来源:LogicPathTool.cs

示例3: Draw

		public void Draw(Microsoft.Xna.Framework.GameTime gameTime) {
			SpriteBatch spriteBatch = EditorEngine.Instance.World.ViewData.SpriteBatch;

			if (selection.Region != Rectangle.Empty) {
				int xs = (int) EditorEngine.Instance.World.Camera.Location.X;
				int ys = (int) EditorEngine.Instance.World.Camera.Location.Y;

				float scale = EditorEngine.Instance.World.Camera.Scale;
				Vector2 scroll = EditorEngine.Instance.World.Camera.Location;

				Rectangle target = new Rectangle((int) (selection.Region.X * scale * 16 + scroll.X), (int) (selection.Region.Y * scale * 16 + scroll.Y), (int) (selection.Region.Width * 16 * scale), (int) (selection.Region.Height * 16 * scale));

				SelectionUtil.DrawRectangle(spriteBatch, Color.Black, target.Add(new Vector2(1, 1)));
				SelectionUtil.DrawRectangle(spriteBatch, Color.White, target);
			}
		}
开发者ID:Hakua,项目名称:PokeSharp,代码行数:16,代码来源:EntityRectangleTool.cs

示例4: Draw

		public void Draw(Microsoft.Xna.Framework.GameTime gameTime) {
			Vector2 position = new Vector2(this.selection.Region.X, this.selection.Region.Y) * new Vector2(16, 16);
			SpriteBatch batch = EditorEngine.Instance.World.ViewData.SpriteBatch;

			if (batch != null && capturedmouse) {
				Vector2 scroll = EditorEngine.Instance.World.Camera.Location;
				float scale = EditorEngine.Instance.World.Camera.Scale;

				Rectangle target = new Rectangle((int) (position.X * scale), (int) (position.Y * scale), (int) (selection.Region.Width * 16 * scale), (int) (selection.Region.Height * 16 * scale)).Add(scroll);

				SelectionUtil.FillRectangle(batch, Color.Blue * .35f, target);
				SelectionUtil.DrawRectangle(batch, Color.Black, target.Add(new Vector2(1, 1)));
				SelectionUtil.DrawRectangle(batch, Color.White, target);
			}
		}
开发者ID:Hakua,项目名称:PokeSharp,代码行数:15,代码来源:LogicRectangleTool.cs


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