示例#1
0
        public float ejection;                  // ejection factor

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

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

            // Play The attacks' sound
            if (fireball_Sound != null)
            {
                audioSource.PlayOneShot(fireball_Sound, 0.3f);
            }

            // Play the attacks' animation
            casterAnimator.SetTrigger("fireball");

            // Adding the effects of the attack on the attacker :
            effects.addEffect(new Effects.Immobilize(castTime));

            effects.addEffect(new Effects.Silence(castTime));
            effects.addEffect(new Effects.Delayed(castTime, false, () =>
            {
                // The fireballs' ejection pos
                Vector3 EjectPos = caster.transform.position + caster.transform.forward * ejection;
                EjectPos.y      += 1;

                // Instantiating the fireball Gameobject with it's script
                var fireball = Instantiate(fireball_Prefab, EjectPos, caster.transform.rotation);
                var script   = fireball.AddComponent <Fireball>();
                script.setup(caster, damageAttack, fireball_Impact);

                // Appliquer une force
                fireball.GetComponent <Rigidbody>().AddForce(caster.transform.forward * strength);

                // Destroy the fireball
                Destroy(fireball, range);
            }));
        }
示例#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());
                    }
                }
            }));
        }