summaryrefslogtreecommitdiff
path: root/GameCode/BuildButtonUI.cs
blob: 86c77323816d6bd65d4782a3c5e6851730932744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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;
	}
}