public void InitTower(int ID) //the level is not used here { TowerPool tgameObject; tgameObject = PoolManager.poolManager.GetTowerParamFromID(ID); base.unitName = tgameObject.name; baseTower = tgameObject.towerAttri; baseTower.range = baseTower.maxRange; }
protected override void OnPropertyChanged(string propertyName) { if (propertyName == "Tower" && Tower != null) { // Get tower attribute TowerAttribute attr = (TowerAttribute)Tower.GetType().GetCustomAttributes(typeof(TowerAttribute), true).FirstOrDefault(); tbName.Text = attr.Name; tbLevel.Text = "Level: " + Tower.Level.ToString(); tbSellWorth.Text = "Sell Worth: " + Tower.GetSellPrice(); tbUpgradeCost.Text = "Upgrade Cost: " + Tower.GetUpgradeCost(); } base.OnPropertyChanged(propertyName); }
void button_Click(object sender, ButtonClickEventArgs e) { if (inputContext.State == GameInputContextState.None || inputContext.State == GameInputContextState.Placing) { // Get tower type Type towerType = (Type)((UIElement)sender).Tag; // Can the player afford it? TowerAttribute attr = (TowerAttribute)towerType.GetCustomAttributes(typeof(TowerAttribute), true).FirstOrDefault(); if (player.Cash >= attr.Cost) { var tower = (Tower)NinjectFactory.Kernel.Get(towerType); tower.Initialize(); tower.LoadContent(); inputContext.State = GameInputContextState.Placing; inputContext.CurrentSprite = tower; } } }