예제 #1
0
    //Initialise stat modifiers dictionary with base modifier value and subscribe to onDeath event
    protected void Awake()
    {
        onDeath += InvokeDeathEvent;  //Unsubscribe in OnDisable

        //Set ability costs
        abilityAmounts = new Dictionary <Abilities, float>();
        foreach (Abilities ability in Enum.GetValues(typeof(Abilities)))
        {
            if (GameMetaInfo._Is_Instant_Ability(ability))
            {
                abilityAmounts.Add(ability, instantAbilityAmount);
            }
            else if (GameMetaInfo._Is_AoE_Ability(ability))
            {
                abilityAmounts.Add(ability, areaAbilityAmount);
            }
            else if (GameMetaInfo._Is_Defense_Ability(ability))
            {
                abilityAmounts.Add(ability, areaAbilityAmount);
            }
        }

        //Initialise Stat Modifiers and Values - Stats Enum as key, Stat Class with type (Stats) and value - Default val: 1
        statModifiers = new Dictionary <Stats, Stat>();
        foreach (Stats stat in Enum.GetValues(typeof(Stats)))
        {
            Stat newStat = new Stat(stat, defaultModifierValue);
            statModifiers.Add(newStat.StatType, newStat);
        }
    }
예제 #2
0
    /// <summary>
    /// Calculates damage or heal amount based upon ability costs
    /// </summary>
    private float CalculateAbilDamage(Abilities ability)
    {
        float damage = 0f;

        //Damage dependent upon NPC ability cost, health, and then damage modifier. Increase in health/Decreases in cost will increase the damage the NPC can do.
        if (GameMetaInfo._Is_Instant_Ability(ability))
        {
            damage = instantAbilityAmount;
        }
        else if (GameMetaInfo._Is_AoE_Ability(ability))
        {
            damage = areaAbilityAmount;
        }
        else if (GameMetaInfo._Is_Defense_Ability(ability))
        {
            damage = defenseAbilityAmount;
        }
        damage /= 2;

        damage *= statModifiers[Stats.DamageModifier].StatValue;
        return(damage);
    }