Ejemplo n.º 1
0
		public void DrawSprite(int x, int y, string location, int columns, int rows, int xt, int yt, float opacity) {
			Texture2D sprite = this.player.World.SpriteLibrary.GetSprite(location);
			if (sprite != null) {
				TileableTexture tileable = new TileableTexture(sprite, columns, rows);
				spriteBatch.Draw(sprite, new Rectangle(x, y, tileable.FrameWidth, tileable.FrameHeight), tileable.GetSource(tileable.GetIndex(xt, yt)), Color.White * opacity);
			}
		}
Ejemplo n.º 2
0
		public void DrawBox(SpriteBatch spriteBatch, TileableTexture Texture, int x, int y, int w, int h, float opacity = 1f) {
			spriteBatch.Begin();
			for (int i = 0; i < w; i++) {
				for (int j = 0; j < h; j++) {
					int xs = 0;
					int ys = 0;

					if (j == 0) {
						xs++;
						if (i == 0) xs--;
						else if (i == w - 1) xs++;
					} else if (i == 0) {
						ys++;
						if (j == h - 1) ys++;
					} else if (i == w - 1) {
						xs++;
						xs++;
						ys++;
						if (j == h - 1) ys++;
					} else if (j == h - 1) {
						xs++;
						ys++;
						ys++;
					} else {
						xs++;
						ys++;
					}

					Rectangle sourceRectangle = Texture.GetSource(Texture.GetIndex(xs, ys));
					spriteBatch.Draw(Texture.Texture, new Rectangle(x + i * Texture.FrameWidth, y + j * Texture.FrameHeight, Texture.FrameWidth, Texture.FrameHeight), sourceRectangle, Color.White * opacity);
				}
			}
			spriteBatch.End();
		}
Ejemplo n.º 3
0
		public override void LoadContent() {
			batch = new SpriteBatch(GraphicsDevice);
			base.LoadContent();
			Tileset = null;
			using (MemoryStream stream = new MemoryStream()) {
				MapEditor.Data.Resources.ox.Save(stream, ImageFormat.Png);
				ox = new TileableTexture(Texture2D.FromStream(EditorEngine.Instance.GraphicsDevice, stream), 2, 1);
			}
		}
Ejemplo n.º 4
0
		public IEncodable Decode(BinaryInput stream) {
			this.Name = stream.ReadString();
			int tilesCount = stream.ReadInt32();

			for (int i = 0; i < tilesCount; i++) {
				Tiles.Add(stream.ReadObject<Tile>());
			}

			this.Texture = stream.ReadObject<TileableTexture>();

			return this;
		}
Ejemplo n.º 5
0
		public IEncodable Decode(BinaryInput stream) {
			Name = stream.ReadString();
			ID = stream.ReadInt32();

			EntityType = (EntityType) stream.ReadByte();
			ShadowType = (ShadowType) stream.ReadByte();

			ShadowType = ShadowType.Perspective;

			isSubEntity = stream.ReadBoolean();

			ShadowOffset = stream.ReadInt32();
			stream.ReadInt32();

			CollisionMap = stream.ReadObject<CollisionMap>();
			Texture = stream.ReadObject<TileableTexture>();

			int c = stream.ReadInt32();
			for (int i = 0; i < c; i++) {
				Animations.Add(stream.ReadObject<Animation>());
			}
			return this;
		}
Ejemplo n.º 6
0
		public void Dump() {
			try {
				Texture2D texture = Texture2D.FromStream(this.GraphicsDevice, File.OpenRead(@"C:\Users\Oxysoft\Desktop\_splitter_tool\input.png"));
				string dumploc = @"C:\Users\Oxysoft\Desktop\_splitter_tool\newdump\";
				const int cols = 10;
				const int rows = 10;
				TileableTexture tileableTexture = new TileableTexture(texture, cols, rows);
				List<RenderTarget2D> results = new List<RenderTarget2D>();
				Color chroma1 = new Color(0xBF, 0xC8, 0xFF);
				Color chroma2 = new Color(0xD8, 0xDE, 0xFF);
				for (int y = 0; y < rows; y++) {
					for (int x = 0; x < cols; x++) {
						int[] order = new int[4 * 4];

						order[0] = 5;
						order[1] = 11;
						order[2] = 5;
						order[3] = 8;
						order[4] = 6;
						order[5] = 3;
						order[6] = 6;
						order[7] = 9;
						order[8] = 1;
						order[9] = 4;
						order[10] = 1;
						order[11] = 7;
						order[12] = 0;
						order[13] = 2;
						order[14] = 0;
						order[15] = 10;

						RenderTarget2D renderTarget = new RenderTarget2D(GraphicsDevice, 96, 128);
						TileableTexture tileableRenderTarget = new TileableTexture(renderTarget, 3, 4);
						GraphicsDevice.SetRenderTarget(renderTarget);
						SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice);
						spriteBatch.Begin();
						spriteBatch.Draw(texture, new Rectangle(0, 0, 96, 128), tileableTexture.GetSource(tileableTexture.GetIndex(x, y)), Color.White);
						spriteBatch.End();
						GraphicsDevice.SetRenderTarget(null);
						RenderTarget2D resultTarget = new RenderTarget2D(GraphicsDevice, 128, 128);
						TileableTexture tileableResultTarget = new TileableTexture(resultTarget, 4, 4);
						GraphicsDevice.SetRenderTarget(resultTarget);
						GraphicsDevice.Clear(Color.Transparent);

						spriteBatch.Begin();
						for (int i = 0; i < order.Length; i++) {
							Rectangle target = tileableResultTarget.GetSource(i);
							spriteBatch.Draw(renderTarget, target, tileableRenderTarget.GetSource(order[i]), Color.White);
						}
						spriteBatch.End();
						GraphicsDevice.SetRenderTarget(null);

						//----> Start of CHROMA CLEARING
						Color[] colors = new Color[resultTarget.Width * resultTarget.Height];
						resultTarget.GetData<Color>(colors);

						for (int i = 0; i < colors.Length; i++) {
							if (colors[i] == chroma1 || colors[i] == chroma2) colors[i] = Color.Transparent; 
						}

						resultTarget.SetData<Color>(colors);
						//End of CHROMA CLEARING <----
						
						results.Add(resultTarget);
					}
				}
				for (int i = 0; i < results.Count; i++) {
					results[i].SaveAsPng(File.OpenWrite(dumploc + i + ".png"), results[i].Width, results[i].Height);
				}
			} catch (Exception e) {
				Console.WriteLine("what da fack");
			}
		}