コード例 #1
0
 public void Upgrade()
 {
     if ((level + 1 <= maxLevel))
     {
         TowerLevel data = levelData[level - 1];
         level++;
         Range.AddModifer(data.RangeIncrease);
         Damage.AddModifer(data.DamageIncrease);
         FireRate.AddModifer(data.FireRateIncrease);
         hasPickedPerk = false;
         OnTowerChanged();
         UpdateSelectionCircleRadius();
     }
 }
コード例 #2
0
    private void UpdateUpgradePreviewStats()
    {
        var tower       = towerSelectSystem.GetSelectedTower();
        var upgradeData = tower.GetUpgradeData();

        Stat damage   = new Stat();
        Stat fireRate = new Stat();
        Stat range    = new Stat();

        damage.BaseValue   = tower.Damage.Value;
        fireRate.BaseValue = tower.FireRate.Value;
        range.BaseValue    = tower.Range.Value;

        float dmg  = damage.Value;
        float rate = fireRate.Value;
        float rng  = range.Value;

        damage.AddModifer(upgradeData.DamageIncrease);
        range.AddModifer(upgradeData.RangeIncrease);
        fireRate.AddModifer(upgradeData.FireRateIncrease);

        float deltaDmg      = damage.Value - dmg;
        float deltaFireRate = fireRate.Value - rate;
        float deltaRange    = range.Value - rng;

        deltaFireRate = (float)Math.Round((decimal)deltaFireRate, 2);

        string mathOp   = GetMathOperatorSymbolBasedOnValue(deltaDmg);
        string hexColor = GetHexColorFromDeltaValue(deltaDmg);

        damageText.SetText(damage.Value.ToString() + " (<#" + hexColor + ">" + mathOp + deltaDmg + "</color>)");

        mathOp   = GetMathOperatorSymbolBasedOnValue(deltaFireRate);
        hexColor = GetHexColorFromDeltaValue(deltaFireRate);

        fireRateText.SetText(fireRate.Value.ToString() + " (<#" + hexColor + ">" + mathOp + deltaFireRate + "</color>)");

        mathOp   = GetMathOperatorSymbolBasedOnValue(deltaRange);
        hexColor = GetHexColorFromDeltaValue(deltaRange);

        rangeText.SetText(range.Value.ToString() + " (<#" + hexColor + ">" + mathOp + deltaRange + "</color>)");
        tower.UpdateSelectionCircleRadius(range.Value);
    }