コード例 #1
0
    //TODO Rework this, so it makes more sense
    //This is where the AC should be calculated?
    public void OnHit(AbilityEffects effect)
    {
        bool wasHit = effect.hitInfo.isHit;

        healthBar.OnHit(effect.hitInfo);
        stats.ModifyHealth(effect.hitInfo);
    }
コード例 #2
0
ファイル: Health.cs プロジェクト: caesuric/familiar-quest
    public void ApplyEffectsFromAttack(Character attacker, AttackAbility ability, float damage, Transform projectileTransform)
    {
        Dictionary <string, Effect> effects = SetUpEffectDictionary(attacker, ability, damage, projectileTransform);
        int count = 0;

        foreach (var attribute in ability.attributes)
        {
            if (effects.ContainsKey(attribute.type) && attribute.priority >= 50 && count < 4)
            {
                effects[attribute.type](attribute);
            }
            count++;
        }
        if (attacker != null && attacker.GetComponent <AbilityUser>().HasPassive("knockback"))
        {
            AbilityEffects.KnockbackDefault(attacker, GetComponent <Character>());
        }
        if (attacker != null && attacker.GetComponent <AbilityUser>().HasPassive("pullEnemies"))
        {
            AbilityEffects.PullTowardsDefault(attacker, GetComponent <Character>());
        }
        if (ability.FindAttribute("createDamageZone") == null && ability.dotDamage > 0)
        {
            GetComponent <StatusEffectHost>().AddStatusEffect("dot", ability.dotTime, degree: ability.CalculateDotDamage(attacker), inflicter: attacker, ability: ability);
        }
    }
コード例 #3
0
        public void AddEffect(AbilityEffects effect)
        {
            if (effect == null)
            {
                return;
            }
            int numberOfStack = 0;

            for (int i = 0; i < listEffects.Count; i++)
            {
                if (listEffects[i].Index == effect.Index && listEffects[i].groupEffect == effect.groupEffect)
                {
                    numberOfStack++;
                    if (listEffects[i].StackMode == StackModeEnum.ResetTime)
                    {
                        listEffects[i].EffectDuration = effect.EffectDuration;
                    }
                }
            }
            if (numberOfStack < effect.MaxOfStacks)
            {
                listEffects.Add(effect);
                effect.targetUnit = this;
                effect.OnAddAbilityEffects();
            }
        }
コード例 #4
0
    // runs debuff & buffs
    IEnumerator RunAbilityEffects(AbilityEffects effects, Piece source, Piece target, AbilityTarget abilityTarget)
    {
        //stat boosting
        if (effects.Boosts != null)
        {
            if (abilityTarget == AbilityTarget.Self)
            {
                source.ApplyBoost(effects.Boosts);
            }
            else
            {
                target.ApplyBoost(effects.Boosts);
            }
        }

        // cheecks to see what type of status condtion effect
        if (effects.Status != ConditionID.none)
        {
            target.SetStatus(effects.Status);
        }

        // cheecks to see what type of volatile status condtion effect
        if (effects.VolatileStatus != ConditionID.none)
        {
            target.SetVolatileStatus(effects.VolatileStatus);
        }

        //calls function to show after applying stat
        yield return(ShowStatusChanges(source));

        yield return(ShowStatusChanges(target));
    }
コード例 #5
0
    /// <summary>
    /// Calculates the damage bonus from an effect
    /// </summary>
    /// <param name="effect">The current effect</param>
    /// <param name="caster">The caster of the effect</param>
    /// <returns>A floored value of the damage bonuses</returns>
    public static int GetDamageBonus(AbilityEffects effect, ICharacter caster)
    {
        int mod = caster.stats.GetTempDamageBonus();

        for (int i = 0; i < effect.damageRollModifiers.Length; i++)
        {
            if (effect.damageRollModifiers[i].isApplied)
            {
                mod += effect.damageRollModifiers[i].GetModifier(caster.stats.GetModifierFromName(effect.damageRollModifiers[i].modifierType));
            }
        }
        return(Mathf.FloorToInt(mod));
    }
コード例 #6
0
    /// <summary>
    /// Used to apply combat effects, such as damage, healing, damage over time, ad other status effects.
    /// </summary>
    /// <param name="effect"></param>
    public void ApplyEffect(AbilityEffects effect)
    {
        switch (effect.hitType)
        {
        case HitType.Hit:
            effect.hitInfo.hitValue = ReduceDamage(effect.hitInfo.hitValue, effect.abilityType);
            OnHit(effect);
            break;

        case HitType.Heal:
            OnHit(effect);
            //Add eventual heal mods
            break;

        case HitType.DoT:

            AddNewStatusEffect(effect.statusEffect);

            //    currentEffects[currentEffects.Count-1].InitialEffect();

            //Check type
            healthBar.ApplyBleed((BleedStatus)effect.statusEffect);
            break;

        case HitType.HoT:

            AddNewStatusEffect(effect.statusEffect);

            // currentEffects[currentEffects.Count - 1].InitialEffect();

            //Check type
            healthBar.ApplyHoT((HealOverTimeStatus)effect.statusEffect);
            break;

        case HitType.StatusEffect:


            AddNewStatusEffect(effect.statusEffect);



            //   currentEffects[currentEffects.Count - 1].InitialEffect();
            break;

        //Status effect type
        default:
            Debug.Log("defaulting the ability effect");
            OnHit(effect);
            break;
        }
    }
コード例 #7
0
/*---------------------------------------------------------------------------------------
*  --  FUNCTION:   addExp
*  --
*  --  DATE:       March 28, 2019
*  --
*  --  REVISIONS:
*  --
*  --  DESIGNER:   Ziqian Zhang
*  --
*  --  PROGRAMMER: Ziqian Zhang
*  --
*  --  INTERFACE:  public void addExp (Player player, int exp)
*  --                  player: the player who need to add EXP
*  --                  exp: the exp need to be added
*  --
*  --  RETURNS:    void
*  --
*  --  NOTES:  This is helper function to add exp to player
*  --
*  ---------------------------------------------------------------------------------------*/

        public void addExp(Player player, int exp)
        {
            int preLevel = GameUtility.currentLevel(player.Experience);

            player.Experience += exp;
            int afterLevel = GameUtility.currentLevel(player.Experience);

            if (afterLevel > preLevel)
            {
                //levelUp, skill change
                player.Level++;
                int newSkillId = AbilityEffects.ReturnRandomAbilityId(player);
                while (player.HasAbility((AbilityType)newSkillId))
                {
                    newSkillId = AbilityEffects.ReturnRandomAbilityId(player);
                }
                player.AddAbility(afterLevel, (AbilityType)newSkillId);
                OutgoingReliableElements.Enqueue(new AbilityAssignmentElement(player.ActorId, newSkillId));
            }
        }
コード例 #8
0
ファイル: Health.cs プロジェクト: caesuric/familiar-quest
 private Dictionary <string, Effect> SetUpEffectDictionary(Character attacker, AttackAbility ability, float damage, Transform projectileTransform)
 {
     return(new Dictionary <string, Effect>()
     {
         { "lifeleech", (AbilityAttribute attribute) => AbilityEffects.Lifeleech(attacker, GetComponent <Character>(), damage, attribute) },
         { "paralyze", (AbilityAttribute attribute) => AbilityEffects.Paralyze(attacker, GetComponent <Character>(), attribute) },
         { "blind", (AbilityAttribute attribute) => AbilityEffects.Blind(attacker, GetComponent <Character>(), attribute) },
         { "knockback", (AbilityAttribute attribute) => AbilityEffects.Knockback(attacker, GetComponent <Character>(), attribute) },
         { "jumpBack", (AbilityAttribute attribute) => AbilityEffects.JumpBack(attacker, GetComponent <Character>(), attribute) },
         { "pullTowards", (AbilityAttribute attribute) => AbilityEffects.PullTowards(attacker, GetComponent <Character>(), attribute) },
         { "mpOverTime", (AbilityAttribute attribute) => AbilityEffects.MpOverTime(attacker, attribute) },
         { "elementalDamageBuff", (AbilityAttribute attribute) => AbilityEffects.ElementalDamageBuff(attacker, attribute) },
         { "blunting", (AbilityAttribute attribute) => AbilityEffects.Blunting(ability, attacker, GetComponent <Character>(), attribute) },
         { "inflictVulnerability", (AbilityAttribute attribute) => AbilityEffects.InflictVulnerability(GetComponent <Character>(), attribute) },
         { "delay", (AbilityAttribute attribute) => AbilityEffects.Delay(attacker, GetComponent <Character>(), ability, damage, attribute) },
         { "damageShield", (AbilityAttribute attribute) => AbilityEffects.DamageShield(attacker, ability, attribute) },
         { "restoreMP", (AbilityAttribute attribute) => AbilityEffects.RestoreMp(attacker, attribute) },
         { "removeDebuff", (AbilityAttribute attribute) => AbilityEffects.RemoveDebuff(attacker, ability, attribute) },
         { "addedDot", (AbilityAttribute attribute) => AbilityEffects.AddedDot(attacker, GetComponent <Character>(), ability, attribute) },
         { "speed-", (AbilityAttribute attribute) => AbilityEffects.SpeedMinus(GetComponent <Character>(), attribute) },
         { "steal", (AbilityAttribute attribute) => AbilityEffects.AttrSteal(attacker, GetComponent <Character>()) }
     });
 }
コード例 #9
0
    //TODO: Add dies to the ablity
    /// <summary>
    /// Calculates the damage roll for the effect
    /// </summary>
    /// <param name="ability"></param>
    /// <param name="effect"></param>
    /// <returns></returns>
    public static int EffectRoll(Ability ability, AbilityEffects effect)
    {
        int  value = 0;
        Dice dice  = effect.dice;

        value = dice.RollDice();

        int[] casterStats = ability.caster.stats.GetModifiersFromArray();
        int   damagebonus = 0;

        //Rewrite this to loop in GetDamageBonus?
        // for (int i = 0; i < ability.abilityModifiers.Length; i++)
        // {
        damagebonus += GetDamageBonus(effect, ability.caster);
        //  }
//        Debug.Log("The ability power is " + value);
        if (value < 0)
        {
            value = 0;
        }

//        Debug.Log("You rolled " + dice.ToString() + " resulting in: " + value + " + " + damagebonus);
        return(value + damagebonus);
    }
コード例 #10
0
 public void RemoveEffect(AbilityEffects ailment)
 {
     ailment.OnRemoveAbilityEffects();
     listEffects.Remove(ailment);
 }
コード例 #11
0
ファイル: Ability.cs プロジェクト: unbelt/SoftUni
 public Ability(string name, string description, AbilityEffects abilityEffect, int energyCost)
     : base(name, description)
 {
     this.EnergyCost = energyCost;
     this.AbilityEffect = abilityEffect;
 }