當前位置: 首頁>>代碼示例>>C#>>正文


C# Ability.getAbilityClass方法代碼示例

本文整理匯總了C#中Ability.getAbilityClass方法的典型用法代碼示例。如果您正苦於以下問題:C# Ability.getAbilityClass方法的具體用法?C# Ability.getAbilityClass怎麽用?C# Ability.getAbilityClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ability的用法示例。


在下文中一共展示了Ability.getAbilityClass方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: calculateBaseDamage

    public Damage calculateBaseDamage(Ability.IAbility ability)
    {
        int str = 0;

        float damageModifier = ability.getDamageModifier();
        string damageType = ability.getAbilityClass();
        bool crit;
        float critProb = 0.0f;
        float critMultiplier;

        switch (damageType)
        {
            case "Physical":
                str = strength;
                critMultiplier = 1.5f;
                critProb = getBasePhysicalCritProbability();
                break;

            case "Fire":
                str = magic;
                critMultiplier = 1.2f;
                critProb = getBaseMagicCritProbability();
                break;

            case "Ice":
                str = magic;
                critMultiplier = 1.2f;
                critProb = getBaseMagicCritProbability();
                break;

            case "Light":
                str = spirit;
                critMultiplier = 1.2f;
                critProb = getBaseMagicCritProbability();
                break;

            case "Poison":
                str = magic;
                critMultiplier = 1.2f;
                critProb = getBaseMagicCritProbability();
                break;

            case "Ignore":
                return new Damage(0, false);

            default:
                throw new System.NotImplementedException();

        }

        float rand = Random.Range(0.0f, 1.0f);

        crit = critProb > rand ? true : false;
        critMultiplier = crit ? 1.5f : 1.0f;

        return new Damage((int)(((str * str * str) / 32 + 32) * damageModifier * critMultiplier * Random.Range(0.8f, 1.2f)), crit);
    }
開發者ID:sjai013,項目名稱:RPG,代碼行數:57,代碼來源:CharacterStats.cs

示例2: takeGeneralDamage

    public virtual void takeGeneralDamage(Damage damage, Ability.IAbility  ability, IBattleCharacter source)
    {
        if (ability.getStatusEffectTypes() != null)
        {
            addStatusEffect(ability.getStatusEffectTypes());
        }

        if (this.getCharStats().targetCurHP <= 0)
            return;

        float modifier = UnityEngine.Random.Range(0.9f, 1.1f);
        damage.actualDamage = (int)((float)playerStats.calculateDamageTaken(damage.baseDamage, ability.getAbilityClass()) * modifier);
        takeDamage(damage, ability.show0Damage(), ability.timeToDamage());
    }
開發者ID:sjai013,項目名稱:RPG,代碼行數:14,代碼來源:Player.cs


注:本文中的Ability.getAbilityClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。