Example #1
0
    private float GetPerkValue(DevPAPerk currentPerk, PAPerk perk)
    {
        // Gauss formula => 1 + 2 + 3 + ... + n = n * (n + 1) / 2
        float sumValuesUntilLevel = (perk.Points - 1) * perk.Points / 2;
        // 1 * x + 2 * x + ... + n * x = (1 + 2 + 3 + ... + n) * x
        int   precentAccelerationPerUpgrade = 0;//CurrentPerk.PrecentAccelerationPerUpgrade;
        float accelerationPoint             = sumValuesUntilLevel * precentAccelerationPerUpgrade;

        float percentValue = currentPerk.StartingValue + perk.Points * currentPerk.PrecentPerUpgrade + accelerationPoint;

        return(percentValue);
    }
Example #2
0
File: CrateUI.cs Project: Tzook/lel
    public void Set(string perkKey, PAPerk currentAbilityPerk = null)
    {
        Debug.Log("SD" + perkKey);
        CurrentPerk = Content.Instance.GetPerk(perkKey);

        m_Image.sprite = CurrentPerk.Icon;

        m_Animator.SetTrigger("Reset");

        int   precentAccelerationPerUpgrade = 0;//CurrentPerk.PrecentAccelerationPerUpgrade;
        float PercentValue = CurrentPerk.PrecentPerUpgrade + precentAccelerationPerUpgrade * (currentAbilityPerk == null ? 0 : currentAbilityPerk.Points);

        m_Title.text = PerkValueFormatter.Instance.GetFormattedValue(CurrentPerk, PercentValue, true) + " " + CurrentPerk.Name;
    }
Example #3
0
    public void SetInfo(DevAbility devPA, PAPerk perk)
    {
        currentPerk = Content.Instance.GetPerk(perk.Key);
        bool isInitialValue = Content.Instance.IsInitialPerkValue(devPA, perk);

        txtTitle.text    = currentPerk.Name;
        iconImage.sprite = currentPerk.Icon;

        float percentValue = GetPerkValue(currentPerk, perk);

        txtPrecent.text = PerkValueFormatter.Instance.GetFormattedValue(currentPerk, percentValue, false);

        txtPrecent.color = isInitialValue ? initialPerkColor : originalTextColor;
    }
Example #4
0
    public void SetStats(ItemInfo itemInfo)
    {
        ItemStatUI statsInfoObject;

        if (itemInfo.Stats.JumpBonus > 0)
        {
            statsInfoObject = GetStatsInfoObject();
            statsInfoObject.SetInfo("+" + itemInfo.Stats.JumpBonus + " Jumping Bonus", ResourcesLoader.Instance.GetSprite("fx_hit01"), bonusColor);
        }

        if (itemInfo.Stats.SpeedBonus > 0)
        {
            statsInfoObject = GetStatsInfoObject();
            statsInfoObject.SetInfo("+" + itemInfo.Stats.SpeedBonus + " Speed Bonus", ResourcesLoader.Instance.GetSprite("fx_hit01"), bonusColor);
        }

        if (itemInfo.Stats.RequiresLVL > 0)
        {
            statsInfoObject = GetStatsInfoObject();
            statsInfoObject.transform.localScale = Vector3.one;
            Color minLevelColor = itemInfo.Stats.RequiresLVL > LocalUserInfo.Me.ClientCharacter.LVL ? requiredColor : bonusColor;
            statsInfoObject.SetInfo("Minimum Level " + itemInfo.Stats.RequiresLVL, ResourcesLoader.Instance.GetSprite("fx_hit_small"), minLevelColor);
        }

        foreach (DevPerkMap perkMap in itemInfo.Perks)
        {
            statsInfoObject = GetStatsInfoObject();
            DevPAPerk perkRef = Content.Instance.GetPerk(perkMap.Key);

            string perkText   = PerkValueFormatter.Instance.GetFormattedValue(perkRef, perkMap.Value, true) + " " + perkRef.Name;
            bool   isGoodPerk = perkRef.PrecentPerUpgrade > 0 ? perkMap.Value > 0 : perkMap.Value < 0;
            Color  color      = isGoodPerk ? bonusColor : requiredColor;
            statsInfoObject.SetInfo(perkText, perkRef.Icon, color);
        }

        if (itemInfo.UseInfo.BonusHP > 0)
        {
            statsInfoObject = GetStatsInfoObject();
            statsInfoObject.SetInfo("+" + itemInfo.UseInfo.BonusHP + " HP", Content.Instance.GetPerk("hpBonus").Icon, bonusColor);
        }
        if (itemInfo.UseInfo.BonusMP > 0)
        {
            statsInfoObject = GetStatsInfoObject();
            statsInfoObject.SetInfo("+" + itemInfo.UseInfo.BonusMP + " MP", Content.Instance.GetPerk("mpBonus").Icon, bonusColor);
        }
    }
Example #5
0
    public void GainPerk(string perkKey)
    {
        PAPerk    tempPerk = GetPerk(perkKey);
        DevPAPerk perkRef  = Content.Instance.GetPerk(perkKey);

        if (tempPerk != null)
        {
            tempPerk.Points++;
        }
        else
        {
            tempPerk = new PAPerk();

            tempPerk.Key    = perkRef.Key;
            tempPerk.Points = 1;

            Perks.Add(tempPerk.Key, tempPerk);
        }
    }
Example #6
0
    public string GetFormattedValue(DevPAPerk perkInfo, float perkValue, bool includePrefix)
    {
        string prefix = includePrefix && perkValue >= 0 ? "+" : "";
        string suffix = "";

        if (perkInfo.PerkType == DevPAPerk.PerkTypeEnum.Percent)
        {
            perkValue *= 100f;
            suffix     = "%";
        }
        else if (perkInfo.PerkType == DevPAPerk.PerkTypeEnum.Time)
        {
            suffix = "s";
        }
        bool   hasFloatingPoint = perkValue % 1 == 0;
        string showValue        = (hasFloatingPoint ? Mathf.FloorToInt(perkValue) : perkValue).ToString();

        return(prefix + showValue + suffix);
    }