Пример #1
0
        public override void OnInteract(Projectile projectile)
        {
            //Checks if the projectile is already under influence of this weather
            if (CheckWeatherInfluence(projectile))
            {
                return;
            }

            //Passes this instance to any projectile's dependent projectile
            projectile.OnBeginElectricityInteraction(this);

            //If the project can't collide, it should not be taken into consideration for spawning/explosion effects
            if (!projectile.CanCollide)
            {
                return;
            }

            //Once added to the list, the projectile starts spawning electrical particles around it's flipbook
            SpecialEffect se = SpecialEffectBuilder.ElectricityParticle(projectile.Position);

            projectile.OnAfterUpdateAction += () =>
            {
                se.Flipbook.Position = projectile.Position;
                se.Flipbook.Rotation = projectile.CurrentFlipbookRotation;
            };

            //Install itself on the projectile explosion event forcing every exploding projectile to be removed from the spawning list
            Action removeParticle = () => SpecialEffectHandler.Remove(se);

            projectile.OnExplodeAction        += removeParticle;
            projectile.OnBeingDestroyedAction += removeParticle;

            projectile.OnExplodeAction += () =>
            {
                LightningBaseProjectile ep = new LightningBaseProjectile(projectile.Mobile, projectile.Position,
                                                                         MathHelper.PiOver2,
                                                                         Parameter.WeatherEffectElectricityExplosionRadius,
                                                                         Parameter.WeatherEffectElectricityEExplosionRadius,
                                                                         Parameter.WeatherEffectElectricityBaseDamage,
                                                                         Parameter.WeatherEffectElectricityEBaseDamage);

                ep.Update();

                AudioHandler.PlaySoundEffect("Audio/SFX/Tank/Blast/LightningS1");
            };
        }