Made the shop upgrades work

Click a shop upgrade to change its respective value and start a new wave
This commit is contained in:
2024-10-20 20:28:27 -07:00
parent 256b9ba569
commit 4a0eee9c38
5 changed files with 162 additions and 22 deletions

View File

@@ -2,15 +2,41 @@ using UnityEngine;
public class ShopButton : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public string upgrade;
void Start() {
GetComponent<UnityEngine.UI.Button>().onClick.AddListener(Upgrade);
}
void Upgrade() {
Teo player = GameObject.FindGameObjectWithTag("Player").GetComponent<Teo>();
GameState gameState =
GameObject
.FindGameObjectWithTag("GameController")
.GetComponent<GameState>();
if (upgrade == "attackRange") {
player.swingRange += 1;
}
else if (upgrade == "attackDistance") {
player.swingDistance += 30;
}
else if (upgrade == "attackDamage") {
player.damageStrength += 5;
}
else if (upgrade == "attackCooldown") {
player.attackCooldownSeconds -= 0.5F;
}
else if (upgrade == "maxHealth") {
player.health += 20;
player.maxHealth += 20;
}
else if (upgrade == "movementSpeed") {
player.moveSpeed += 5;
}
else if (upgrade == "dashDistance") {
player.dashDistance += 1;
}
else if (upgrade == "dashCooldown") {
player.dashCooldownSeconds -= 0.5F;
}
gameState.NewWave();
}
}