コード例 #1
0
        private void Awake()
        {
            _linkedTower = GetComponentInParent<Tower>();

            // We should change our rank when it actually changes
            _linkedTower.RankedHasChangedEvent += SetImageSpriteBasedOnRank;

            _rankImage = GetComponent<SpriteRenderer>();

            SetImageSpriteBasedOnRank(_linkedTower.Rank);
        }
コード例 #2
0
        /// <summary>
        /// Changing the cost logic
        /// We're not only getting the cost, but also dimming the Upgrade button
        /// </summary>
        /// <param name="tower"></param>
        /// <returns></returns>
        protected override int GetCostFromTower(Tower tower)
        {
            var towerUpgradePrice = tower.TowerPreferences[tower.Rank].UpgradeCost;

            if (towerUpgradePrice > PlayerStatus.Instance.Money)
            {
                GetComponent<Image>().color = Color.gray;
                // And subscribe to the money changed event so possobly later we will be able to buy that tower
                GlobalEventSystem<MoneyChangedEvent>.EventHappened += MoneyHasChangedEvent;
            }

            return towerUpgradePrice;
        }
コード例 #3
0
 /// <summary>
 /// Gets cost from the provided tower
 /// </summary>
 /// <param name="tower">Tower from which we should get cost</param>
 /// <returns>Cost</returns>
 protected virtual int GetCostFromTower(Tower tower)
 {
     return -tower.TowerPreferences[tower.Rank].SellCost;
 }