/// <summary> /// Constructor /// </summary> /// <param name="tile">name of tile to edit</param> public TileEditor(string tile) { tileName = tile; InitializeComponent(); bool? currentType = TileData.GetType(tile); int index = 0; foreach (string s in types) { typeComboBox.Items.Add(s); if (typeValues[index++] == currentType) typeComboBox.SelectedIndex = index - 1; } TileManager sprite = new TileManager(this); sprite.Draw(tile, 0, 0); }
/// <summary> /// Constructor /// </summary> /// <param name="s">message text</param> public PositionSelection(string s) { InitializeComponent(); messageLabel.Content = s; x = 0; y = 0; TileManager tiles = new TileManager(this); foreach (string tile in MainWindow.map) { tiles.Draw(tile, 0, 0); y++; if (y == MainWindow.height) { y = 0; x++; } } x = -1; y = -1; }
/// <summary> /// Constructor /// </summary> /// <param name="currentTile">currently selected tile</param> public TileSelection(string currentTile) { InitializeComponent(); cursor = ControlManager.CreateCanvas(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\TowerHaven\\Marker", 8, 4, 8); grid1.Children.Add(cursor); string[] tiles = TileData.GetTileNames(); int index = 0; TileManager sprite = new TileManager(this); // Add tile labels foreach (string s in tiles) { if (s.Equals(currentTile)) cursor.Margin = new Thickness(8, 4 + 16 * index, 0, 0); sprite.Draw(s, -6, index); Label label = ControlManager.CreateLabel(s, 50, 16 * index - 5); label.MouseLeftButtonDown += TileName_Clicked; grid1.Children.Add(label); index++; } }
/// <summary> /// Constructor /// </summary> public MainWindow() { // Default WPF intializer InitializeComponent(); towers = new List<string>(); try { // Create directories if they do not exist Directory.CreateDirectory(directory + "Tiles"); Directory.CreateDirectory(directory + "Towers"); Directory.CreateDirectory(directory + "Enemies"); Directory.CreateDirectory(directory + "MapsSource"); } catch (Exception) { } // Copy default tiles if no tiles are currently available if (TileData.GetTileNames().Length == 0) TileData.LoadTiles(); // Load editor data TileData.Load(); TowerData.Load(); EnemyData.Load(); StatusData.Load(); WaveData.Load(); // Prepare map drawing sprite = new TileManager(this); backgroundTile = "Grass"; tile = TileData.GetTileNames()[0]; height = 25; width = 30; health = 1; // Setup tile palette updater DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 1); timer.Tick += UpdateTilePalette; timer.Start(); UpdateTilePalette(null, null); // Load a map if any Load(); // Add a mouse listener (turn off drawing when mouse leaves the window) MouseLeave += Mouse_Released; // Set the size of the window SetSize(); }