Beispiel #1
0
		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);
			}
		}
Beispiel #2
0
		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)));
				}
			}
		}
Beispiel #3
0
		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);
			}
		}
Beispiel #4
0
		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);
			}
		}