示例#1
0
文件: CueData.cs 项目: sin-us/sdhk
 public void Update(AudioListener listener)
 {
     if (Is3DEmitter)
     {
         Cue.Apply3D(listener, Emitter);
     }
 }
示例#2
0
 /// <summary>
 /// Apply 3d effects if spatialized.
 /// </summary>
 /// <param name="listener"></param>
 public void Apply3D(AudioListener listener)
 {
     if (Spatial)
     {
         if (cue != null)
         {
             AudioEmitter emitter = Audio.Emitter;
             if (thing != null)
             {
                 emitter.Up = thing.Movement.LocalMatrix.Backward;   // Actually up.  Yeah, I know...
                 emitter.Position = thing.Movement.Position;
                 emitter.Velocity = thing.Movement.Velocity;
                 emitter.Forward = thing.Movement.Facing;
             }
             else
             {
                 emitter.Position = position;
                 emitter.Up = Vector3.UnitZ;
                 emitter.Velocity = Vector3.Zero;
                 emitter.Forward = Vector3.UnitX;
             }
             // Apply new 3D values to the audio cue
             cue.Apply3D(listener, emitter);
         }
     }
 }
示例#3
0
文件: Audio.cs 项目: bradleat/trafps
 public void Apply3DPosition(Cue cue, AudioListener listener, AudioEmitter emitter,
                             Vector3 listenerPosition, Vector3 emitterPosition)
 {
     listenerPosition = listener.Position;
     emitterPosition  = emitter.Position;
     cue.Apply3D(listener, emitter);
 }
示例#4
0
 public void StartCategoryTransition(bool toInGame)
 {
     transition = true;
     if (toInGame)
     {
         oldCategory     = menuCategory;
         currentCategory = graphXPackCategory;
         currentCategory.Stop(AudioStopOptions.Immediate);
         oldMusic        = currentMusic;
         currentPlaylist = graphXPackPlaylist;
         currentMusic    = soundBank.GetCue(GetRandomTrack(currentPlaylist));
         popUpText.Text  = currentPlaylist[currentMusic.Name];
         StartPopUp();
     }
     else
     {
         oldCategory     = graphXPackCategory;
         currentCategory = menuCategory;
         currentCategory.Stop(AudioStopOptions.Immediate);
         oldMusic        = currentMusic;
         currentPlaylist = playList;
         currentMusic    = soundBank.GetCue(GetRandomTrack(currentPlaylist));
         popUpText.Text  = currentPlaylist[currentMusic.Name];
         StartPopUp();
     }
     currentVolume = 0;
     currentCategory.SetVolume(currentVolume);
     currentMusic.Apply3D(new AudioListener(), new AudioEmitter());
     currentMusic.Play();
 }
 public void currentState(GameState state)
 {
     if (this.state != state)
     {
         bool isLoop        = (state == GameState.anim_idle || state == GameState.anim_walk || state == GameState.anim_run || state == GameState.anim_attackidle);
         bool lastIsLoop    = (this.state == GameState.anim_idle || this.state == GameState.anim_walk || this.state == GameState.anim_run || this.state == GameState.anim_attackidle);
         bool isAttackState = (state == GameState.anim_attack1 || state == GameState.anim_attack2 || state == GameState.anim_attack3);
         if (!lastIsLoop)
         {
             if (model.isAnimated())
             {
                 model.playClip((short)state, isLoop);
                 this.state = state;
             }
         }
         else
         {
             model.playClip((short)state, isLoop);
             this.state = state;
         }
         if (isAttackState)
         {
             model.playClip((short)state, isLoop);
             this.state = state;
             if (model != null)
             {
                 Random rand = new Random();
                 audioEmitter.Position = model._Position;
                 Cue cue = audioSystem.getSoundBank().GetCue("att-0." + rand.Next(1, 2));
                 cue.Apply3D(audioSystem.getAudioListener(), audioEmitter);
                 cue.Play();
             }
         }
     }
 }
示例#6
0
        public Cue PlaySound(string soundName, AudioListener audioListener, AudioEmitter audioEmitter)
        {
            Cue result = GetCue(soundName);

            result.Apply3D(audioListener, audioEmitter);
            result.Play();
            return(result);
        }
示例#7
0
文件: Audio.cs 项目: bradleat/trafps
 public void Apply3DAll(Cue cue, AudioListener listener, AudioEmitter emitter, Vector3 listenerPosition,
                        Vector3 emitterPosition, Vector3 listenerVelocity, Vector3 emitterVelocity)
 {
     listenerPosition  = listener.Position;
     emitterPosition   = emitter.Position;
     listener.Velocity = listener.Velocity;
     emitter.Velocity  = emitter.Velocity;
     cue.Apply3D(listener, emitter);
 }
示例#8
0
        /// <summary>
        /// Creates a new instance of CorvSoundEffectCue with attenuation.
        /// </summary>
        public CorvSoundEffectCue(Cue cue, Vector2 listenerPosition, Vector2 emitterPosition)
            : base(cue)
        {
            this._Listener          = new AudioListener();
            this._Listener.Position = new Vector3(listenerPosition, 0);
            this._Emitter           = new AudioEmitter();
            this._Emitter.Position  = new Vector3(emitterPosition, 0);

            Cue.Apply3D(this._Listener, this._Emitter);
        }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (cue != null)
            {
                audioEmitter.Position = new Vector3(Position.X, 0f, 0f);
                cue.Apply3D(audioListener, audioEmitter);
            }
        }
示例#10
0
 public Sound()
 {
     audioengine = new AudioEngine("Content\\audio.xgs");
     wavebank    = new WaveBank(audioengine, "Content\\Wave Bank.xwb");
     soundBank   = new SoundBank(audioengine, "Content\\Sound Bank.xsb");
     emitter     = new AudioEmitter();
     listener    = new AudioListener();
     cue         = soundBank.GetCue("anxious");
     cue.Apply3D(listener, emitter);
     cue.Play();
 }
示例#11
0
文件: CueData.cs 项目: sin-us/sdhk
        public CueData(SoundBank soundBank, String soundName, AudioListener listener, bool is3DEmitter)
        {
            Cue = soundBank.GetCue(soundName);

            Is3DEmitter = is3DEmitter;
            if (is3DEmitter)
            {
                Emitter = new AudioEmitter();
                Cue.Apply3D(listener, Emitter);
            }
        }
示例#12
0
文件: Sound3D.cs 项目: W3SS/delta
        private void Apply3D()
        {
            Vector2 newSource = _source.Position * 5; // needs to fall off faster, this is easiest for now.
            Vector2 value     = CalculateForward(newSource, _dest.Position);

            _audioEmitter.Position  = new Vector3(newSource, 0f);
            _audioListener.Position = new Vector3(_dest.Position, 0f);
            _audioListener.Forward  = new Vector3(value, 0f);
            _audioListener.Up       = -Vector3.Forward;
            _cue.Apply3D(_audioListener, _audioEmitter);
        }
示例#13
0
 public void Apply3D(AudioListener listener)
 {
     if (thing != null)
     {
         // GameThing.Movement doesn't expose an "Up" property, so just use Camera.Up
         emitter.Up       = InGame.inGame.Camera.Up;
         emitter.Position = thing.Movement.Position;
         emitter.Velocity = thing.Movement.Velocity;
         emitter.Forward  = thing.Movement.Facing;
         // Apply new 3D values to the audio cue
         cue.Apply3D(listener, emitter);
     }
 }
示例#14
0
文件: Sound.cs 项目: jwmcglynn/float
        /// <summary>
        /// Play a locational sound at the Entity's position.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="source"></param>
        public static Cue PlayCue(string name, Entity source)
        {
            Cue sound = m_soundBank.GetCue(name);

            if (source.SoundEmitter == null)
            {
                source.SoundEmitter = new AudioEmitter();
            }
            source.SoundEmitter.Position = new Vector3(source.Position.X, source.Position.Y, 0.0f);

            sound.Apply3D(Listener, source.SoundEmitter);
            sound.Play();
            return(sound);
        }
示例#15
0
文件: Audio.cs 项目: bradleat/trafps
        /// <summary>
        ///
        /// </summary>
        /// <param name="cue"></param>
        /// <param name="apply3d"></param>
        /// <param name="listener"></param>
        /// <param name="emitter"></param>
        /// <returns></returns>
        public Cue Play(Cue cue, bool apply3d, AudioListener listener, AudioEmitter emitter)
        {
            if (cue.IsStopped)
            {
                cue = soundBank.GetCue(cue.Name);
            }

            if (cue.IsPrepared)
            {
                if (apply3d)
                {
                    cue.Apply3D(listener, emitter);
                }
                cue.Play();
            }
            return(cue);
        }
        private void UpdateSoundPosition(Cue cue, Vector3 sourcePos, Vector3 camPos, Vector3 camForward, Vector3 camUp)
        {
            AudioEmitter emitter = new AudioEmitter();

            emitter.Position = sourcePos;

            AudioListener listener = new AudioListener();

            listener.Position = camPos;
            listener.Forward  = camForward;
            listener.Up       = camUp;

            SoundEffect effect;


            cue.Apply3D(listener, emitter);
        }
        public void recieveDamage(int dmg)
        {
            if (model != null && dmg > 0)
            {
                Random rand = new Random();
                audioEmitter.Position = model._Position;
                Cue cue = audioSystem.getSoundBank().GetCue("att-1." + rand.Next(1, 5));
                cue.Apply3D(audioSystem.getAudioListener(), audioEmitter);
                cue.Play();
                Vector3 particlePos = getPosition();
                particlePos.Y += 5;
                particleManager.ParticleBloodStar(particlePos, Vector3.One);

                numDamage = (numDamage + 1) % listDamageSize;
                listDamageValue[numDamage] = dmg;
                listDamageTime[numDamage]  = DateTime.Now.Ticks;
            }
        }
示例#18
0
文件: Sound.cs 项目: THSJF/sjf
        public int Play(string k, bool apply3d, float Position)
        {
            if (Main.Mode == Modes.SINGLE)
            {
                float num = (float)(((double)Position - 224.0) / 448.0);
                Sound.emitter.Position = (double)Position - 224.0 <= 0.0 ? ((double)Position - 224.0 >= 0.0 ? new Vector3(1.5f * num, 0.0f, 1f - Math.Abs(num)) : new Vector3(1.5f * num, 0.0f, 1f - Math.Abs(num))) : new Vector3(1.5f * num, 0.0f, 1f - Math.Abs(num));
            }
            if (!apply3d)
            {
                Sound.emitter.Position = Vector3.Zero;
            }
            foreach (string str in Sound.already)
            {
                if (str == k)
                {
                    return(0);
                }
            }
            if (k.Contains(".wav"))
            {
                k = k.Replace(".wav", "");
            }
            foreach (string key in this.SEs.Keys)
            {
                if (key == k)
                {
                    this.SEs[key].Dispose();
                    this.SEs[key] = Sound.SB.GetCue(k);
                    this.SEs[key].Apply3D(Sound.listener, Sound.emitter);
                    this.SEs[key].Play();
                    Sound.already.Add(k);
                    return(0);
                }
            }
            Cue cue = Sound.SB.GetCue(k);

            this.SEs.Add(k, cue);
            cue.Apply3D(Sound.listener, Sound.emitter);
            cue.Play();
            Sound.already.Add(k);
            return(0);
        }
示例#19
0
 /// <summary>
 /// Play this sound now.
 /// </summary>
 public void Play()
 {
     // Dispose cue because can only played once
     // see: http://forums.xna.com/thread/11094.aspx
     if (!cue.IsDisposed)
     {
         cue.Dispose();
     }
     cue = bank.GetCue(Name);
     switch (Type)
     {
     case SoundType.Effect:
         al.Position      = box.ListenerPosition;
         emitter.Position = this.GlobalPosition;
         if ((al != null) && (emitter != null))
         {
             try
             {
                 cue.Apply3D(al, emitter);
             }
             catch (System.Exception)
             {
                 // Catch XNA Sound error. One member of the development team
                 // get errors if multiple sound device are attached.
             }
         }
         break;
     }
     // Wait for stopping cue.
     while (cue.IsStopping)
     {
     }
     if (!cue.IsPlaying)
     {
         cue.Play();
     }
 }
示例#20
0
        private static void PlaySound(string cueName, Vector2 sourceTilePos)
        {
            try
            {
                SoundBank soundBank = ModEntry.GetHelper().Reflection.GetField <SoundBank>(Game1.soundBank as SoundBankWrapper, "soundBank").GetValue();

                Cue           cue      = soundBank.GetCue(cueName);
                AudioListener listener = new AudioListener
                {
                    Position = new Vector3(Game1.player.Position, 0)
                };
                AudioEmitter emitter = new AudioEmitter
                {
                    Position = new Vector3(sourceTilePos * Game1.tileSize, 0)
                };

                cue.Apply3D(listener, emitter);
                cue.Play();
            }
            catch (System.Exception e)
            {
                ModEntry.Log("Error while playing sound: " + e.Message);
            }
        }
示例#21
0
 public void Update(GameTime gameTime)
 {
     if (currentMusic == null)
     {
         currentMusic = soundBank.GetCue(GetRandomTrack(currentPlaylist));
         //Fake 3D Sound for Surround Effect ;)
         currentMusic.Apply3D(new AudioListener(), new AudioEmitter());
         currentMusic.Play();
         popUpText.Text = currentPlaylist[currentMusic.Name];
         StartPopUp();
     }
     if (currentMusic.IsStopped)
     {
         currentMusicindex++;
         if (currentMusicindex >= playList.Keys.Count)
         {
             currentMusicindex = 0;
         }
         currentMusic = soundBank.GetCue(GetRandomTrack(currentPlaylist));
         currentMusic.Apply3D(new AudioListener(), new AudioEmitter());
         currentMusic.Play();
         popUpText.Text = currentPlaylist[currentMusic.Name];
         StartPopUp();
     }
     if (transition)
     {
         oldVolume     -= gameTime.GetElapsedTotalSecondsFloat();
         oldVolume      = MathHelper.Clamp(oldVolume, 0, options.MusicVolumeFloat);
         currentVolume += gameTime.GetElapsedTotalSecondsFloat();
         if (currentVolume >= options.MusicVolumeFloat)
         {
             transition    = false;
             currentVolume = MathHelper.Clamp(currentVolume, 0, options.MusicVolumeFloat);
             oldCategory.Stop(AudioStopOptions.Immediate);
             oldMusic.Stop(AudioStopOptions.Immediate);
         }
         oldCategory.SetVolume(oldVolume);
         currentCategory.SetVolume(currentVolume);
     }
     if (popUpActive)
     {
         if (popUpFloatIn)
         {
             popUp.Y += (int)(popUpSpeed * gameTime.GetElapsedTotalSecondsFloat());
             AlignPopUpText();
             if (popUp.Y >= 0)
             {
                 popUpFloatIn = false;
             }
         }
         else
         {
             popUpStillStandelpasedTime += gameTime.GetElapsedTotalSecondsFloat();
             if (popUpStillStandelpasedTime >= popUpStillStandThreshold)
             {
                 popUp.Y -= (int)(popUpSpeed * gameTime.GetElapsedTotalSecondsFloat());
                 if (popUp.X <= -(int)(options.Resolution.ScreenHeight * 0.1))
                 {
                     popUpActive = false;
                 }
                 AlignPopUpText();
             }
         }
     }
 }
示例#22
0
 /// <summary>
 /// Instruct the sound cue to play the sound in 3D space.
 /// </summary>
 /// <param name="listener">The symbolic object representing the user's speakers.</param>
 public void Apply3DEffects(AudioListener listener)
 {
     Listener = listener;
     Cue.Apply3D(Listener, Emitter);
 }
示例#23
0
 public void Apply3D(Listener listener, Emitter emiter)
 {
     m_cue.Apply3D(listener, emiter);
 }
示例#24
0
        public override void Update(GameTime gameTime)
        {
            if (m_screen.IsActive)
            {
                m_killTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            //if ((float)gameTime.TotalGameTime.TotalSeconds > m_killTime)
            if (m_killTime < 0.0f)
            {
                bDead = true;
                // Cue c = Game1.Audio.PlaySound("sfx_cannonball_hit_water");
                Cue c = Game1.Audio.GetCue("sfx_cannonball_hit_water");

                AudioListener al = new AudioListener();
                al.Position = new Vector3(m_screen.Player.Position, 0);
                al.Up       = Vector3.Backward;
                al.Forward  = Vector3.Up;

                AudioEmitter ae = new AudioEmitter();
                ae.Position = new Vector3(Position, 0);
                ae.Up       = Vector3.Backward;
                ae.Forward  = Vector3.Up;

                c.Apply3D(al, ae);
                Game1.Audio.PlayCue(c);
                c.SetVariable("Distance", (m_screen.Player.Position - Position).Length());

                Watersplash w = new Watersplash(Game);
                w.Initialize(10, Position, true);

                //Game1.Audio.SetParameter("sfx_cannonball_hit_water", "Distance", (m_screen.Player.Position - Position).Length());
            }



            m_obb.Orientation = Rotation;
            m_obb.Center      = Position;
            m_obb.CalculateAxis();

            for (Actor a = Actors.First.Value; a != null; a = a.NextActor)
            {
                if (a is PDVehicle)
                {
                    if (a != Owner)
                    {
                        if ((a as PDVehicle).Obb.TestOBBOBB(Obb))
                        {
                            SpriteEffect e = new EffectCannonFire(Game);
                            e.Initialize(10, Position, true);

                            bDead = true;

                            // Cue c = Game1.Audio.PlaySound("sfx_cannonball_hit");
                            Cue           c  = Game1.Audio.GetCue("sfx_cannonball_hit");
                            AudioListener al = new AudioListener();
                            al.Position = new Vector3(m_screen.Player.Position, 0);
                            al.Up       = Vector3.Backward;
                            al.Forward  = Vector3.Up;

                            AudioEmitter ae = new AudioEmitter();
                            ae.Position = new Vector3(Position, 0);
                            ae.Up       = Vector3.Backward;
                            ae.Forward  = Vector3.Up;

                            c.Apply3D(al, ae);
                            Game1.Audio.PlayCue(c);
                            c.SetVariable("Distance", (m_screen.Player.Position - Position).Length());
                            // Game1.Audio.SetParameter("sfx_cannonball_hit", "Distance", (m_screen.Player.Position - Position).Length());

                            // Damage target
                            (a as PDVehicle).Damage(Damage);
                        }
                    }
                }
            }

            base.Update(gameTime);
        }
示例#25
0
文件: Audio.cs 项目: bradleat/trafps
 public void Apply3D(Cue cue, AudioListener listener, AudioEmitter emitter)
 {
     cue.Apply3D(listener, emitter);
 }
示例#26
0
文件: Audio.cs 项目: bradleat/trafps
 public void Apply3DVelocity(Cue cue, AudioListener listener, AudioEmitter emitter, Vector3 emitterVelocity, Vector3 listenerVelocity)
 {
     listenerVelocity = listener.Velocity;
     emitterVelocity  = emitter.Velocity;
     cue.Apply3D(listener, emitter);
 }
示例#27
0
        public override void Update(GameTime gameTime)
        {
            // Set the correct animation based on Velocity/Throttle & Rotation

            // Lean percentage that increases when you hold down turning and normalizes when you don't
            // The Lean percentage is adjusted by velocity/throttle so that you can't lean hard with low velocity

            if (m_health <= 0)
            {
                bDead = true;
                // Cue c = Game1.Audio.PlaySound("sfx_ship_sink");
                Cue           c  = Game1.Audio.GetCue("sfx_ship_sink");
                AudioListener al = new AudioListener();
                al.Position = new Vector3(m_screen.Player.Position, 0);
                al.Up       = Vector3.Backward;
                al.Forward  = Vector3.Up;

                AudioEmitter ae = new AudioEmitter();
                ae.Position = new Vector3(Position, 0);
                ae.Up       = Vector3.Backward;
                ae.Forward  = Vector3.Up;

                c.Apply3D(al, ae);
                Game1.Audio.PlayCue(c);


                c.SetVariable("Distance", (Screen.Player.Position - Position).Length());

                Wreckage w = new Wreckage(Game);
                w.Initialize(m_gold, Silk, Spices, Leather, Rum, Iron, Coal, Rope, Tools);
                w.Position = Position;

                for (int i = 0; i < 10; i++)
                {
                    EffectCannonFire a = new EffectCannonFire(Game);
                    a.Initialize(10, Position + new Vector2(Game1.Rand.Next(-40, 40), Game1.Rand.Next(-40, 40)), true);
                }

                for (int i = 0; i < 10; i++)
                {
                    Watersplash a = new Watersplash(Game);
                    a.Initialize(10, Position + new Vector2(Game1.Rand.Next(-40, 40), Game1.Rand.Next(-40, 40)), true);
                }

                int n = Game1.Rand.Next(0, GameplayScreen.m_waypoints.Length);

                int type = Game1.Rand.Next(0, 4);

                PDVehicle v = null;

                switch (type)
                {
                case 0:
                    v = new PDVBritish(Game, m_screen);
                    v.Initialize();
                    v.SetDefaultGraphics(ref GameplayScreen.m_tShipBritish);
                    break;

                case 1:
                    v = new PDVChinese(Game, m_screen);
                    v.Initialize();
                    v.SetDefaultGraphics(ref GameplayScreen.m_tShipChinese);
                    break;

                case 2:
                    v = new PDVPersian(Game, m_screen);
                    v.Initialize();
                    v.SetDefaultGraphics(ref GameplayScreen.m_tShipPersian);
                    break;

                case 3:
                    v = new PDVSpanish(Game, m_screen);
                    v.Initialize();
                    v.SetDefaultGraphics(ref GameplayScreen.m_tShipSpanish);
                    break;
                }

                v.Position         = GameplayScreen.m_waypoints[n];
                v.ThrottleMax      = 40;
                v.ThrottleDecrease = 100;
                v.bTurnInPlace     = true;


                return;
            }



            for (int i = 0; i < Screen.m_islands.Count; i++)
            {
                if (Screen.m_islands[i].Hitbox != null)
                {
                    for (int j = 0; j < Screen.m_islands[i].Hitbox.Length; j++)
                    {
                        if (Screen.m_islands[i].Hitbox[j].TestOBBOBB(Obb))
                        {
                            // Cue c = Game1.Audio.PlaySound("sfx_ship_collide");
                            Cue           c  = Game1.Audio.GetCue("sfx_ship_collide");
                            AudioListener al = new AudioListener();
                            al.Position = new Vector3(m_screen.Player.Position, 0);
                            al.Up       = Vector3.Backward;
                            al.Forward  = Vector3.Up;

                            AudioEmitter ae = new AudioEmitter();
                            ae.Position = new Vector3(Position, 0);
                            ae.Up       = Vector3.Backward;
                            ae.Forward  = Vector3.Up;

                            c.Apply3D(al, ae);
                            Game1.Audio.PlayCue(c);


                            c.SetVariable("Distance", (Screen.Player.Position - Position).Length());


                            Vector2 v = Obb.Center - Screen.m_islands[i].Hitbox[j].Center;
                            v.Normalize();

                            Heading  = v;
                            Rotation = (float)Math.Atan2(Heading.Y, Heading.X);
                            Throttle = 100;
                            break;
                        }
                    }
                }
            }



            // Throttle -= ThrottleDecrease * (float)gameTime.ElapsedGameTime.TotalSeconds * 0.25f;

            float velMod = 0.0f;

            if (Throttle > 0.001f)
            {
                velMod = Throttle / ThrottleMax;
            }

            m_leanValue = MathHelper.Clamp(m_leanValue * velMod, -1.0f, 1.0f);

            int index = (int)Math.Round(m_leanValue * 4.0f) + 4;

            if (m_gfx != null)
            {
                if ((m_gfx as Animation).ActiveAnimationSet.Name != m_animTable[index])
                {
                    int currentFrame = (m_gfx as Animation).ActiveAnimationSet.nActiveFrame;
                    (m_gfx as Animation).SetActiveSet(m_animTable[index], currentFrame);
                }
            }


            if (m_bFiring)
            {
                if (m_nextShot < gameTime.TotalGameTime.TotalSeconds)
                {
                    Fire(gameTime);
                    m_nextShot += m_tTimeBetweenShots;

                    if (m_cannonsReady <= 0)
                    {
                        m_bFiring = false;
                    }
                }
            }
            else
            {
                Reload(gameTime);
            }



            m_obb.Orientation = Rotation;
            m_obb.Center      = Position;
            m_obb.CalculateAxis();

            m_shadow.Position = Position;
            m_shadow.Rotation = Rotation;

            m_hpBar.Position = Position;
            m_hpBar.Update(gameTime);
            m_hpBar.Scale = new Vector2(m_health / m_maxHealth, 1);

            m_hpBarBG.Position = Position;

            m_hpBarBG.Update(gameTime);



            if (m_tNextWaterTrail < gameTime.TotalGameTime.TotalSeconds)
            {
                if (Throttle > 10.0f)
                {
                    EffectWaterTrail water = new EffectWaterTrail(Game);
                    water.Initialize((float)gameTime.TotalGameTime.TotalSeconds + 3.5f, Position + (Heading * 40), false);
                    water.Rotation = Rotation - MathHelper.PiOver2;

                    water = new EffectWaterTrail(Game);
                    water.Initialize((float)gameTime.TotalGameTime.TotalSeconds + 3.5f, Position + (Heading * 40), false);
                    water.Rotation = Rotation + MathHelper.PiOver2;

                    m_tNextWaterTrail = (float)gameTime.TotalGameTime.TotalSeconds + 0.1f;
                }
            }



            base.Update(gameTime);
        }
示例#28
0
        public virtual bool FireRight(GameTime gameTime)
        {
            if (m_cannonsReady > 4)
            {
                if (!m_bFiring)
                {
                    m_bFiring   = true;
                    m_bFireLeft = false;

                    Cue c = null;

                    if (m_cannonsReady > 6)
                    {
                        m_tTimeBetweenShots = 1.3f / m_cannonsReady;
                        // c = Game1.Audio.PlaySound("sfx_cannon_shoot_many");
                        c = Game1.Audio.GetCue("sfx_cannon_shoot_many");
                    }
                    else
                    {
                        m_tTimeBetweenShots = 0.5f / m_cannonsReady;
                        // c = Game1.Audio.PlaySound("sfx_cannon_shoot");
                        c = Game1.Audio.GetCue("sfx_cannon_shoot");
                    }

                    AudioListener al = new AudioListener();
                    al.Position = new Vector3(m_screen.Player.Position, 0);
                    al.Up       = Vector3.Backward;
                    al.Forward  = Vector3.Up;

                    AudioEmitter ae = new AudioEmitter();
                    ae.Position = new Vector3(Position, 0);
                    ae.Up       = Vector3.Backward;
                    ae.Forward  = Vector3.Up;

                    c.Apply3D(al, ae);
                    Game1.Audio.PlayCue(c);

                    c.SetVariable("Distance", (Screen.Player.Position - Position).Length());

                    m_nextShot = (float)gameTime.TotalGameTime.TotalSeconds;
                }

                /*
                 * Vector2 back = Position - (Heading * 50);
                 * Vector2 length = Heading * 100;
                 *
                 * Vector2 pos = back + (length * (float)Game1.Rand.NextDouble());
                 *
                 * Texture2D tex = GameplayScreen.m_debugSprites;
                 * Proj_CannonBall p = new Proj_CannonBall(Game, this, ref tex, m_screen);
                 * p.Initialize(Rotation + MathHelper.PiOver2, pos, null, false, false, gameTime);
                 *
                 * m_cannonsReady--;
                 *
                 * return true;
                 *
                 */
            }

            return(false);
        }