Exemplo n.º 1
0
        /// <summary>
        /// Upgrades <see cref="currentSelectedTower" />, if possible
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// Throws exception when selecting tower when
        /// <see cref="State" /> does not equal <see cref="State.Normal" />
        /// or <see cref="currentSelectedTower" /> is null
        /// </exception>
        public void UpgradeSelectedTower()
        {
            if (state != State.Normal)
            {
                throw new InvalidOperationException(
                          "Trying to upgrade whilst not in Normal state");
            }
            if (currentSelectedTower == null)
            {
                throw new InvalidOperationException(
                          "Selected Tower is null");
            }
            if (currentSelectedTower.isAtMaxLevel)
            {
                return;
            }
            int  upgradeCost       = currentSelectedTower.GetCostForNextLevel();
            bool successfulUpgrade = LevelManagerYfb.instance.currency.TryPurchase(upgradeCost);

            if (successfulUpgrade)
            {
                currentSelectedTower.UpgradeTower();
            }
            towerUI.Hide();
            DeselectTower();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Hides the information
        /// </summary>
        public virtual void Hide()
        {
            if (m_State == AnimationState.Hidden)
            {
                return;
            }

            m_TowerUI.Hide();
            anim.Play(hideClipName);
            m_State = anim[hideClipName].normalizedTime < 1 ? AnimationState.Hiding :
                      AnimationState.Hidden;
        }