/// <summary> /// Define the button information for the tower /// </summary> /// <param name="towerData"> /// The tower to initialize the button with /// </param> public void InitializeButton(TowerYfb towerData) { m_Tower = towerData; if (towerData.levels.Length > 0) { TowerLevelYfb firstTower = towerData.levels[0]; buttonText.text = firstTower.cost.ToString(); towerIcon.sprite = firstTower.levelData.icon; } else { Debug.LogWarning("[Tower Spawn Button] No level data for tower"); } if (LevelManagerYfb.instanceExists) { m_Currency = LevelManagerYfb.instance.currency; m_Currency.currencyChanged += UpdateButton; } else { Debug.LogWarning("[Tower Spawn Button] No level manager to get currency object"); } UpdateButton(); }
/// <summary> /// Draws the tower data on to the canvas, /// if the relevant text components are populated /// </summary> /// <param name="tower">The tower to gain info from</param> /// <param name="levelOfTower">The level of the tower</param> public void Show(TowerYfb tower, int levelOfTower) { if (levelOfTower >= tower.levels.Length) { return; } TowerLevelYfb towerLevel = tower.levels[levelOfTower]; DisplayText(towerName, tower.towerName); DisplayText(description, towerLevel.description); //DisplayText(dps, towerLevel.GetTowerDps().ToString("f2")); //DisplayText(health, string.Format("{0}/{1}", tower.configuration.currentHealth, towerLevel.maxHealth)); //DisplayText(level, (levelOfTower + 1).ToString()); //DisplayText(dimensions, string.Format("{0}, {1}", tower.dimensions.x, tower.dimensions.y)); //if (levelOfTower + 1 < tower.levels.Length) //{ // DisplayText(upgradeCost, tower.levels[levelOfTower + 1].cost.ToString()); //} //int sellValue = tower.GetSellLevel(levelOfTower); //DisplayText(sellPrice, sellValue.ToString()); }