summaryrefslogtreecommitdiff
path: root/Assembly_CSharp/UI/BuildButtonUI.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-11-26 23:52:30 +0800
committerchai <215380520@qq.com>2023-11-26 23:52:30 +0800
commit626381f061cde0c78564f6336e3131835cf20a5b (patch)
treed9991d6eda6ae5d7649ac91ecaa3b4dc833cd4c3 /Assembly_CSharp/UI/BuildButtonUI.cs
parent0e63c4a2c6dec8dfa260501fb7d73750261ea7b7 (diff)
* move
Diffstat (limited to 'Assembly_CSharp/UI/BuildButtonUI.cs')
-rw-r--r--Assembly_CSharp/UI/BuildButtonUI.cs107
1 files changed, 107 insertions, 0 deletions
diff --git a/Assembly_CSharp/UI/BuildButtonUI.cs b/Assembly_CSharp/UI/BuildButtonUI.cs
new file mode 100644
index 0000000..86c7732
--- /dev/null
+++ b/Assembly_CSharp/UI/BuildButtonUI.cs
@@ -0,0 +1,107 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+public class BuildButtonUI : MonoBehaviour
+{
+ [SerializeField]
+ private GameObject tower;
+
+ [SerializeField]
+ private TowerFlyweight towerFlyweight;
+
+ [SerializeField]
+ private Text priceTag;
+
+ [SerializeField]
+ private Text modifiersText;
+
+ [SerializeField]
+ private TowerType myTowerType;
+
+ private void Start()
+ {
+ priceTag.text = towerFlyweight.currentPrice + "g";
+ UpdateModifiersText();
+ }
+
+ public void Build()
+ {
+ BuildingManager.instance.EnterBuildMode(tower, towerFlyweight.currentPrice, towerFlyweight.priceIncrease, myTowerType);
+ }
+
+ public void UpdatePriceText()
+ {
+ priceTag.text = towerFlyweight.currentPrice + "g";
+ }
+
+ public void UpdateModifiersText()
+ {
+ if (!(modifiersText != null))
+ {
+ return;
+ }
+ string text = "";
+ if (TowerManager.instance.GetBonusBaseDamage(myTowerType) > 0)
+ {
+ text = text + "\n+" + TowerManager.instance.GetBonusBaseDamage(myTowerType) + " Base Damage";
+ }
+ if (TowerManager.instance.GetBonusBaseDamage(myTowerType) < 0)
+ {
+ text = text + "\n" + TowerManager.instance.GetBonusBaseDamage(myTowerType) + " Base Damage";
+ }
+ if (TowerManager.instance.GetBonusHealthDamage(myTowerType) > 0)
+ {
+ text = text + "\n+" + TowerManager.instance.GetBonusHealthDamage(myTowerType) + " Health Damage";
+ }
+ if (TowerManager.instance.GetBonusArmorDamage(myTowerType) > 0)
+ {
+ text = text + "\n+" + TowerManager.instance.GetBonusArmorDamage(myTowerType) + " Armor Damage";
+ }
+ if (TowerManager.instance.GetBonusShieldDamage(myTowerType) > 0)
+ {
+ text = text + "\n+" + TowerManager.instance.GetBonusShieldDamage(myTowerType) + " Shield Damage";
+ }
+ if (TowerManager.instance.GetCritChance(myTowerType) + TowerManager.instance.GetCritChanceLevelMultiplier(myTowerType) > 0f)
+ {
+ text = text + "\n+(" + (int)(TowerManager.instance.GetCritChance(myTowerType) * 100f);
+ if (TowerManager.instance.GetCritChanceLevelMultiplier(myTowerType) > 1f)
+ {
+ text = text + " + " + (int)TowerManager.instance.GetCritChanceLevelMultiplier(myTowerType) + "xLvl";
+ }
+ else if (TowerManager.instance.GetCritChanceLevelMultiplier(myTowerType) > 0f)
+ {
+ text += " + level";
+ }
+ text += ")% Crit";
+ }
+ if (TowerManager.instance.GetStunChance(myTowerType) > 0f)
+ {
+ text = text + "\n+" + Mathf.FloorToInt(TowerManager.instance.GetStunChance(myTowerType) * 101f) + "% Freeze Chance";
+ }
+ if (TowerManager.instance.GetBonusRange(myTowerType) > 0f)
+ {
+ text = text + "\n+" + TowerManager.instance.GetBonusRange(myTowerType) + " Range";
+ }
+ if (TowerManager.instance.GetBonusBlast(myTowerType) > 0f)
+ {
+ text = text + "\n+" + (int)(TowerManager.instance.GetBonusBlast(myTowerType) * 100f) + "% Blast Radius";
+ }
+ if (TowerManager.instance.GetBonusSlow(myTowerType) > 0f)
+ {
+ text = text + "\n+" + (int)(TowerManager.instance.GetBonusSlow(myTowerType) * 100f) + "% Slow";
+ }
+ if (TowerManager.instance.GetBonusBleed(myTowerType) > 0f)
+ {
+ text = text + "\n+" + (int)(TowerManager.instance.GetBonusBleed(myTowerType) * 100f) + "% Bleed";
+ }
+ if (TowerManager.instance.GetBonusBurn(myTowerType) > 0f)
+ {
+ text = text + "\n+" + (int)(TowerManager.instance.GetBonusBurn(myTowerType) * 100f) + "% Burn";
+ }
+ if (TowerManager.instance.GetBonusPoison(myTowerType) > 0f)
+ {
+ text = text + "\n+" + (int)(TowerManager.instance.GetBonusPoison(myTowerType) * 100f) + "% Poison";
+ }
+ modifiersText.text = text;
+ }
+}