/// <summary> /// Constructor /// </summary> /// <param name="level">level data</param> /// <param name="x">horizontal coordinate of selected tile</param> /// <param name="y">vertical coordinate of selected tile</param> public GameTowerSelection(Level level, int x, int y) { InitializeComponent(); // Set fields this.level = level; this.x = x; this.y = y; // Draw the cursor cursor = ControlManager.CreateCanvas(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\TowerHaven\\Marker", 8, 6, 8); nameGrid.Children.Add(cursor); // Find buildable towers that are affordable towers = level.GetBuildableTowers(); int index = 0; foreach (Tower t in towers) { AddLabel(25, index, t.name, nameGrid); AddLabel(6, index, t.buildCost.ToString(), costGrid); AddLabel(6, index, t.range.ToString(), rangeGrid); AddLabel(6, index, t.damage.ToString(), damageGrid); AddLabel(6, index, t.status, statusGrid); index += 16; } }
/// <summary> /// Constructor /// </summary> /// <param name="level">level data</param> /// <param name="x">horizontal position</param> /// <param name="y">vertical position</param> /// <param name="canBuild">whether or not this tile can be built on presently</param> public GameTileMenu(Level level, int x, int y, Boolean canBuild) { InitializeComponent(); // Set fields this.level = level; this.x = x; this.y = y; // Apply data to labels tileName.Content = level.GetTileName(x, y); typeLabel.Content = level.GetTileType(x, y); // Draw the tile or tower string path; if (level.IsTower(x, y)) path = directory + "Tower" + level.GetTileName(x, y); else path = directory + "Tile" + level.GetTileName(x, y); Canvas tile = ControlManager.CreateCanvas(path, 4, 4, 16); ContentRoot.Children.Add(tile); // Add buttons // If it is a tower, add the "Sell" button // If the tower can be upgraded, add the "Upgrade" button if (level.IsTower(x, y)) { Button option = CreateOptionButton("Sell Tower", 8, 60, 8); option.Click += Sell_Click; ContentRoot.Children.Add(option); // Check if the tower can be upgraded // Needs enough money and a tower to upgrade into foreach (Tower t in level.TowerList) { if (t.baseTower.Equals(level.GetTileName(x, y)) && level.Money >= t.buildCost) { Button upgrade = CreateOptionButton("Upgrade", 8, 95, 8); upgrade.Click += Upgrade_Click; Height = Height + 35; ContentRoot.Children.Add(upgrade); break; } } } // If it is a tile and it is buildable and enough money is owned to build at least one tower, // add the "Build" button else if (level.CanBuild && level.IsBuildable(x, y) && canBuild) { Button option = CreateOptionButton("Build Tower", 8, 60, 8); option.Click += Build_Click; ContentRoot.Children.Add(option); } else Height = Height - 35; }
/// <summary> /// Constructor /// </summary> /// <param name="child">tower being upgraded</param> /// <param name="level">level the tower is in</param> /// <param name="x">horizontal coordinate</param> /// <param name="y">vertical coordinate</param> public Upgrade(Tower child, Level level, int x, int y) { InitializeComponent(); this.level = level; this.x = x; this.y = y; List<Tower> upgrades = level.GetUpgrades(child); foreach (Tower t in upgrades) upgradeComboBox.Items.Add(t.name); upgradeComboBox.SelectedIndex = 0; UpdateLabels(); childAoeLabel.Content = child.aoeRadius > 0 ? child.aoeRadius + " (" + child.aoeDamage + "%)" : "None"; childDamageLabel.Content = child.damage; childDelayLabel.Content = child.delay; childRangeLabel.Content = child.range; childStatusLabel.Content = child.status; }
/// <summary> /// Constructor /// </summary> /// <param name="level">level data</param> /// <param name="x">horizontal position</param> /// <param name="y">vertical position</param> public GameTileMenu(Level level, int x, int y) : this(level, x, y, true) { }