예제 #1
0
        public override void EventFired(object sender, Event evt)
        {
            if (evt is ActivationEvent ae && ae.Affected.Components.Get <SoundEmitter>() is SoundEmitter em)
            {
                Spatial sp = ae.Affected.Components.Get <Spatial>();
                foreach (Sound sound in em.Sounds)
                {
                    double volumeMultiplier = 1;
                    double pan = 0;

                    if (sp != null && sound.Range != 0)
                    {
                        volumeMultiplier = 1 - ((sp.Position - Owner.CurrentViewport.Location).Magnitude / sound.Range);
                        if (volumeMultiplier <= 0)
                        {
                            continue;
                        }
                        pan = Math.Atan(sp.Position.X - Owner.CurrentViewport.Location.X) / (2 * Math.PI);
                    }

                    ISoundEffect soundEffect = Woofer.Controller.AudioUnit[sound.Name];
                    soundEffect.Volume  = sound.Volume * (float)volumeMultiplier;
                    soundEffect.Pitch   = sound.Pitch;
                    soundEffect.Pan     = (float)pan;
                    soundEffect.Looping = sound.Looping;
                    if (em.Music)
                    {
                        soundEffect.PlayAsMusic();
                    }
                    else
                    {
                        soundEffect.Play();
                    }
                }
            }
예제 #2
0
 public void SetMusic(ISoundEffect sound)
 {
     if (ActiveSong != null && sound.Name == ActiveSong.Name)
     {
         return;
     }
     ActiveSong?.Stop();
     ActiveSong = sound;
     sound.Play();
 }
예제 #3
0
파일: PulseSystem.cs 프로젝트: dncep/Woofer
        public override void Input()
        {
            IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap;

            foreach (PulseAbility pa in WatchedComponents.Where(c => c is PulseAbility))
            {
                ButtonInput pulseButton = inputMap.Pulse;

                if (pa.Owner.GetComponent <Health>() is Health health && health.CurrentHealth <= 0)
                {
                    continue;
                }

                if (pa.EnergyMeter >= pa.PulseCost)
                {
                    if (pulseButton.Consume())
                    {
                        double strength = (pa.PulseStrength * Math.Sqrt(pa.EnergyMeter / pa.MaxEnergy));

                        if (pa.Owner.Components.Has <Physical>() && pa.Owner.Components.Has <PlayerOrientation>())
                        {
                            pa.Owner.Components.Get <Physical>().Velocity = pa.Owner.Components.Get <PlayerOrientation>().Unit * -strength;

                            ISoundEffect sound_low = Woofer.Controller.AudioUnit["pulse_low"];
                            sound_low.Pitch = (float)(strength / 256) - 1;
                            ISoundEffect sound_mid = Woofer.Controller.AudioUnit["pulse_mid"];
                            sound_mid.Pitch = sound_low.Pitch;
                            ISoundEffect sound_high = Woofer.Controller.AudioUnit["pulse_high"];
                            sound_high.Pitch = sound_low.Pitch;

                            sound_low.Volume = 0.6f;


                            sound_low.Play();
                            sound_mid.Play();
                            sound_high.Play();
                        }

                        pa.EnergyMeter -= pa.PulseCost;

                        if (pa.Owner.Components.Has <Spatial>())
                        {
                            Spatial sp = pa.Owner.Components.Get <Spatial>();
                            if (sp == null)
                            {
                                continue;
                            }
                            PlayerOrientation po = pa.Owner.Components.Get <PlayerOrientation>();

                            Owner.Events.InvokeEvent(new PulseEvent(pa, sp.Position + pa.Offset, po != null ? po.Unit : new Vector2D(), strength, pa.MaxRange));
                        }
                    }
                }
            }
        }
 public static void OneUpEffect()
 {
     oneUpEffect = new OneUpEffect();
     oneUpEffect.Play();
 }
 public static void GameOverEffect()
 {
     gameOverEffect = new GameOverEffect();
     gameOverEffect.Play();
 }
 public static void GoombaHitEffect()
 {
     goombaHitEffect = new GoombaStompedEffect();
     goombaHitEffect.Play();
 }
 public static void FireBallThrowEffect()
 {
     fireBallThrowEffect = new FireballEffect();
     fireBallThrowEffect.Play();
 }
 public static void FlagPoleEffect()
 {
     flagPoleEffect = new FlagPoleMovingEffect();
     flagPoleEffect.Play();
 }
 public static void PowerUpAppearsEffect()
 {
     powerUpAppearsEffect = new PowerUpAppearsEffect();
     powerUpAppearsEffect.Play();
 }
 public static void EnemyFlippedEffect()
 {
     enemyFlipped = new EnemyFlippedEffect();
     enemyFlipped.Play();
 }
 public static void PacMarioChompEffect()
 {
     pacMarioChompEffect = new PacMarioChompEffect();
     pacMarioChompEffect.Play();
 }
 public static void CoinEffect()
 {
     coinEffect = new CoinEffect();
     coinEffect.Play();
 }
 public static void SuperMarioJumpEffect()
 {
     superMarioJumpEffect = new SuperMarioJumpEffect();
     superMarioJumpEffect.Play();
 }
 public static void BlockBumpedEffect()
 {
     blockBumpedEffect = new BlockBumpEffect();
     blockBumpedEffect.Play();
 }
 public static void StompEffect()
 {
     stompEffect = new StompEffect();
     stompEffect.Play();
 }
 public static void SmallMarioJumpEffect()
 {
     smallMarioJumpEffect = new SmallMarioJumpEffect();
     smallMarioJumpEffect.Play();
 }
 public static void ShrinkingOrPipeEffect()
 {
     shrinkingOrPipeEffect = new ShrinkingOrPipeEffect();
     shrinkingOrPipeEffect.Play();
 }
 public static void PacExtraLifeEffect()
 {
     pacExtraLifeEffect = new PacMarioExtraLifeEffect();
     pacExtraLifeEffect.Play();
 }
 public static void EatGhostEffect()
 {
     eatGhostEffect = new EatGhostEffect();
     eatGhostEffect.Play();
 }
 public static void BreakingBlockSoundEffect()
 {
     breakingBlockSoundEffect = new BrickBreakingEffect();
     breakingBlockSoundEffect.Play();
 }
 public static void PowerPlayerUpEffect()
 {
     powerPlayerUpEffect = new PowerPlayerUpEffect();
     powerPlayerUpEffect.Play();
 }