/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="towerName">tower name</param>
        public TowerEditor(string towerName)
        {
            InitializeComponent();

            // Draw the tower
            TowerManager tower = new TowerManager(this);
            tower.Draw(towerName, 0);

            // Set fields
            this.tower = TowerData.GetTower(towerName);
            this.tower.name = towerName;

            // Set labels' text
            costBox.Text = this.tower.buildCost.ToString();
            valueBox.Text = this.tower.sellValue.ToString();
            damageBox.Text = this.tower.damage.ToString();
            rangeBox.Text = this.tower.range.ToString();
            delayBox.Text = this.tower.delay.ToString();
            aoeRadiusBox.Text = this.tower.aoeRadius.ToString();
            aoeDamageBox.Text = this.tower.aoeDamage.ToString();
            aoeStatusComboBox.SelectedIndex = this.tower.aoeStatus ? 0 : 1;
            moneyPerAttackBox.Text = this.tower.moneyPerAttack.ToString();
            moneyPerKillBox.Text = this.tower.moneyPerKill.ToString();
            moneyPerTickBox.Text = this.tower.moneyPerTick.ToString();
            moneyPerWaveBox.Text = this.tower.moneyPerWave.ToString();

            // Setup the status combo box
            statusComboBox.Items.Add("None");
            statusComboBox.SelectedIndex = 0;
            string[] statusNames = StatusData.GetStatusNames();
            foreach (string s in statusNames)
            {
                statusComboBox.Items.Add(s);
                if (this.tower.status.Equals(s))
                    statusComboBox.SelectedItem = s;
            }

            // Setup the upgrade combo box
            upgradeComboBox.Items.Add("<None>");
            upgradeComboBox.SelectedIndex = 0;
            foreach (string s in TowerData.GetTowerNames())
                if (!s.Equals(this.tower.name))
                {
                    upgradeComboBox.Items.Add(s);
                    if (this.tower.baseTower.Equals(s))
                        upgradeComboBox.SelectedItem = s;
                }
        }
Beispiel #2
0
        /// <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;
        }
Beispiel #3
0
 /// <summary>
 /// Buys the supplied tower and marks it at the given coordinates
 /// </summary>
 /// <param name="t">tower to buy</param>
 /// <param name="x">horizontal coordinate</param>
 /// <param name="y">vertical coordinate</param>
 public void BuyTower(Tower t, int x, int y)
 {
     builtTowers.Add(new TowerInstance(t.name, x, y));
     money -= t.buildCost;
 }
Beispiel #4
0
 /// <summary>
 /// Gets the list of upgraded towers that t can turn into
 /// </summary>
 /// <param name="t">tower</param>
 /// <returns>upgrade towers</returns>
 public List<Tower> GetUpgrades(Tower t)
 {
     List<Tower> upgrades = new List<Tower>();
     foreach (Tower tower in towers)
         if (tower.baseTower.Equals(t.name) && tower.buildCost <= money)
             upgrades.Add(tower);
     return upgrades;
 }
Beispiel #5
0
 /// <summary>
 /// Updates the given tower
 /// </summary>
 /// <param name="tower">updated tower</param>
 public static void UpdateTower(Tower tower)
 {
     foreach (Tower t in towers)
         if (t.name.Equals(tower.name))
         {
             t.range = tower.range;
             t.sellValue = tower.sellValue;
             t.status = tower.status;
             t.delay = tower.delay;
             t.damage = tower.damage;
             t.buildCost = tower.buildCost;
             return;
         }
     towers.Add(tower);
 }