// the transformation routines public void Rotate() { for (int index = 0; index < _brushes.Length; index++) { _brushes[index].Rotate(); } var array = new Brush[_brushes.Length]; for (int y = 0; y < _brushSize.Y; y++) { for (int x = 0; x < _brushSize.X; x++) { var yy = y; var xx = (_brushSize.X - 1) - x; var index1 = y * _brushSize.X + x; var index2 = xx * _brushSize.Y + yy; array[index2] = _brushes[index1]; } } _brushes = array; // flip brush _brushSize = new Point(_brushSize.Y, _brushSize.X); CreateTexture(); }
public CopyBrush(Brush[] brushes, Point brushSize) { if (brushes.Length == 0) throw new UnityException("No array"); _textureSize = (int)Math.Sqrt(brushes[0].Colors.GetLength(0)); _brushSize = brushSize; _brushes = brushes; CreateTexture(); }
public NormalBrush(int textureSize, TileTexture tt) { TextureSize = textureSize; if (tt == null) { return; } var pixels = tt.Texture.GetPixels(); var oldSize = (int)Mathf.Sqrt(pixels.Length); var colors = Util.ResizeArray(pixels, _textureSize, oldSize); var c = tt.Collision; var collision = new bool[c.Length]; Array.Copy(c, collision, c.Length); _brush = new Brush(colors, new TileProperties(tt.ID), collision); _preview = new Texture2D(_textureSize, _textureSize, TextureFormat.ARGB32, false); _preview.SetPixels(_brush.Colors); _preview.Apply(); }
public void PushUndo(Cell cell, Point localTileID, Brush brush) { var ud = new UndoData(cell, localTileID, brush); _undo[_index].Add(ud); }
public UndoData(Cell cell, Point localTileID, Brush brush) { Cell = cell; LocalTileID = localTileID; Brush = brush; }