public override void Execute(object parameter) { Logging.DebugLogger.WriteLine($"{GetType().Name}.{nameof(Execute)}({parameter})"); var result = MessageBox.Show("Are you sure you want to transform this tile?", "Warning!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.No) { return; } if (!(parameter is ITile tile)) { MessageBox.Show($"Could not transform to {nameof(ContainerTile)}, parameter was of type {parameter.GetType()}."); return; } if (tile.Button == null) { MessageBox.Show($"Could not transform to {nameof(ContainerTile)}, not connected to a button yet."); return; } var newTile = new ContainerTile(tile.Id, tile.Column, tile.Row, tile.Text, tile.Background, tile.Foreground, new TileCollection()); tile.Button.Update(newTile); Settings.ReplaceTile(tile, newTile); new EditTileCommand().Execute(newTile); }
private static Tile GenerateRandomTile(int level, int x, int y) { Tile t; if (level < parameters.DivisionLevels && random.Next(level + 1) == 0) { //NW; NE; SE; SW Tile[] subdivision = new Tile[4]; int offset = parameters.TileSize / (Convert.ToInt32(Math.Pow(2, level))); subdivision[0] = GenerateRandomTile(level + 1, x, y); subdivision[1] = GenerateRandomTile(level + 1, x + offset, y); subdivision[2] = GenerateRandomTile(level + 1, x + offset, y + offset); subdivision[3] = GenerateRandomTile(level + 1, x, y + offset); t = new ContainerTile(x, y, level, subdivision); } else { //int randomType = RANDOM.Next(TILESET.tileCount-1); int randomType = 1 + random.Next(13); t = new GraphicTile(x, y, level, (TileType)randomType, tileset.GetTile(level - 1, randomType)); } return(t); }
private static Tile GenerateRandomPerlinTile(int level, int x, int y, double[,] noise) { Tile t; double noiseValue = noise[x / 10, y / 10]; //DEBUG double limit1 = 0.5d; double risinglimit = 0.05d; //LIL BIT OF RANDOMNESS noiseValue += (random.NextDouble() - 0.5) / 5; bool isContainer = false; if (noiseValue < limit1 - ((level - 1) * (risinglimit))) { isContainer = true; } if (level < parameters.DivisionLevels && isContainer) { //NW; NE; SE; SW Tile[] subdivision = new Tile[4]; int offset = parameters.TileSize / (Convert.ToInt32(Math.Pow(2, level))); subdivision[0] = GenerateRandomPerlinTile(level + 1, x, y, noise); subdivision[1] = GenerateRandomPerlinTile(level + 1, x + offset, y, noise); subdivision[2] = GenerateRandomPerlinTile(level + 1, x + offset, y + offset, noise); subdivision[3] = GenerateRandomPerlinTile(level + 1, x, y + offset, noise); t = new ContainerTile(x, y, level, subdivision); } else { //int randomType = RANDOM.Next(TILESET.tileCount-1); int randomType = 1 + random.Next(13); t = new GraphicTile(x, y, level, (TileType)randomType, tileset.GetTile(level - 1, randomType)); } return(t); }