public bool IsEqualTo(TileCellSource source) { if (TextureIndex != source.TextureIndex) { return(false); } if (X != source.X) { return(false); } if (Y != source.Y) { return(false); } if (Width != source.Width) { return(false); } if (Height != source.Height) { return(false); } if (IsAutotile != source.IsAutotile) { return(false); } return(true); }
public TileCell(Point2D dest, TileCellSource source, float alpha, float rot) { X = dest.X; Y = dest.Y; TextureSource = source; Alpha = alpha; Rotation = rot; AutoTextureType = EAutoTileType.None; FlipEffect = SpriteEffects.None; }
public static TileCellSource Parse(string text) { var parts = text.Split(','); var src = new TileCellSource { TextureIndex = parts[0].Trim(), X = int.Parse(parts[1]), Y = int.Parse(parts[2]), Width = int.Parse(parts[3]), Height = int.Parse(parts[4]) }; return src; }
public static TileCellSource Parse(string text) { var parts = text.Split(','); var src = new TileCellSource { TextureIndex = parts[0].Trim(), X = int.Parse(parts[1]), Y = int.Parse(parts[2]), Width = int.Parse(parts[3]), Height = int.Parse(parts[4]) }; return(src); }
public bool IsEqualTo(TileCellSource source) { if (TextureIndex != source.TextureIndex) { return false; } if (X != source.X) { return false; } if (Y != source.Y) { return false; } if (Width != source.Width) { return false; } if (Height != source.Height) { return false; } if (IsAutotile != source.IsAutotile) { return false; } return true; }
private void SetAutotileType(Point2D startPoint, string autoIndex, ref List<Point2D> doneCells, ref List<UndoAction> undoCells) { TileCell cellBefore; var p = new Point2D(startPoint.X, startPoint.Y); if (doneCells.Contains(startPoint)) { return; } doneCells.Add(p); var thisCell = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X, startPoint.Y); var cellTop = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X, startPoint.Y - 1); var cellBottom = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X, startPoint.Y + 1); var cellLeft = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X - 1, startPoint.Y); var cellRight = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X + 1, startPoint.Y); var cellTopLeft = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X - 1, startPoint.Y - 1); var cellTopRight = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X + 1, startPoint.Y - 1); var cellBottomLeft = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X - 1, startPoint.Y + 1); var cellBottomRight = mTileMap.Layers[mCurrentLayer].GetCell(startPoint.X + 1, startPoint.Y + 1); var isAutoTile = (thisCell.IsAutoTexture && thisCell.TextureSource.TextureIndex == autoIndex); var hasTop = (cellTop.IsAutoTexture && cellTop.TextureSource.TextureIndex == autoIndex); var hasBottom = (cellBottom.IsAutoTexture && cellBottom.TextureSource.TextureIndex == autoIndex); var hasLeft = (cellLeft.IsAutoTexture && cellLeft.TextureSource.TextureIndex == autoIndex); var hasRight = (cellRight.IsAutoTexture && cellRight.TextureSource.TextureIndex == autoIndex); var hasTopLeft = (cellTopLeft.IsAutoTexture && cellTopLeft.TextureSource.TextureIndex == autoIndex); var hasTopRight = (cellTopRight.IsAutoTexture && cellTopRight.TextureSource.TextureIndex == autoIndex); var hasBottomLeft = (cellBottomLeft.IsAutoTexture && cellBottomLeft.TextureSource.TextureIndex == autoIndex); var hasBottomRight = (cellBottomRight.IsAutoTexture && cellBottomRight.TextureSource.TextureIndex == autoIndex); var autoSource = new TileCellSource(autoIndex, 0, 0, Constants.TileWidth, Constants.TileHeight); var cell = new TileCell(Point2D.Zero, autoSource, 1f, 0f); // keine anliegenden Autotiles if (hasTop == false && hasBottom == false && hasLeft == false && hasRight == false && hasTopLeft == false && hasTopRight == false && hasBottomLeft == false && hasBottomRight == false) { cell.AutoTextureType = EAutoTileType.None; // reset Cell type if (isAutoTile) { cell.AutoTextureType = EAutoTileType.StandAlone; if (startPoint.X == 0) { cell.AutoTextureType |= EAutoTileType.Left | EAutoTileType.TopLeft | EAutoTileType.BottomLeft; } if (startPoint.Y == 0) { cell.AutoTextureType |= EAutoTileType.Top | EAutoTileType.TopLeft | EAutoTileType.TopRight; } if (startPoint.X >= mTileMap.Layers[mCurrentLayer].Width - 1) { cell.AutoTextureType |= EAutoTileType.Right | EAutoTileType.BottomRight | EAutoTileType.TopRight; } if (startPoint.Y >= mTileMap.Layers[mCurrentLayer].Height - 1) { cell.AutoTextureType |= EAutoTileType.Bottom | EAutoTileType.BottomLeft | EAutoTileType.BottomRight; } cellBefore = GetCell(p); if (SetCell(p, cell, true)) { undoCells.Add(new UndoAction(mCurrentLayer, cell, cellBefore, p)); } } return; } // not alone in the Dark... cell.AutoTextureType = EAutoTileType.None; if (isAutoTile) { // say the Cell it has Autotiles on the Map Ending [open-end Autotile like RPG Maker XP] if (startPoint.X == 0) { cell.AutoTextureType |= EAutoTileType.Left | EAutoTileType.TopLeft | EAutoTileType.BottomLeft; } if (startPoint.Y == 0) { cell.AutoTextureType |= EAutoTileType.Top | EAutoTileType.TopLeft | EAutoTileType.TopRight; } if (startPoint.X >= mTileMap.Layers[mCurrentLayer].Width - 1) { cell.AutoTextureType |= EAutoTileType.Right | EAutoTileType.BottomRight | EAutoTileType.TopRight; } if (startPoint.Y >= mTileMap.Layers[mCurrentLayer].Height - 1) { cell.AutoTextureType |= EAutoTileType.Bottom | EAutoTileType.BottomLeft | EAutoTileType.BottomRight; } if (hasRight) { cell.AutoTextureType |= EAutoTileType.Right; } if (hasLeft) { cell.AutoTextureType |= EAutoTileType.Left; } if (hasTop) { cell.AutoTextureType |= EAutoTileType.Top; } if (hasBottom) { cell.AutoTextureType |= EAutoTileType.Bottom; } if (hasTopLeft) { cell.AutoTextureType |= EAutoTileType.TopLeft; } if (hasTopRight) { cell.AutoTextureType |= EAutoTileType.TopRight; } if (hasBottomLeft) { cell.AutoTextureType |= EAutoTileType.BottomLeft; } if (hasBottomRight) { cell.AutoTextureType |= EAutoTileType.BottomRight; } // nothing to update if (thisCell.AutoTextureType == cell.AutoTextureType) { return; } // set Cell Type cellBefore = GetCell(p); if (SetCell(p, cell, true)) { undoCells.Add(new UndoAction(mCurrentLayer, cell, cellBefore, p)); } } // update other Cells if (hasRight) { SetAutotileType(new Point2D(startPoint.X + 1, startPoint.Y), autoIndex, ref doneCells, ref undoCells); } if (hasLeft) { SetAutotileType(new Point2D(startPoint.X - 1, startPoint.Y), autoIndex, ref doneCells, ref undoCells); } if (hasTop) { SetAutotileType(new Point2D(startPoint.X, startPoint.Y - 1), autoIndex, ref doneCells, ref undoCells); } if (hasBottom) { SetAutotileType(new Point2D(startPoint.X, startPoint.Y + 1), autoIndex, ref doneCells, ref undoCells); } if (hasTopLeft) { SetAutotileType(new Point2D(startPoint.X - 1, startPoint.Y - 1), autoIndex, ref doneCells, ref undoCells); } if (hasTopRight) { SetAutotileType(new Point2D(startPoint.X + 1, startPoint.Y - 1), autoIndex, ref doneCells, ref undoCells); } if (hasBottomLeft) { SetAutotileType(new Point2D(startPoint.X - 1, startPoint.Y + 1), autoIndex, ref doneCells, ref undoCells); } if (hasBottomRight) { SetAutotileType(new Point2D(startPoint.X + 1, startPoint.Y + 1), autoIndex, ref doneCells, ref undoCells); } }
public TileCell(Point dest, TileCellSource source, float alpha, float rot) : this(new Point2D(dest.X, dest.Y), source, alpha, rot) { }
private static TileCellSource GetTextureSource(string name) { var parts = name.Split(new[] { '_' }); var src = new TileCellSource { TextureIndex = FileLists.Instance.AnimationTilesets[int.Parse(parts[0])].Filename, Width = Constants.AnimationTilesetWidth, Height = Constants.AnimationTilesetHeight, X = (int.Parse(parts[1]) * Constants.AnimationTilesetWidth), Y = (int.Parse(parts[2]) * Constants.AnimationTilesetHeight) }; return src; }