Beispiel #1
0
        protected void ApplyEffect(Character source, GameObject target, SkillEffect ef, bool allowStackingSameEffect = false)
        {
            foreach (EquippableItem u in Owner.Inventory.ActiveUpgrades)
            {
                u.ModifySkillEffects(this, new SkillEffect[] { ef });
            }

            ef.Source            = source;
            ef.SourceSkill       = GetSkillId();
            ef.SourceSkillObject = this;

            if (!allowStackingSameEffect && !(ef is EffectDamage))
            {
                Character targetCh = target.GetChar();

                if (targetCh != null && targetCh.HasEffectAlready(ef))
                {
                    SkillEffect oldEf = targetCh.GetCopyEffect(ef);

                    if (oldEf != null)
                    {
                        targetCh.RemoveEffect(oldEf);
                    }
                    else
                    {
                        return;
                    }
                }
            }

            ef.ApplyEffect(source, target);
        }
Beispiel #2
0
        /// <summary>
        /// Applies all SkillEffects of this skill to the target
        /// </summary>
        /// <param name="source">who casted the skill (usually the Owner of this skill)</param>
        /// <param name="target">who receives the effects</param>
        public void ApplyEffects(Character source, GameObject target, bool allowStackingSameEffect = false, int param = 0)
        {
            // add new effect from templates // TOOD vytvorit kopii efektu!
            if (additionalEffects != null)
            {
                foreach (SkillEffect ef in additionalEffects)
                {
                    SkillEffect newEf = ef.Clone() as SkillEffect;

                    newEf.Source            = source;
                    newEf.SourceSkill       = GetSkillId();
                    newEf.SourceSkillObject = this;

                    if (!allowStackingSameEffect && !(newEf is EffectDamage))
                    {
                        Character targetCh = target.GetChar();

                        if (targetCh != null && targetCh.HasEffectAlready(newEf))
                        {
                            SkillEffect oldEf = targetCh.GetCopyEffect(newEf);

                            if (oldEf != null)
                            {
                                targetCh.RemoveEffect(oldEf);
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }

                    newEf.ApplyEffect(source, target);
                }
            }

            SkillEffect[] efs = CreateEffects(param);

            // add new effects from ugprades
            foreach (EquippableItem u in Owner.Inventory.ActiveUpgrades)
            {
                SkillEffect[] newEffects = u.CreateAdditionalSkillEffects(this, efs);

                if (newEffects != null)
                {
                    foreach (SkillEffect ef in newEffects)
                    {
                        ef.Source            = source;
                        ef.SourceSkill       = GetSkillId();
                        ef.SourceSkillObject = this;

                        if (!allowStackingSameEffect && !(ef is EffectDamage))
                        {
                            Character targetCh = target.GetChar();
                            if (targetCh != null && targetCh.HasEffectAlready(ef))
                            {
                                SkillEffect oldEf = targetCh.GetCopyEffect(ef);

                                if (oldEf != null)
                                {
                                    targetCh.RemoveEffect(oldEf);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }

                        ef.ApplyEffect(source, target);
                    }
                }
            }

            foreach (EquippableItem u in Owner.Inventory.ActiveUpgrades)
            {
                u.ModifySkillEffects(this, efs);
            }

            if (efs != null && !originalEffectsDisabled)
            {
                foreach (SkillEffect ef in efs)
                {
                    ef.Source            = source;
                    ef.SourceSkill       = GetSkillId();
                    ef.SourceSkillObject = this;

                    if (!allowStackingSameEffect && !(ef is EffectDamage))
                    {
                        Character targetCh = target.GetChar();

                        if (targetCh != null && targetCh.HasEffectAlready(ef))
                        {
                            SkillEffect oldEf = targetCh.GetCopyEffect(ef);

                            if (oldEf != null)
                            {
                                targetCh.RemoveEffect(oldEf);
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }

                    ef.ApplyEffect(source, target);
                }
            }
        }