Ejemplo n.º 1
0
        public override void OnEnter()
        {
            SoundManager.StopMusic();
            Player.CurrentHealth       = Player.MaxHealth;
            Player.CurrentMana         = Player.MaxMana;
            Game.PlayerStats.HeadPiece = 7;
            Player.AttachedLevel.SetMapDisplayVisibility(false);
            Player.AttachedLevel.SetPlayerHUDVisibility(false);
            if (m_rainSFX != null)
            {
                m_rainSFX.Dispose();
            }
            m_rainSFX = SoundManager.PlaySound("Rain1");
            Player.UpdateCollisionBoxes();
            Player.Position = new Vector2(10f, 660f - (Player.Bounds.Bottom - Player.Y));
            Player.State    = 1;
            var logicSet = new LogicSet(Player);

            logicSet.AddAction(new RunFunctionLogicAction(Player, "LockControls"));
            logicSet.AddAction(new MoveDirectionLogicAction(new Vector2(1f, 0f)));
            logicSet.AddAction(new ChangeSpriteLogicAction("PlayerWalking_Character"));
            logicSet.AddAction(new PlayAnimationLogicAction());
            logicSet.AddAction(new DelayLogicAction(2.5f));
            logicSet.AddAction(new ChangePropertyLogicAction(Player, "CurrentSpeed", 0));
            Player.RunExternalLogicSet(logicSet);
            Tween.RunFunction(2f, this, "Intro1");
            base.OnEnter();
        }
Ejemplo n.º 2
0
 public override void OnExit()
 {
     if (m_seagullCue != null && m_seagullCue.IsPlaying)
     {
         m_seagullCue.Stop(AudioStopOptions.Immediate);
         m_seagullCue.Dispose();
     }
     base.OnExit();
 }
        public void StopBeamSounds()
        {
            if (turretWeapon.firetype != Weapon.fireType.Beam)
            {
                return;
            }

            if (laserCue == null)
            {
                return;
            }

            if (!laserCue.IsPlaying)
            {
                return;
            }

            if (laserCue.IsStopped)
            {
                return;
            }

            try
            {
                laserCue.Stop(AudioStopOptions.AsAuthored);
                laserCue.Dispose();
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        public void loadTrack(string trackName)
        {
            currentTrack = trackName;
            System.IO.Stream stream = TitleContainer.OpenStream(BeatShift.contentManager.RootDirectory + "/BFF/" + trackName + ".bff");
            LoadBFF(new StreamReader(stream));
            stream.Dispose();

            waveBank = new WaveBank(BeatShift.engine, "Content\\XACT\\" + trackName + "Map.xwb");

            if (track != null && !track.IsStopped)
            {
                track.Stop(AudioStopOptions.AsAuthored);
            }
            try
            {
                track.Dispose();
            }
            catch (NullReferenceException e)
            {
            }
            track = soundBank.GetCue(trackName);

            tick.Reset();

            GC.Collect();
        }
Ejemplo n.º 5
0
        //* -----------------------------------------------------------------------*
        /// <summary>1フレーム分の更新処理を実行します。</summary>
        ///
        /// <param name="entity">この状態を適用されているオブジェクト。</param>
        /// <param name="privateMembers">
        /// オブジェクトと状態クラスのみがアクセス可能なフィールド。
        /// </param>
        /// <param name="gameTime">前フレームが開始してからの経過時間。</param>
        public override void update(
            CAudio entity, CAudio.CPrivateMembers privateMembers, GameTime gameTime)
        {
            List <Cue>    cueList      = privateMembers.cueList;
            List <string> reservedList = privateMembers.reservedList;

            for (int i = cueList.Count; --i >= 0;)
            {
                Cue cue = cueList[i];
                if (cue.IsStopped)
                {
                    // Cueクラスは使いまわすことができない
                    cue.Dispose();
                    cueList.RemoveAt(i);
                }
            }
            for (int i = reservedList.Count; --i >= 0;)
            {
                string name = reservedList[i];
                Cue    cue  = entity.find(name);
                if (cue == null || cue.GetVariable("AttackTime") >= entity.loopInterval)
                {
                    Cue newCue = entity.soundBank.GetCue(name);
                    newCue.Play();
                    cueList.Add(newCue);
                    reservedList.RemoveAt(i);
                }
            }
            privateMembers.engineUpdate();
        }
Ejemplo n.º 6
0
 public override void OnEnter()
 {
     if (m_rainSound != null)
     {
         m_rainSound.Dispose();
     }
     if (DateTime.Now.Month != 12 && DateTime.Now.Month != 1)
     {
         m_rainSound = SoundManager.PlaySound("Rain1_Filtered");
     }
     else
     {
         m_rainSound = SoundManager.PlaySound("snowloop_filtered");
     }
     if (Game.PlayerStats.TotalBlueprintsFound >= 75)
     {
         GameUtil.UnlockAchievement("FEAR_OF_THROWING_STUFF_OUT");
     }
     m_lockControls = true;
     SoundManager.PlaySound("ShopMenuOpen");
     m_confirmText.Opacity    = 0f;
     m_cancelText.Opacity     = 0f;
     m_navigationText.Opacity = 0f;
     Tween.To(m_confirmText, 0.2f, Linear.EaseNone, "Opacity", "1");
     Tween.To(m_cancelText, 0.2f, Linear.EaseNone, "Opacity", "1");
     Tween.To(m_navigationText, 0.2f, Linear.EaseNone, "Opacity", "1");
     m_confirmText.Text = "[Input:" + 0 + "]  select/equip";
     m_cancelText.Text  = "[Input:" + 2 + "]  cancel/close menu";
     if (!InputManager.GamePadIsConnected(PlayerIndex.One))
     {
         m_navigationText.Text = "Arrow keys to navigate";
     }
     else
     {
         m_navigationText.Text = "[Button:LeftStick] to navigate";
     }
     m_currentEquipmentIndex  = 0;
     m_inCategoryMenu         = true;
     m_selectionIcon.Position = m_blacksmithUI.GetChildAt(6).AbsPosition;
     m_currentCategoryIndex   = 6;
     UpdateIconStates();
     DisplayCategory(0);
     EaseInMenu();
     Tween.To(this, 0.2f, Linear.EaseNone, "BackBufferOpacity", "0.5");
     UpdateIconSelectionText();
     base.OnEnter();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Marks this AudioCue as no longer in use
 /// </summary>
 public void Free()
 {
     Debug.Assert(m_state != State.AVAILABLE);
     Debug.Assert(false == m_cue.IsPlaying);
     m_cue.Dispose();
     m_cue   = null;
     m_state = State.AVAILABLE;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Stop music playback.
 /// </summary>
 public void StopMusic()
 {
     if (musicCue != null)
     {
         musicCue.Stop(AudioStopOptions.AsAuthored);
         musicCue.Dispose();
         musicCue = null;
     }
 }
Ejemplo n.º 9
0
 protected override void Recycle(bool isReleasing)
 {
     Name       = String.Empty;
     OnFinished = null;
     if (isReleasing)
     {
         _cue.Dispose();
     }
     base.Recycle(isReleasing);
 }
Ejemplo n.º 10
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         SpawnRoom = null;
         if (m_deathLoop != null && !m_deathLoop.IsDisposed)
         {
             m_deathLoop.Dispose();
         }
         m_deathLoop = null;
         base.Dispose();
     }
 }
Ejemplo n.º 11
0
 protected override void Recycle(bool isReleasing)
 {
     Name           = String.Empty;
     OnFinished     = null;
     _source        = null;
     _dest          = null;
     _audioEmitter  = null;
     _audioListener = null;
     if (isReleasing)
     {
         _cue.Dispose();
     }
     base.Recycle(isReleasing);
 }
Ejemplo n.º 12
0
        protected override void Dispose(bool disposing)
        {
            if (!disposed && disposing)
            {
                //Save the settings
                Settings.Default.Save();

                //Do the disposing
                if (m_currentMusic != null)
                {
                    m_currentMusic.Dispose();
                }

                m_musicCategory = new AudioCategory();
                m_soundCategory = new AudioCategory();

                m_engine.Dispose();
                m_waveBank.Dispose();
                m_soundBank.Dispose();

                disposed = true;
            }
        }
Ejemplo n.º 13
0
        //* ────________________________________*
        //* methods ───────────────────────────────-*

        //* -----------------------------------------------------------------------*
        /// <summary>
        /// アンマネージ リソースの解放およびリセットに関連付けられている
        /// アプリケーション定義のタスクを実行します。
        /// </summary>
        public void Dispose()
        {
            CLogger.add("音響リソースの解放をしています...");
            string strErr = "";

            try { if (cueBGM != null)
                  {
                      cueBGM.Dispose();
                  }
            }
            catch (Exception e) { strErr += e.ToString() + "\r\n"; }
            try { if (soundBank != null)
                  {
                      soundBank.Dispose();
                  }
            }
            catch (Exception e) { strErr += e.ToString() + "\r\n"; }
            try { if (waveBankBGM != null)
                  {
                      waveBankBGM.Dispose();
                  }
            }
            catch (Exception e) { strErr += e.ToString() + "\r\n"; }
            try { if (waveBankSE != null)
                  {
                      waveBankSE.Dispose();
                  }
            }
            catch (Exception e) { strErr += e.ToString() + "\r\n"; }
            try { if (engine != null)
                  {
                      engine.Dispose();
                  }
            }
            catch (Exception e) { strErr += e.ToString() + "\r\n"; }
            if (strErr.Length > 0)
            {
                CLogger.add(
                    "音響処理の解放に失敗しました。" + Environment.NewLine +
                    "完全に終了しないうちにウィンドウを非アクティブにするとこの現象が起きやすいです。" +
                    Environment.NewLine + Environment.NewLine + strErr);
            }
            soundBank   = null;
            cueBGM      = null;
            waveBankBGM = null;
            waveBankSE  = null;
            engine      = null;
            CLogger.add("音響リソースの解放完了。");
        }
Ejemplo n.º 14
0
        public static void Play(String _musicStr)
        {
            if (musicStr != _musicStr)
            {
                musicStr = _musicStr;

                if (musicCue != null)
                {
                    musicCue.Dispose();
                }

                musicCue = sound.GetCue(musicStr);
                musicCue.Play();
            }
        }
Ejemplo n.º 15
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         m_pupil.Dispose();
         m_pupil = null;
         m_squishSound.Dispose();
         m_squishSound = null;
         if (m_deathLoop != null && !m_deathLoop.IsDisposed)
         {
             m_deathLoop.Dispose();
         }
         m_deathLoop = null;
         base.Dispose();
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Garbage collection.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            if (!this._Disposed)
            {
                if (disposing)
                {
                    if (_Cue != null)
                    {
                        _Cue.Dispose();
                        _Cue = null;
                    }
                }

                this._Disposed = true;
            }
        }
Ejemplo n.º 17
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    sb      = null;
                    wb      = null;
                    cueName = null;
                }

                cue.Dispose();
                cue = null;

                disposed = true;
            }
        }
Ejemplo n.º 18
0
        public void Dispose()
        {
            soundName = null;

            if (sound != null)
            {
                sound.Stop(AudioStopOptions.Immediate);
                sound.Dispose();
                sound = null;
            }

            if (child != null)
            {
                child.Dispose();
                child = null;
            }
        }
Ejemplo n.º 19
0
        // Override OnExiting function to stop all sounds and save game data
        protected override void OnExiting(Object sender, EventArgs args)
        {
            loopingMusic.Stop(AudioStopOptions.Immediate);
            loopingMusic.Dispose();

            // Save the current high score
            if ((result != null) && result.IsCompleted)
            {
                device = Guide.EndShowStorageDeviceSelector(result);
                result = null;
            }
            if ((device != null) && device.IsConnected)
            {
                SaveGameData();
            }

            base.OnExiting(sender, args);
        }
Ejemplo n.º 20
0
 //* -----------------------------------------------------------------------*
 /// <summary>死んだ効果音をゆっくり破棄するスレッドです。</summary>
 ///
 /// <returns>スレッドが実行される間、<c>true</c></returns>
 private IEnumerator <object> threadGC()
 {
     while (true)
     {
         for (int i = 0; i < (isHighPriorityMode ? 6 : 20); i++)
         {
             yield return(null);
         }
         if (GRAVE_SE.Count > 0)
         {
             Cue cue = GRAVE_SE.Dequeue();
             if (cue != null)
             {
                 cue.Stop(AudioStopOptions.AsAuthored);
                 cue.Dispose();
                 cue = null;
             }
         }
     }
 }
Ejemplo n.º 21
0
        public static void Play(string musicCueName)
        {
            while (!Wave.IsPrepared)
            {
                Audio.Sound.Update();
            }

            if (string.Compare(_musicStr, musicCueName, true, CultureInfo.InvariantCulture) != 0)
            {
                _musicStr = musicCueName;

                if (_musicCue != null)
                {
                    _musicCue.Dispose();
                }

                _musicCue = Sound.GetCue(_musicStr);
                _musicCue.Play();
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Damages all actors in a radius around the rocket.
        /// </summary>
        /// <param name="touchedActor">The actor that was originally hit.</param>
        public override void Explode(Actor touchedActor)
        {
            // stop the rocket-flying cue
            if (rocketCue != null)
            {
                rocketCue.Stop(AudioStopOptions.Immediate);
                rocketCue.Dispose();
                rocketCue = null;
            }

            // play the explosion cue
            world.AudioManager.PlayCue("explosionMedium");

            // add a double-particle system effect
            world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                         Vector2.Zero, 64, 32f, 64f, 3f, 0.05f, explosionColors));
            world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                         Vector2.Zero, 16, 128f, 256f, 4f, 0.1f, explosionColors));

            base.Explode(touchedActor);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            m_audioEngine.Update();

            int index = 0;

            while (index < m_sounds.Count)
            {
                Cue cue = m_sounds[index];
                if (cue.IsStopped)
                {
                    cue.Dispose();
                    m_sounds.RemoveAt(index);
                }

                index++;
            }

            // TODO: Add your update code here

            base.Update(gameTime);
        }
Ejemplo n.º 24
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();
     }
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Defines the interaction between this projectile and a target actor
        /// when they touch.
        /// </summary>
        /// <param name="target">The actor that is touching this object.</param>
        /// <returns>True if the objects meaningfully interacted.</returns>
        public override bool Touch(Actor target)
        {
            if ((target is CFC1) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionLarge");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 128, 32f * world.ResVar, 64f * world.ResVar,
                                                             3f * world.ResVar, 0.1f * world.ResVar, world.CFC1Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 64, 64f * world.ResVar, 128f * world.ResVar,
                                                             4f * world.ResVar, 0.15f * world.ResVar, world.CFC1Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 128f * world.ResVar, 256f * world.ResVar,
                                                             5f * world.ResVar, 0.2f * world.ResVar, world.CFC1Color));
                owner.FireGamepadMotors(0.75f, 0.25f);

                target.Die(target);

                return(base.Touch(target));
            }
            if ((target is CFC2) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionLarge");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 128, 32f * world.ResVar, 64f * world.ResVar,
                                                             3f * world.ResVar, 0.1f * world.ResVar, world.CFC1Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 64, 64f * world.ResVar, 128f * world.ResVar,
                                                             4f * world.ResVar, 0.15f * world.ResVar, world.CFC1Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 128f * world.ResVar, 256f * world.ResVar,
                                                             5f * world.ResVar, 0.2f * world.ResVar, world.CFC1Color));
                owner.FireGamepadMotors(0.75f, 0.25f);

                target.Die(target);

                return(base.Touch(target));
            }
            if ((target is Hydroxyl) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 64, 32f * world.ResVar, 64f * world.ResVar,
                                                             3f * world.ResVar, 0.05f * world.ResVar, world.OHColor));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 16, 128f * world.ResVar, 256f * world.ResVar,
                                                             4f * world.ResVar, 0.1f * world.ResVar, world.OHColor));
                owner.FireGamepadMotors(0.35f, 0.25f);

                target.Die(target);
                world.UnbondHydroxyl(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is NitricOxide) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 64, 32f * world.ResVar, 64f * world.ResVar,
                                                             3f * world.ResVar, 0.05f * world.ResVar, world.NOColor));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 16, 128f * world.ResVar, 256f * world.ResVar,
                                                             4f * world.ResVar, 0.1f * world.ResVar, world.NOColor));
                owner.FireGamepadMotors(0.35f, 0.25f);

                target.Die(target);
                world.UnbondNitricOxide(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is CarbonDioxide) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.CO2Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.CO2Color));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondCarbonDioxide(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is Methane) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.CH4Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.CH4Color));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondMethane(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is NitrousOxide) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.N2OColor));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.N2OColor));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondNitrousOxide(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is Ozone) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.O3Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.O3Color));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondOzone(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is Water) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.H2OColor));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.H2OColor));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondWater(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is Deuterium) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.HHColor));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.HHColor));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondDeuterium(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is Methylene) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.CH2Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.CH2Color));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondMethylene(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is NitrogenTwo) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.CH2Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.CH2Color));
                owner.FireGamepadMotors(0.0f, 0.25f);

                target.Die(target);
                world.UnbondNitrogenTwo(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            if ((target is OxygenTwo) == true)
            {
                // stop the rocket-flying cue
                if (rocketCue != null)
                {
                    rocketCue.Stop(AudioStopOptions.Immediate);
                    rocketCue.Dispose();
                    rocketCue = null;
                }

                // play the explosion cue
                world.AudioManager.PlayCue("explosionMedium");

                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.O2Color));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.O2Color));
                owner.FireGamepadMotors(0.25f, 0.25f);

                target.Die(target);
                world.UnbondOxygenTwo(target.Position, target.Velocity, target.Direction);

                return(base.Touch(target));
            }
            else if ((target is Nitrogen) == true ||
                     (target is Oxygen) == true ||
                     (target is Hydrogen) == true ||
                     (target is Bromine) == true ||
                     (target is Chlorine) == true ||
                     (target is Carbon) == true ||
                     (target is Fluorine) == true ||
                     (target is NanoBot) == true)
            {
                // add a double-particle system effect
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 32, 16f * world.ResVar, 32f * world.ResVar,
                                                             0.3f * world.ResVar, 0.025f * world.ResVar, world.AMBColor));
                world.ParticleSystems.Add(new ParticleSystem(this.position,
                                                             Vector2.Zero, 8, 32f * world.ResVar, 64f * world.ResVar,
                                                             0.4f * world.ResVar, 0.05f * world.ResVar, world.AMBColor));
                owner.FireGamepadMotors(0.0f, 0.25f);

                return(base.Touch(target));
            }
            return(false);
        }
Ejemplo n.º 26
0
 public void Dispose()
 {
     Cue.Dispose();
 }
Ejemplo n.º 27
0
 public void Dispose()
 {
     cue.Dispose();
     cue = null;
 }
Ejemplo n.º 28
0
        public override void OnEnter()
        {
            if (Game.PlayerStats.SpecialItem == 9 && Game.PlayerStats.ChallengeEyeballBeaten)
            {
                Game.PlayerStats.SpecialItem = 0;
            }
            if (Game.PlayerStats.SpecialItem == 10 && Game.PlayerStats.ChallengeSkullBeaten)
            {
                Game.PlayerStats.SpecialItem = 0;
            }
            if (Game.PlayerStats.SpecialItem == 11 && Game.PlayerStats.ChallengeFireballBeaten)
            {
                Game.PlayerStats.SpecialItem = 0;
            }
            if (Game.PlayerStats.SpecialItem == 12 && Game.PlayerStats.ChallengeBlobBeaten)
            {
                Game.PlayerStats.SpecialItem = 0;
            }
            if (Game.PlayerStats.SpecialItem == 13 && Game.PlayerStats.ChallengeLastBossBeaten)
            {
                Game.PlayerStats.SpecialItem = 0;
            }
            Player.AttachedLevel.UpdatePlayerHUDSpecialItem();
            m_isSnowing = (DateTime.Now.Month == 12 || DateTime.Now.Month == 1);
            if (m_isSnowing)
            {
                foreach (var current in m_rainFG)
                {
                    current.ChangeToSnowflake();
                }
            }
            if (!(Game.ScreenManager.Game as Game).SaveManager.FileExists(SaveType.Map) &&
                Game.PlayerStats.HasArchitectFee)
            {
                Game.PlayerStats.HasArchitectFee = false;
            }
            Game.PlayerStats.TutorialComplete = true;
            Game.PlayerStats.IsDead           = false;
            m_lightningTimer       = 5f;
            Player.CurrentHealth   = Player.MaxHealth;
            Player.CurrentMana     = Player.MaxMana;
            Player.ForceInvincible = false;
            (Player.AttachedLevel.ScreenManager.Game as Game).SaveManager.SaveFiles(SaveType.PlayerData);
            if (TollCollectorAvailable && !Player.AttachedLevel.PhysicsManager.ObjectList.Contains(m_tollCollector))
            {
                Player.AttachedLevel.PhysicsManager.AddObject(m_tollCollector);
            }
            if (m_blacksmithAnvilSound == null)
            {
                m_blacksmithAnvilSound = new FrameSoundObj(m_blacksmith.GetChildAt(5) as IAnimateableObj, Player, 7,
                                                           "Anvil1", "Anvil2", "Anvil3");
            }
            if (Game.PlayerStats.Traits.X == 35f || Game.PlayerStats.Traits.Y == 35f)
            {
                Game.ShadowEffect.Parameters["ShadowIntensity"].SetValue(0.7f);
            }
            else
            {
                Game.ShadowEffect.Parameters["ShadowIntensity"].SetValue(0);
            }
            m_playerWalkedOut = false;
            Player.UpdateCollisionBoxes();
            Player.Position     = new Vector2(0f, 660f - (Player.Bounds.Bottom - Player.Y));
            Player.State        = 1;
            Player.IsWeighted   = false;
            Player.IsCollidable = false;
            var logicSet = new LogicSet(Player);

            logicSet.AddAction(new RunFunctionLogicAction(Player, "LockControls"));
            logicSet.AddAction(new MoveDirectionLogicAction(new Vector2(1f, 0f)));
            logicSet.AddAction(new ChangeSpriteLogicAction("PlayerWalking_Character"));
            logicSet.AddAction(new PlayAnimationLogicAction());
            logicSet.AddAction(new DelayLogicAction(0.5f));
            logicSet.AddAction(new ChangePropertyLogicAction(Player, "CurrentSpeed", 0));
            logicSet.AddAction(new ChangePropertyLogicAction(Player, "IsWeighted", true));
            logicSet.AddAction(new ChangePropertyLogicAction(Player, "IsCollidable", true));
            Player.RunExternalLogicSet(logicSet);
            Tween.By(this, 1f, Linear.EaseNone);
            Tween.AddEndHandlerToLastTween(Player, "UnlockControls");
            SoundManager.StopMusic(1f);
            m_isRaining = (CDGMath.RandomPlusMinus() > 0);
            m_isRaining = true;
            if (m_isRaining)
            {
                if (m_rainSFX != null)
                {
                    m_rainSFX.Dispose();
                }
                if (!m_isSnowing)
                {
                    m_rainSFX = SoundManager.PlaySound("Rain1");
                }
                else
                {
                    m_rainSFX = SoundManager.PlaySound("snowloop_filtered");
                }
            }
            m_tent.TextureColor            = new Color(200, 200, 200);
            m_blacksmithBoard.TextureColor = new Color(200, 200, 200);
            m_screw.TextureColor           = new Color(200, 200, 200);
            if (Game.PlayerStats.LockCastle)
            {
                m_screw.GoToFrame(m_screw.TotalFrames);
                m_architectBlock.Position = new Vector2(1492f, 579f);
            }
            else
            {
                m_screw.GoToFrame(1);
                m_architectBlock.Position = new Vector2(1492f, 439f);
            }
            Player.UpdateEquipmentColours();
            base.OnEnter();
        }
Ejemplo n.º 29
0
        public override void Update(GameTime gameTime)
        {
            if (gameTime == null)
            {
                throw new ArgumentNullException("gameTime");
            }

            // Do we need to reset
            if (currentState == CatapultState.Reset)
            {
                ResetCatapult();
            }

            // Are we currently rolling?
            if (currentState == CatapultState.Rolling)
            {
                // Add to current speed
                float speedAmt = curGame.CurrentGamePadState.Triggers.Left;
                if (curGame.CurrentKeyboardState.IsKeyDown(Keys.Right))
                {
                    speedAmt = 1.0f;
                }

                baseSpeed += speedAmt *
                             gameTime.ElapsedGameTime.Milliseconds * 0.001f;

                // Move catapult based on speed
                basePosition.X += baseSpeed * gameTime.ElapsedGameTime.Milliseconds;

                // Move pumpkin to match catapult
                pumpkinPosition.X = pumpkinLaunchPosition = basePosition.X + 120;
                pumpkinPosition.Y = basePosition.Y + 80;

                // Play moving sound
                if (playingCue == null && baseSpeed > 0)
                {
                    playingCue = curGame.SoundBank.GetCue("Move");
                    playingCue.Play();
                }

                // Check to see if we fire the pumpkin
                if ((curGame.CurrentGamePadState.Buttons.A == ButtonState.Pressed &&
                     curGame.LastGamePadState.Buttons.A != ButtonState.Pressed) ||
                    (curGame.CurrentKeyboardState.IsKeyDown(Keys.Space) &&
                     curGame.LastKeyboardState.IsKeyUp(Keys.Space)))
                {
                    Fire();
                    if (playingCue != null && playingCue.IsPlaying)
                    {
                        playingCue.Stop(AudioStopOptions.Immediate);
                        playingCue.Dispose();
                        playingCue = curGame.SoundBank.GetCue("Flying");
                        playingCue.Play();
                    }
                }
            }
            // Are we in the firing state
            else if (currentState == CatapultState.Firing)
            {
                // Rotate the arm
                if (armRotation < MathHelper.ToRadians(81))
                {
                    armRotation +=
                        MathHelper.ToRadians(gameTime.ElapsedGameTime.Milliseconds);

                    Matrix matTranslate, matTranslateBack, matRotate, matFinal;
                    matTranslate = Matrix.CreateTranslation((-pumpkinRotationPosition.X)
                                                            - 170, -pumpkinRotationPosition.Y, 0);
                    matTranslateBack =
                        Matrix.CreateTranslation(pumpkinRotationPosition.X + 170,
                                                 pumpkinRotationPosition.Y, 0);
                    matRotate = Matrix.CreateRotationZ(armRotation);
                    matFinal  = matTranslate * matRotate * matTranslateBack;

                    Vector2.Transform(ref pumpkinRotationPosition, ref matFinal,
                                      out pumpkinPosition);
                    pumpkinLaunchPosition = pumpkinPosition.X;

                    pumpkinRotation += MathHelper.ToRadians(
                        gameTime.ElapsedGameTime.Milliseconds / 10.0f);
                }
                // We are done rotating so send the pumpkin flying
                else
                {
                    currentState = CatapultState.ProjectileFlying;

                    pumpkinVelocity.X = baseSpeed * 2.0f + 1;
                    pumpkinVelocity.Y = -baseSpeed * 0.75f;

                    // Add extra velocity for Right trigger
                    float rightTriggerAmt = curGame.CurrentGamePadState.Triggers.Right;

                    if (rightTriggerAmt > 0.5f)
                    {
                        rightTriggerAmt = 1.0f - rightTriggerAmt;
                    }

                    if (curGame.CurrentKeyboardState.IsKeyDown(Keys.B))
                    {
                        rightTriggerAmt = 0.5f;
                    }

                    rightTriggerAmt *= 2;

                    pumpkinVelocity *= 1.0f + rightTriggerAmt;

                    // Check for extra boost power
                    if (basePosition.X > 620)
                    {
                        boostPower       = 3;
                        pumpkinVelocity *= 2.0f;
                        curGame.SoundBank.PlayCue("Boost");
                    }
                    else if (basePosition.X > 600)
                    {
                        boostPower       = 2;
                        pumpkinVelocity *= 1.6f;
                        curGame.SoundBank.PlayCue("Boost");
                    }
                    else if (basePosition.X > 580)
                    {
                        boostPower       = 1;
                        pumpkinVelocity *= 1.3f;
                        curGame.SoundBank.PlayCue("Boost");
                    }
                }
            }
            // Pumpkin is in the flying state
            else if (currentState == CatapultState.ProjectileFlying)
            {
                // Update the position of the pumpkin
                pumpkinPosition += pumpkinVelocity *
                                   gameTime.ElapsedGameTime.Milliseconds;
                pumpkinVelocity += pumpkinAcceleration *
                                   gameTime.ElapsedGameTime.Milliseconds;

                // Move the catapult away from the pumpkin
                basePosition.X -= pumpkinVelocity.X *
                                  gameTime.ElapsedGameTime.Milliseconds;

                // Rotate the pumpkin as it flys
                pumpkinRotation += MathHelper.ToRadians(pumpkinVelocity.X * 3.5f);

                // Is the pumpkin hitting the ground
                if (pumpkinPosition.Y > 630)
                {
                    // Stop playing any sounds
                    if (playingCue != null && playingCue.IsPlaying)
                    {
                        playingCue.Stop(AudioStopOptions.Immediate);
                        playingCue.Dispose();
                        playingCue = null;
                    }

                    // Play the bounce sound
                    // curGame.SoundBank.PlayCue("Bounce");

                    // Move the pumpkin out of the ground and Change the pumkin velocity
                    pumpkinPosition.Y  = 630;
                    pumpkinVelocity.Y *= -0.8f;
                    pumpkinVelocity.X *= 0.7f;

                    // Stop the pumpkin if the speed is too low
                    if (pumpkinVelocity.X < 0.1f)
                    {
                        currentState = CatapultState.ProjectileHit;
                        curGame.SoundBank.PlayCue("Hit");

                        if (curGame.HighScore == (int)curGame.PumpkinDistance &&
                            curGame.HighScore > 1000)
                        {
                            curGame.SoundBank.PlayCue("HighScore");
                        }
                    }
                }
            }
            // Did we crash into the log
            if (basePosition.X > 650)
            {
                currentState = CatapultState.Crash;

                if (playingCue != null && playingCue.IsPlaying)
                {
                    playingCue.Stop(AudioStopOptions.Immediate);
                    playingCue.Dispose();
                    playingCue = null;

                    if (crashCue != null)
                    {
                        crashCue.Stop(AudioStopOptions.Immediate);
                        crashCue.Dispose();
                        crashCue = null;
                    }

                    crashCue = curGame.SoundBank.GetCue("Crash");
                    crashCue.Play();
                }
            }

            // If the projectile hit or we crashed reset the catapult
            if ((currentState == CatapultState.Crash ||
                 currentState == CatapultState.ProjectileHit) &&
                (curGame.CurrentGamePadState.Buttons.A == ButtonState.Pressed ||
                 curGame.CurrentKeyboardState.IsKeyDown(Keys.Space)) &&
                curGame.CurrentGamePadState.Triggers.Left == 0 &&
                curGame.CurrentKeyboardState.IsKeyUp(Keys.Right))
            {
                currentState = CatapultState.Reset;
            }

            base.Update(gameTime);
        }