예제 #1
0
 /// <summary>
 /// The effect of te skill. The skill's owner is passed as parameter.
 /// </summary>
 public abstract void cast(SkillManager manager);
예제 #2
0
        public float width;                  // Size of the attack AoE

        public override void cast(SkillManager skillManager)
        {
            // Initialization :

            var caster         = skillManager.gameObject;
            var trans          = caster.transform;
            var casterAnimator = caster.GetComponent <Animator>();
            var audioSource    = caster.GetComponent <AudioSource>();
            var effects        = skillManager.GetComponent <EffectManager>();

            // Adding the effects of the attack on the attacker :

            effects.addEffect(new Effects.Silence(castTime));
            effects.addEffect(new Effects.Slow(castTime, 0.33f));
            casterAnimator.SetTrigger("sword");

            effects.addEffect(new Effects.Delayed(castTime / 2f, false, () => {
                audioSource.PlayOneShot(sword_Sound, 0.3f);

                var poisonBuff = caster.GetComponent <EffectManager>()
                                 .getEffects()
                                 .FirstOrDefault(e => e is Effects.PoisonBuff)
                                 as Effects.PoisonBuff;

                var hits = Physics.OverlapSphere(trans.position + trans.forward * range + Vector3.up * 0.5f, width / 2f);
                foreach (var hit in hits)
                {
                    if (hit.isTrigger)
                    {
                        continue;
                    }
                    if (!caster.isEnemyWith(hit.gameObject))
                    {
                        continue;
                    }

                    var health = hit.GetComponent <HealthManager>();
                    if (!health)
                    {
                        continue;
                    }

                    // Cause damage to the enemy
                    health.harm(damageAttack);

                    if (poisonBuff == null)
                    {
                        continue;
                    }

                    // Try applying the poison

                    var enemyEffects = hit.GetComponent <EffectManager>();
                    var poisonEffect = enemyEffects
                                       .getEffects()
                                       .FirstOrDefault(e => e is Effects.Poison)
                                       as Effects.Poison;

                    if (poisonEffect == null)
                    {
                        enemyEffects.addEffect(poisonBuff.makeEffect());
                    }
                    else
                    {
                        poisonEffect.setTime(poisonBuff.buffDuration());
                    }
                }
            }));
        }