Ejemplo n.º 1
0
 void CheckUpgradeButtonBudget(UpgradeButtonBehaviour button, WeaponUpgradableAttributes.WeaponAttribute upgrade)
 {
     if (PlayerStats.Money < upgrade.upgradeCurrentPrice)
     {
         button.gameObject.GetComponent <Button>().interactable = false;
     }
     else
     {
         button.gameObject.GetComponent <Button>().interactable = true;
     }
 }
    void Awake()
    {
        gameManager = GameManager.instance;
        var upgradePanel = transform.Find("UpgradeButtons");

        damageButton      = upgradePanel.Find("Damage").GetComponent <UpgradeButtonBehaviour>();
        speedButton       = upgradePanel.Find("Speed").GetComponent <UpgradeButtonBehaviour>();
        healthButton      = upgradePanel.Find("Health").GetComponent <UpgradeButtonBehaviour>();
        rangeButton       = upgradePanel.Find("Range").GetComponent <UpgradeButtonBehaviour>();
        attackSpeedButton = upgradePanel.Find("AttackSpeed").GetComponent <UpgradeButtonBehaviour>();
        aimingSpeedButton = upgradePanel.Find("AimingSpeed").GetComponent <UpgradeButtonBehaviour>();

        //keep upgrade button and related weapon upgrade attribute together
        buttonsWithWeaponAttributes = new Dictionary <UpgradeButtonBehaviour, WeaponUpgradableAttributes.WeaponAttribute>()
        {
            { damageButton, weaponPrefab.GetUpgradableAttributes().damage },
            { speedButton, weaponPrefab.GetUpgradableAttributes().speed },
            { healthButton, weaponPrefab.GetUpgradableAttributes().health },
            { rangeButton, weaponPrefab.GetUpgradableAttributes().range },
            { attackSpeedButton, weaponPrefab.GetUpgradableAttributes().attackSpeed },
            { aimingSpeedButton, weaponPrefab.GetUpgradableAttributes().aimingSpeed }
        };
    }