Ejemplo n.º 1
0
    public void UpgradeStatus(string _status)
    {
        Dictionary <string, int> upgrades = UpgradeHandler.data.towerUpgrades[turretSelected.name];

        if (upgrades[_status] < 3 && upgradesPrice[_status] <= UpgradeHandler.data.playerStats["Coins"])
        {
            upgrades[_status]++;
            UpgradeHandler.data.playerStats["Coins"] -= upgradesPrice[_status];
            upgradeStatus = status[_status].GetComponent <UpgradeStatus>();
            upgradeStatus.UpdateUpgradeStatus(upgrades[_status]);
            Debug.Log(turretSelected.name + ": " + _status + ": " + upgrades[_status]);
            UpgradeHandler.instance.SaveData();
            foreach (string item in activeStatus)
            {
                if (upgradesPrice[item] > UpgradeHandler.data.playerStats["Coins"])
                {
                    status[item].GetComponentInChildren <Button>().interactable = false;
                }
                else
                {
                    status[item].GetComponentInChildren <Button>().interactable = true;
                }
            }
            totalStars.text = UpgradeHandler.data.playerStats["TotalStars"].ToString();
            totalCoins.text = UpgradeHandler.data.playerStats["Coins"].ToString();
        }
    }
Ejemplo n.º 2
0
    public void SelectTurret(int i)
    {
        activeStatus       = new List <string>();
        turretSelected     = allTurrets[i];
        turretImage.sprite = turretSelected.sprite;
        turretName.text    = turretSelected.name;
        Dictionary <string, int> upgrades = UpgradeHandler.data.towerUpgrades[turretSelected.name];
        int coins = UpgradeHandler.data.playerStats["Coins"];

        foreach (string item in status.Keys)
        {
            status[item].gameObject.SetActive(false);
        }
        foreach (string item in upgrades.Keys)
        {
            status[item].gameObject.SetActive(true);
            activeStatus.Add(item);
            upgradeStatus = status[item].GetComponent <UpgradeStatus>();
            upgradeStatus.UpdateUpgradeStatus(upgrades[item], upgradesPrice[item]);
            if (upgradesPrice[item] > UpgradeHandler.data.playerStats["Coins"])
            {
                upgradeStatus.GetComponentInChildren <Button>().interactable = false;
            }
            else
            {
                upgradeStatus.GetComponentInChildren <Button>().interactable = true;
            }
        }
    }