-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShopManager.cs
58 lines (46 loc) · 1.24 KB
/
ShopManager.cs
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
using UnityEngine.UI;
using UnityEngine;
public class ShopManager : MonoBehaviour {
PlayerStats playerStats;
[SerializeField]
int firerateCost = 500;
[SerializeField]
int damageCost = 5000;
[SerializeField]
int speedCost = 1000;
[SerializeField]
Text moneyText;
// Use this for initialization
void Start () {
playerStats = GameObject.FindGameObjectWithTag("GameController").GetComponent<PlayerStats>();
}
public void ChangeMoney(int amount)
{
playerStats.money += amount;
moneyText.text = playerStats.money + "$";
}
public void upgradeFirerate(float amount)
{
if (playerStats.money >= firerateCost)
{
playerStats.fireDelay -= amount;
ChangeMoney(-firerateCost);
}
}
public void UpgradeDamage(int amount)
{
if (playerStats.money >= damageCost)
{
playerStats.damage += amount;
ChangeMoney(-damageCost);
}
}
public void UpgradeSpeed(float amount)
{
if (playerStats.money >= speedCost)
{
playerStats.speed += amount;
ChangeMoney(-speedCost);
}
}
}