public static bool switchLayersAction(string action, GameLocation location, Vector2 tile, string layer) { string[] actions = action.Split(' '); foreach (string s in actions) { string[] layers = s.Split(':'); if (layers.Length > 1) { if (layers.Length < 4) { location.map.switchLayers(layers[0], layers[1]); } else { string[] xStrings = layers[2].Split('-'); string[] yStrings = layers[3].Split('-'); Range xRange = new Range(int.Parse(xStrings[0]), int.Parse(xStrings.Last()) + 1); Range yRange = new Range(int.Parse(yStrings[0]), int.Parse(yStrings.Last()) + 1); foreach (int x in xRange.toArray()) { foreach (int y in yRange.toArray()) { location.map.switchTileBetweenLayers(layers[0], layers[1], x, y); } } } } } return(true); }
public static bool copyLayersAction(string action, GameLocation location, Vector2 tile, string layer) { string[] actions = action.Split(' '); foreach (string s in actions) { string[] layers = s.Split(':'); if (layers.Length > 1) { if (layers.Length < 4) { Layer l = location.map.GetLayer(layers[0]); if (l != null) { var size = new Microsoft.Xna.Framework.Rectangle(0, 0, l.DisplayWidth / Game1.tileSize, l.DisplayHeight / Game1.tileSize); for (int x = 0; x < size.Width; x++) { for (int y = 0; y < size.Height; y++) { copyTileBetweenLayers(location.map, layers[0], layers[1], x, y); } } } } else { string[] xStrings = layers[2].Split('-'); string[] yStrings = layers[3].Split('-'); Range xRange = new Range(int.Parse(xStrings[0]), int.Parse(xStrings.Last()) + 1); Range yRange = new Range(int.Parse(yStrings[0]), int.Parse(yStrings.Last()) + 1); foreach (int x in xRange.toArray()) { foreach (int y in yRange.toArray()) { copyTileBetweenLayers(location.map, layers[0], layers[1], x, y); } } } } } return(true); }
public static AssetInjector <IAssetDataForImage, IAssetDataForImage> injectTileInto(this Texture2D t, string assetName, Range targetTileIndex, Range sourceTileIndex, int tileWidth = 16, int tileHeight = 16, PatchMode mode = PatchMode.Replace) { Func <IAssetDataForImage, IAssetDataForImage> merger = new Func <IAssetDataForImage, IAssetDataForImage>(delegate(IAssetDataForImage asset) { for (int i = 0; i < sourceTileIndex.length; i++) { Rectangle source = Game1.getSourceRectForStandardTileSheet(t, sourceTileIndex[i], tileWidth, tileHeight); Rectangle target = Game1.getSourceRectForStandardTileSheet(asset.Data, targetTileIndex[i], tileWidth, tileHeight); asset.PatchImage(t, source, target, mode); } return(asset); }); return(new AssetInjector <IAssetDataForImage, IAssetDataForImage>(assetName, merger).injectEdit()); }