public override void PreviewUpgrade(int id)
    {
        this.turretInfo.ResetTempStats();

        TurretUpgrade upgrade = GetUpgradeById(id);

        if (id == 0)
        {
            this.turretInfo.SetTempStat(0, Mathf.RoundToInt(upgrade.value * 100f) + "%");
        }
        else if (id == 1)
        {
            this.turretInfo.SetTempStat(1, Mathf.RoundToInt(upgrade.value) + "-" + Mathf.RoundToInt(this.durationHighUpgrades[this.durationLevel + 1].value) + "s");
        }

        if (upgrade == null)
        {
            this.costIndicator.gameObject.SetActive(false);
        }
        else
        {
            this.costIndicator.gameObject.SetActive(true);
            this.costIndicator.SetCost(upgrade.tokenCost, upgrade.goldCost);
        }
    }
Example #2
0
    public override void PreviewUpgrade(int id)
    {
        this.turretInfo.ResetTempStats();
        CircleDrawer.instance.DisableSecondary();

        TurretUpgrade upgrade = GetUpgradeById(id);

        if (id == 0)
        {
            this.turretInfo.SetTempStat(0, upgrade.value.ToString("0.0"));
        }
        else if (id == 1)
        {
            this.turretInfo.SetTempStat(1, upgrade.value.ToString("0.0") + "s");
        }
        else if (id == 2)
        {
            CircleDrawer.instance.DrawSecondary(upgrade.value);
        }

        if (upgrade == null)
        {
            this.costIndicator.gameObject.SetActive(false);
        }
        else
        {
            this.costIndicator.gameObject.SetActive(true);
            this.costIndicator.SetCost(upgrade.tokenCost, upgrade.goldCost);
        }
    }
Example #3
0
    public override void PreviewUpgrade(int id)
    {
        this.turretInfo.ResetTempStats();

        TurretUpgrade upgrade = GetUpgradeById(id);

        if (id == 0)
        {
            this.turretInfo.SetTempStat(0, this.damageLowUpgrades[this.damageLevel + 1].value.ToString("0") + "-" + this.damageHighUpgrades[this.damageLevel + 1].value.ToString("0"));
        }
        else if (id == 1)
        {
            this.turretInfo.SetTempStat(1, this.blastRadiusUpgrades[this.blastRadiusLevel + 1].value.ToString("0.0"));
        }

        if (upgrade == null)
        {
            this.costIndicator.gameObject.SetActive(false);
        }
        else
        {
            this.costIndicator.gameObject.SetActive(true);
            this.costIndicator.SetCost(upgrade.tokenCost, upgrade.goldCost);
        }
    }
Example #4
0
 private void UpdateUI(TurretUpgrade upgrade, UpgradePath upgradePath)
 {
     if (upgradePath == UpgradePath.Left)
     {
         // Set the icon
         if (leftPathNextUpgradeIndex >= leftUpgrades.Length)
         {
             leftUpgradeButton.image.sprite = noUpgradesRemainingIcon;
             leftUpgradeButton.interactable = false;
             leftUpgradeCostText.gameObject.SetActive(false);
         }
         else
         {
             leftUpgradeButton.image.sprite = upgrade.icon;
             leftUpgradeCostText.text       = "$" + upgrade.cost;
         }
     }
     else if (upgradePath == UpgradePath.Right)
     {
         // Set the icon
         if (rightPathNextUpgradeIndex >= rightUpgrades.Length)
         {
             rightUpgradeButton.image.sprite = noUpgradesRemainingIcon;
             rightUpgradeButton.interactable = false;
             rightUpgradeCostText.gameObject.SetActive(false);
         }
         else
         {
             rightUpgradeButton.image.sprite = upgrade.icon;
             rightUpgradeCostText.text       = "$" + upgrade.cost;
         }
     }
 }
Example #5
0
        private void TryUpgradePath(UpgradePath upgradePath)
        {
            TurretUpgrade upgrade = null;

            if (upgradePath == UpgradePath.Left && leftPathNextUpgradeIndex < leftUpgrades.Length)
            {
                upgrade = leftUpgrades[leftPathNextUpgradeIndex];
            }
            else if (upgradePath == UpgradePath.Right && rightPathNextUpgradeIndex < rightUpgrades.Length)
            {
                upgrade = rightUpgrades[rightPathNextUpgradeIndex];
            }

            if (upgrade != null && moneyManager.HasEnoughMoneyForPurchase(upgrade.cost))
            {
                moneyManager.Money -= upgrade.cost;
                upgrade.ApplyToTurret(turret);

                if (upgradePath == UpgradePath.Left)
                {
                    leftPathNextUpgradeIndex++;
                }
                else if (upgradePath == UpgradePath.Right)
                {
                    rightPathNextUpgradeIndex++;
                }

                UpdateUI(upgrade, upgradePath);
            }
        }
Example #6
0
    void enableTurretUpgrade(TurretUpgrade upgrade)
    {
        upgrade.CurrentUsages++;
        addStatsToTurret(upgrade.StatChanges, upgrade.TurretToUpgrade.TurretInfo);

        UI.UpdateTurretInfo(upgrade.TurretToUpgrade.TurretInfo);
    }
Example #7
0
    public override void Upgrade(int id)
    {
        TurretUpgrade upgrade = GetUpgradeById(id);

        if (upgrade == null)
        {
            return;
        }

        if (!this.level.TakeTokensAndGold(upgrade.tokenCost, upgrade.goldCost))
        {
            return;
        }

        if (id == 0)
        {
            this.damageLevel++;
            this.damage = this.damageUpgrades[this.damageLevel].value;
            SetStats();

            if (this.damageLevel == this.damageUpgrades.Length - 1)
            {
                this.upgradeDialog.buttons[0].gameObject.SetActive(false);
            }
        }
        else if (id == 1)
        {
            this.fireRateLevel++;
            this.fireRate = this.fireRateUpgrades[this.fireRateLevel].value;
            SetStats();

            if (this.fireRateLevel == this.fireRateUpgrades.Length - 1)
            {
                this.upgradeDialog.buttons[1].gameObject.SetActive(false);
            }
        }
        else if (id == 2)
        {
            this.rangeLevel++;
            this.radius = this.rangeUpgrades[this.rangeLevel].value;
            CircleDrawer.instance.Draw(this.transform.position, this.radius);

            if (this.rangeLevel == this.rangeUpgrades.Length - 1)
            {
                this.upgradeDialog.buttons[2].gameObject.SetActive(false);
            }
        }

        this.turretLevel++;
        this.turretInfo.SetLevel(this.turretLevel);
        if (this.turretLevel == 4)
        {
            this.upgradeDialog.buttons[0].gameObject.SetActive(false);
            this.upgradeDialog.buttons[1].gameObject.SetActive(false);
            this.upgradeDialog.buttons[2].gameObject.SetActive(false);
        }

        CloseUpgradeDialog();
    }
    public override void Upgrade(int id)
    {
        TurretUpgrade upgrade = GetUpgradeById(id);

        if (upgrade == null)
        {
            return;
        }

        if (!Level.instance.TakeTokensAndGold(upgrade.tokenCost, upgrade.goldCost))
        {
            return;
        }

        if (id == 0)
        {
            this.amountLevel++;
            this.amount = this.amountUpgrades[this.amountLevel].value;
            SetStats();

            if (this.amountLevel == this.amountUpgrades.Length - 1)
            {
                this.upgradeDialog.buttons[0].gameObject.SetActive(false);
            }
        }
        else if (id == 1)
        {
            this.durationLevel++;
            this.minDuration = this.durationLowUpgrades[this.durationLevel].value;
            this.maxDuration = this.durationHighUpgrades[this.durationLevel].value;
            SetStats();

            if (this.durationLevel == this.durationLowUpgrades.Length - 1)
            {
                this.upgradeDialog.buttons[1].gameObject.SetActive(false);
            }
        }

        this.turretLevel++;
        this.turretInfo.SetLevel(this.turretLevel);
        if (this.turretLevel == 3)
        {
            this.upgradeDialog.buttons[0].gameObject.SetActive(false);
            this.upgradeDialog.buttons[1].gameObject.SetActive(false);
        }

        CloseUpgradeDialog();
    }
Example #9
0
    public void Upgrade(placementPanel panel, TurretUpgrade tu)
    {
        //Set the reference for the panel asking to upgrade
        UpgradeGUI.GetComponent<GUIRef>().GUIReference = panel;
        upgradeCostGUIText.text = "$" + tu.CostOfUpgrade().ToString();

        if (GM.GetCash() >= tu.CostOfUpgrade())
        {
            if (tu.CostOfUpgrade() == 0)
            {
                textTitle.text = "This turret is Max Level";
                upgradeCostGUIText.text = "";
                upgradeGUIConfirmButton.interactable = false;
            }
            else
            {
                textTitle.text = textTitleInitialValue;
                upgradeGUIConfirmButton.interactable = true;
            }
        }
        else
        {
            upgradeGUIConfirmButton.interactable = false;
        }

        DisableButtons();
        UpgradeGUI.SetActive(true);
    }