Ejemplo n.º 1
0
    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;
    }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
                }
            }
        }