public Jet(ContentManager content,Vector2 position)
 {
     this.texture = content.Load<Texture2D>("Sprites/jet");
     this.position = position;
     this.velocity = new Vector2(-12,0);
     jet = content.Load<SoundEffect>("Sounds/Jet fly by").CreateInstance();
 }
Example #2
0
        public RhythmMelodyMetadata(SoundEffectInstance mainInstance, SoundEffectInstance backCopy)
        {
            _mainInstance = mainInstance;
            _backCopy = backCopy;

            Active = _backCopy;
        }
Example #3
0
 //Modular Constructor
 public SoundObject(SoundEffect target, Vector2 posn)
 {
     this.sound = target;
     this.position = posn;
     this.isModular = true;
     this.dynamic = sound.CreateInstance();
 }
Example #4
0
        public Player(string name, List<AnimatedTextureData> animationsList,
                    SpritePresentationInfo spritePresentationInfo,
                    SpritePositionInfo spritePositionInfo,
                    int frameRate)
            : base(name, animationsList,
                    spritePresentationInfo,
                    spritePositionInfo,
                    frameRate)
        {
            this.moveAmount = 0;
            this.velocity = Vector2.Zero;
            this.acceleration = 0.0015f;
            this.direction = Vector2.Zero;
            this.gravity = 0.0025f;
            this.jumpPower = 1.6f;
            this.springJumpPower = 2f;
            this.oldPos = new Vector2(spritePositionInfo.TRANSLATIONX, spritePositionInfo.TRANSLATIONY);
            this.hasKey = false;
            this.coins = 0;
            this.health = 3; // 3 health? 3 hearts?
            this.invulnerable = false;
            this.invulnerableTimer = 0;

            this.levelStartPos = spritePositionInfo.TRANSLATION;

            this.coinsTaken = new List<Block>();
            this.keysTaken = new List<Block>();

            this.jump = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("jump");
            this.pickup = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("pickup");
            this.hurt = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("hurt");
            this.endGame = SpriteManager.GAME.SOUNDMANAGER.getEffectInstance("endGame");
        }
Example #5
0
        /// <summary>
        /// Updates the position of the dog, and plays sounds.
        /// </summary>
        public override void Update(GameTime gameTime, AudioManager audioManager)
        {
            // Set the entity to a fixed position.
            Position = new Vector3(0, 0, -4000);
            Forward = Vector3.Forward;
            Up = Vector3.Up;
            Velocity = Vector3.Zero;

            // If the time delay has run out, start or stop the looping sound.
            // This would normally go on forever, but we stop it after a six
            // second delay, then start it up again after four more seconds.
            timeDelay -= gameTime.ElapsedGameTime;

            if (timeDelay < TimeSpan.Zero)
            {
                if (activeSound == null)
                {
                    // If no sound is currently playing, trigger one.
                    activeSound = audioManager.Play3DSound("DogSound", true, this);

                    timeDelay += TimeSpan.FromSeconds(6);
                }
                else
                {
                    // Otherwise stop the current sound.
                    activeSound.Stop(false);
                    activeSound = null;

                    timeDelay += TimeSpan.FromSeconds(4);
                }
            }
        }
Example #6
0
 public static void LoadContent(ContentManager Content)
 {
     menuLayer1 = Content.Load<SoundEffect>("audio/music/menu1").CreateInstance();
     menuLayer2 = Content.Load<SoundEffect>("audio/music/menu2").CreateInstance();
     // PLACEHOLDER
     battleMusic = Content.Load<SoundEffect>("audio/music/Drum_Loop").CreateInstance();
 }
Example #7
0
        /// <summary>
        /// Loads the textures and animations for the enemy
        /// </summary>
        /// <param name="content"></param>
        /// <param name="step"></param>
        public void LoadContent(ContentManager content, int step)
        {
            Texture2D trexTexture =
                content.Load<Texture2D>("textures/mainTrexGray");

            Color[,] colorArray = TextureTo2DArray(trexTexture);

            List<Texture2D> textures = new List<Texture2D>();
            if(step == 0)
            {
                textures.Add(content.Load<Texture2D>("textures/mainTrexGray1"));
                textures.Add(content.Load<Texture2D>("textures/mainTrexGray1"));
            }
            textures.Add(content.Load<Texture2D>("textures/mainTrexGray2"));
            textures.Add(content.Load<Texture2D>("textures/mainTrexGray0"));
            textures.Add(content.Load<Texture2D>("textures/mainTrexGray3"));
            textures.Add(content.Load<Texture2D>("textures/mainTrexGray0"));
            textures.Add(content.Load<Texture2D>("textures/mainTrexGray2"));
            textures.Add(content.Load<Texture2D>("textures/mainTrexGray0"));
            textures.Add(content.Load<Texture2D>("textures/mainTrexGray3"));

            // Texture and scale the dinosaur
            Animation = new Animator(textures);
            Animation.advance(step * 3);
            Texture = Animation.next();
            TextureArray = colorArray;

            CreateBoundingBox();

            roarSound =
                content.Load<SoundEffect>("sounds/mainTrexRoar").CreateInstance();

            roarSound.Volume = 1.0f;
            roarSound.IsLooped = false;
        }
Example #8
0
 /// <summary>
 /// This is called when the game should draw itself.
 /// </summary>
 protected override void Draw(GameTime gameTime)
 {
     graphics.GraphicsDevice.Clear(Color.Black);
     #region Play Theme
     //Play theme sound
     if (!themePlaying)
     {
         if (themeInstance == null)
         {
             themeInstance = themeMusic.Play(0.5f, 0.0f, 0.0f, true);
             themeInstance.Volume = 2.0f;
         }
         else
             themeInstance.Resume();
         themePlaying = true;
     }
     else if (themePlaying)
     {
         themeInstance.Play();
         themePlaying = false;
     }
     #endregion
     // The real drawing happens inside the screen manager component.
     base.Draw(gameTime);
 }
Example #9
0
        /// <summary>
        /// The parameterized constructor for the player class
        /// </summary>
        /// <param name="pTexture">The texture that the player will use</param>
        /// <param name="g">The GraphicsDeviceManager that will be used</param>
        public Player(Texture2D pTexture, GraphicsDeviceManager gdm, World w, Texture2D fTexture)
        {
            //Load the texture and set the vectors
            graphic = gdm;
            screenWidth = gdm.PreferredBackBufferWidth;
            screenHeight = gdm.PreferredBackBufferHeight;
            position = new Vector2(150, 50);
            body = new Rectangle((int)position.X, (int)position.Y, 50, 50);
            //TODO: add content manager

            burning = w.game.Content.Load<SoundEffect>("Audio/WAVs/fire");
            burning2 = burning.CreateInstance();

            texture = pTexture;
            flameTexture = fTexture;
            velocity = new Vector2(0, 0);
            world = w;
            world.Player = this;
            //Set the player state
            hState = HorizontalState.standing;

            //Make an array of three torches
            torches = new Torch[999];
            for (int i = 0; i < torches.Length; i++)
            {
                torches[i] = new Torch(this, fTexture, w);
            }
        }
Example #10
0
        public Box(SpriteBatch batch, ContentManager manager, int type, Point position)
            : base(batch, manager, "sprites/box")
        {
            FrameAnimation anim = new FrameAnimation(3, 16, 16, 0, 0);
            anim.FramesPerSecond = 6;
            animations.Add("box1", anim);
            anim = new FrameAnimation(1, 16, 16, 48, 0);
            anim.FramesPerSecond = 1;
            animations.Add("box2", anim);

            CurrentAnimationName = "box1";
            this.position = position;

            this.batch = batch;
            this.manager = manager;

            SoundEffect tmp;
            if (type == 1)
            {
                tmp = manager.Load<SoundEffect>("sounds/coin");
            }
            else
            {
                tmp = manager.Load<SoundEffect>("sounds/powerupa");
            }
            this.type = type;
            if (type == 4)
                visable = false;

            sound1 = tmp.CreateInstance();
            tmp = manager.Load<SoundEffect>("sounds/bump");
            sound2 = tmp.CreateInstance();
        }
Example #11
0
        public override void Initialize(ContentManager content, Vector2 position, Loot theLoot, Wave theWave)
        {
            parachuteRip = (content.Load<SoundEffect>("Music\\Rip.wav")).CreateInstance();
            FlyingTexture = content.Load<Texture2D>("Graphics\\ParachuteEnemy");
            /*
            EnemyDeathTexture = content.Load<Texture2D>("Graphics\\Enemy1Dead");
            FiringTexture = content.Load<Texture2D>("Graphics\\Enemy1Firing");

            EnemyTextureMap = new AnimatedSprite(content.Load<Texture2D>("Graphics\\Enemy1Map"), numMapRows, numMapColumns, animationSpeed);
            speed = E1Speed;
            base.Initialize(content, position, theLoot, theWave);
             * */

            base.Initialize(content, position, theLoot, theWave);

            if (inSky)
            {
                if (position.X < 0)
                {
                    speed *= 2;
                    Position = new Vector2(100, -75);
                }
                else
                {
                    speed *= 2;
                    Position = new Vector2(650, -75);
                }
            }
        }
Example #12
0
        public Motor(string name,ContentManager contentManager, string spriteName, int x, int y, Vector2 velocity,
            SoundEffect Sound, float soundVolume, float accSpeed, int mode)
            : base(contentManager, spriteName, x, y, velocity, Sound)
        {
            this.angle = 0;
              this.angleVelocity = 0;
              if(mode == 0)
              {
                  this.initialAccSpeed = accSpeed;
                  this.friction = 0.04F;
              }
              if(mode==1)
              {
                  this.initialAccSpeed = accSpeed;
                  this.friction = 0.065F;
              }

              this.accSpeed = this.initialAccSpeed;

              this.motorName = name;
              this.soundVolume = soundVolume;
              this.mode = mode;

              if (Sound != null)
              {
                  soundMotorInstance = this.Sound.CreateInstance();
                  soundMotorInstance.IsLooped = true;
                  soundMotorInstance.Volume = soundVolume - 0.2F;
                  this.soundMotorInstance.Play();
                  this.soundIsPlaying = true;
              }
        }
Example #13
0
 public static void Play(SoundEffectInstance sound, float volume, float pan, float pitch)
 {
     sound.Play();
     sound.Volume = volume;
     sound.Pan = pan;
     sound.Pitch = pitch;
 }
Example #14
0
 public static int AddInstance(SoundEffectInstance instance)
 {
     _idCounter++;
     _soundEffects.Add(_idCounter, instance);
     _soundInstancesLoaded++;
     return _idCounter;
 }
Example #15
0
        public static void Initialize(ContentManager content)
        {
            scream = content.Load<SoundEffect>("Assets/Sounds/deathScream");
            collectSound = content.Load<SoundEffect>("Assets/Sounds/itemCollect");
            checkpointHell = content.Load<SoundEffect>("Assets/Sounds/CheckpointHell");
            checkpointCrystal = content.Load<SoundEffect>("Assets/Sounds/CheckpointCristall");
            fireball = content.Load<SoundEffect>("Assets/Sounds/Fireball");
            freezingIce = content.Load<SoundEffect>("Assets/Sounds/freezingIce");
            whip = content.Load<SoundEffect>("Assets/Sounds/whip");
            laser = content.Load<SoundEffect>("Assets/Sounds/laser");
            SeraphinScream = content.Load<SoundEffect>("Assets/Sounds/SeraphinScream");
            thunder = content.Load<SoundEffect>("Assets/Sounds/thunder");
            spear = content.Load<SoundEffect>("Assets/Sounds/spear");
            claws = content.Load<SoundEffect>("Assets/Sounds/claws");
            mainMenu = content.Load<SoundEffect>("Assets/Sounds/mainMenu");
            menu = mainMenu.CreateInstance();
            menu.IsLooped = true;
            punch = content.Load<SoundEffect>("Assets/Sounds/punch");
            waterSound = content.Load<SoundEffect>("Assets/Sounds/water");
            water = waterSound.CreateInstance();
            spawn = content.Load<SoundEffect>("Assets/Sounds/spawn");
            minionsFraktus = content.Load<SoundEffect>("Assets/Sounds/minions");
            goldCave = content.Load<SoundEffect>("Assets/Sounds/GoldCave");
            cave = goldCave.CreateInstance();
            //cave.IsLooped = true;

            //background crystal
            crystalBackground = content.Load<SoundEffect>("Assets/Sounds/crystalBackground");
            crystalBG = crystalBackground.CreateInstance();
            crystalBG.Volume = 0.25f;
            crystalBG.IsLooped = true;
        }
Example #16
0
        public ParticleSystem(Game game, Player player, bool isSand = false)
            : base(game)
        {
            DrawOrder = 50;
            Player = player;
            Particles = new Dictionary<string, Particle>(1000);
            IsSand = isSand;
            _particleQueue = new HashSet<Particle>();
            _createParticleQueue = new HashSet<Particle>();

            if(IsSand)
            {
                _fireParticles = new ParticleSystem(Game, Player);

                Children.Add(_fireParticles);

                _burningSound = Storage.Sound("SandBurning").CreateInstance();
                _burningSound.Volume = 0.0f;
                _burningSound.IsLooped = true;
                _burningSound.Play();

                _updateRemoteSandTimer = new Animation { CompletedDelegate = UpdateRemoteSand };
                _updateRemoteSandTimerGroup = new AnimationGroup(_updateRemoteSandTimer, 60) { Loops = true };

                Storage.AnimationController.AddGroup(_updateRemoteSandTimerGroup);
            }
        }
Example #17
0
 public void PlayEffect(SoundEffectInstance effect, float duration)
 {
     SoundEffectDescriptor sd = new SoundEffectDescriptor();
     sd.Effect = effect;
     sd.RemainingDuration = duration;
     _effects.Add(sd);
 }
        public MenuScreen()
        {
            isActive = false;
            isHidden = true;
            canLauchChallenge = false;

            menuSound = SoundEffectLibrary.Get("cursor").CreateInstance();

            m_sprite = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("menu_start_bg"), m_transform);
            m_sprite.Transform.Position = outPos;
            arrow = new Sprite(Program.TheGame, TextureLibrary.GetSpriteSheet("arrow"), new Transform(m_transform, true));

            moveTo = new MoveToStaticAction(Program.TheGame, m_transform, inPos, 1);
            moveTo.StartPosition = new Vector2(80, 200);
            moveTo.Interpolator = new PSmoothstepInterpolation();
            moveTo.Timer.Interval = 0.5f;

            moveOut = new MoveToStaticAction(Program.TheGame, m_transform, outPos, 1);
            moveOut.StartPosition = inPos;
            moveOut.Interpolator = new PSmoothstepInterpolation();
            moveOut.Timer.Interval = 0.5f;

            choice = MenuState.START;
            challengeChoice = ChallengeState.CHALL_1;
        }
Example #19
0
 public static void RemoveSoundInstance(SoundEffectInstance instance)
 {
     lock (Sync)
     {
         States.Remove(instance);
     }
 }
Example #20
0
 public static void AddSoundInstance(SoundEffectInstance instance)
 {
     lock (Sync)
     {
         States.Add(instance, instance.State);
     }
 }
Example #21
0
 public static void PlayTheme()
 {
     _themeIntance = _theme.CreateInstance();
      _themeIntance.IsLooped = true;
      _themeIntance.Volume = .8f;
      _themeIntance.Play();
 }
        public override bool PreKill(int timeLeft)
        {
            Microsoft.Xna.Framework.Audio.SoundEffectInstance snd = Main.PlaySound(SoundID.Item110, projectile.Center);
            if (snd != null)
            {
                snd.Pitch = 0.50f;
            }

            for (int i = 0; i < 16; i++)
            {
                Vector2 velocity = Main.rand.NextVector2Circular(8f, 8f) * Main.rand.NextFloat(0.2f, 1f);

                int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.AncientLight);
                Main.dust[dust].scale     = 1.00f;
                Main.dust[dust].fadeIn    = 1.5f;
                Main.dust[dust].color     = TorchGodSummonMinion.TorchColors[(int)projectile.ai[0] % 16];
                Main.dust[dust].alpha     = 250;
                Main.dust[dust].velocity  = velocity;
                Main.dust[dust].noGravity = true;

                velocity = Main.rand.NextVector2Circular(16f, 16f);

                dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.AncientLight);
                Main.dust[dust].scale     = 1.50f;
                Main.dust[dust].fadeIn    = 0.25f;
                Main.dust[dust].color     = TorchGodSummonMinion.TorchColors[(int)projectile.ai[0] % 16];
                Main.dust[dust].alpha     = 250;
                Main.dust[dust].velocity  = velocity;
                Main.dust[dust].noGravity = true;
            }


            return(true);
        }
Example #23
0
        public Boss(EnemyType type, Vector2 position, Texture2D sheet, List<Point> path, bool loop, int pathnode, int scene)
            : base(type, position, sheet, path, loop, pathnode, scene)
        {
            numFrames = 2;
            animTime = 50;
            isAnimating = true;

            Speed = 0f;

            frameSize = new Vector2(128,128);
            frameOffset = new Vector2(64, 125);
            hitRadius = 30 * scale;

            centerOffestLength = 32 * scale;

            fireRate = 50;
            fireCountdown = 50;

            HP = 150;

            jeepSound = AudioController.effects["truck"].CreateInstance();
            jeepSound.Volume = 0f;
            jeepSound.IsLooped = true;
            jeepSound.Play();
        }
Example #24
0
        public static void Initialize(ContentManager content)
        {
            try
            {

                Start_Bgm = content.Load<SoundEffect>(@"Sounds\\Start");
                Start_Bgm_Instance = Start_Bgm.CreateInstance();
                Start_Bgm_Instance.IsLooped = true;

                Stage1_3_Bgm = content.Load<SoundEffect>(@"Sounds\\Stage1_3");
                Stage1_3_Bgm_Instance = Stage1_3_Bgm.CreateInstance();
                Stage1_3_Bgm_Instance.IsLooped = true;

                Stage4_6_Bgm = content.Load<SoundEffect>(@"Sounds\\Stage4_6");
                Stage4_6_Bgm_Instance = Stage4_6_Bgm.CreateInstance();
                Stage4_6_Bgm_Instance.IsLooped = true;

                playerShot = content.Load<SoundEffect>(@"Sounds\\Shot1");
                enemyShot = content.Load<SoundEffect>(@"Sounds\\Shot2");

                enemy3Shot = content.Load<SoundEffect>(@"Sounds\\Explosion1");
                Enemy6_pattern1 = content.Load<SoundEffect>(@"Sounds\\Enemy6_pattern1");
                Enemy6_pattern1_2 = content.Load<SoundEffect>(@"Sounds\\Enemy6_pattern1_2");
                for (int x = 1; x <= explosionCount; x++)
                {
                    explosions.Add(content.Load<SoundEffect>(@"sounds\Explosion" + x.ToString()));
                }
            }
            catch
            {
                Debug.Write("SoundManager Initialization Failed");
            }
        }
 public SmallMarioJumpEffect()
 {
     backgroundSoundEffect = SoundEffect.FromStream(backgroundSoundFile);
     instance = backgroundSoundEffect.CreateInstance();
     instance.Volume = 0.25f;
     instance.IsLooped = false;
 }
Example #26
0
        protected void AmbientToggle(KeyboardState currentKeyboardState, GamePadState currentGamePadState)
        {
            // toggle Ambient - Night/Day effect
            if (previousKeyboardState.IsKeyDown(Keys.E) &&
                currentKeyboardState.IsKeyUp(Keys.E) ||
                previousGamePadState.IsButtonDown(Buttons.RightShoulder) &&
                currentGamePadState.IsButtonUp(Buttons.RightShoulder))
            {
                ambient = !ambient;

                currentMusic.Stop();
                currentMusic.Dispose();

                // Ambient true sets to day time effect, false sets to night time effect
                if(ambient)
                {
                    skyColor = Color.DeepSkyBlue;
                    effect.Parameters["material"].StructureMembers["ambient"].SetValue(new Vector4(0.65f, 0.65f, 0.6f, 1.0f));
                    currentMusic = musicDay.CreateInstance();

                }
                else
                {
                    skyColor = Color.DarkSlateGray;
                    effect.Parameters["material"].StructureMembers["ambient"].SetValue(new Vector4(0.1f, 0.1f, 0.15f, 1.0f));
                    currentMusic = musicNight.CreateInstance();
                }
                enemy.Apply3DAudio(listener, enemy.Position, currentMusic);
                currentMusic.Play();

            }
        }
Example #27
0
        public void CreatePlane()
        {
            // Already created plane?
            if (plane != -1)
            {
                factory.Objects[plane].sprite.Location = new Vector2(-LengthAddedfromZoom - factory.Objects[plane].sprite.BoundingBoxRect.Width, -650);
                return;
            }

            plane = factory.Create((int)RaginRovers.GameObjectTypes.PLANE,
                Vector2.Zero,
                "plane_with_banner",
                Vector2.Zero,
                0f,
                0f,
                0f);
            factory.Objects[plane].sprite.Location = new Vector2(-LengthAddedfromZoom - factory.Objects[plane].sprite.BoundingBoxRect.Width, -850); //moved plane up 100 pixels so won't collide with that one map
            factory.Objects[plane].sprite.Scale = 2;
            factory.Objects[plane].sprite.PhysicsBodyFixture = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(factory.Objects[plane].sprite.BoundingBoxRect.Width), ConvertUnits.ToSimUnits(factory.Objects[plane].sprite.BoundingBoxRect.Height), 1, ConvertUnits.ToSimUnits(new Vector2(0, 0)), factory.Objects[plane].sprite.PhysicsBody);
            factory.Objects[plane].sprite.PhysicsBodyFixture.OnCollision += new OnCollisionEventHandler(factory.Objects[plane].sprite.HandleCollision);
            factory.Objects[plane].saveable = false;

            soundBuzz = AudioManager.Instance.GetSoundEffectLooped("airplane");
            soundBuzz.Volume = 0.2f;
            soundBuzz.Play();

            isCreated = true;
        }
Example #28
0
 public void m000001()
 {
     c000075 c;
     if (f00003e == null)
     {
         f00003e = c000031.m000059(@"Image\Effect\shiplight");
     }
     this.f00013c = new c000029(this.f000038.m000062());
     this.f00020b = c000031.LoadSoundEffect(@"MP3\SuperWeaponAlert").CreateInstance();
     this.f00020b.IsLooped = true;
     this.f00020b.Volume = GameSetting.Instance().m000307() * 0.2f;
     if (GameSetting.Instance().m00009d() == enum0276.f000001)
     {
         c = c000031.m000052(@"Image\Face\superweapon");
     }
     else
     {
         c = c000031.m000052(@"Image\EImage\superweapon");
     }
     c.m000143(2f);
     this.f00013c.m000030(c);
     this.f00013c.m00002f().m000356(false);
     this.f0001ab = new c000029(this.f000038.m000062());
     c000075 c2 = c000031.m000058(f00003e, 0.02f);
     c2.m000143(1.9f);
     c2.m000356(false);
     this.f0001ab.m000030(c2);
     this.f0001ab.m000023(new Vector2(312f, 265f));
 }
Example #29
0
        public Sounds(Song song1, Song song2, Song song3, SoundEffect blimpEngineSound, SoundEffect explosionSound, SoundEffect failedSound,
            Song gameStartSound, SoundEffect playerEngineSound, SoundEffect rewardSound, SoundEffect shotSound)
        {
            level1Music = song1;
            level2Music = song2;
            level3Music = song3;
            MediaPlayer.IsRepeating = true;

            blimpEngineSE = blimpEngineSound;
            blimpEngineSEI = blimpEngineSE.CreateInstance();
            blimpEngineSEI.IsLooped = true;
            blimpEngineSEI.Pitch = 0.0f;
            blimpEngineSEI.Pan = 0.0f;

            missileEngineSE = blimpEngineSound;
            missileEngineSEI = missileEngineSE.CreateInstance();
            missileEngineSEI.IsLooped = true;
            missileEngineSEI.Pitch = 1.0f;
            missileEngineSEI.Pan = 0.0f;

            playerEngineSE = playerEngineSound;
            playerEngineSEI = playerEngineSE.CreateInstance();
            playerEngineSEI.IsLooped = true;
            playerEngineSEI.Pitch = -1.0f;

            explosionSE = explosionSound;
            failedSE = failedSound;
            gameStart = gameStartSound;
            rewardSE = rewardSound;
            shotSE = shotSound;
        }
Example #30
0
        public GameManager(Game game, int level)
        {
            mGame = game;

            mPlayer1 = new Character(game, new Pointf(400, 200), new Size(32, 32), new Velocity(), PlayerIndex.One);
            mPlayer2 = new Character(game, new Pointf(350, 200), new Size(32, 32), new Velocity(), PlayerIndex.Two);
            mBoss = null;
            mLevel = level;
            switch (level)
            {
                case 1:
                    mMap = MapBuilder.BuildLevel1(mGame, new Size(game.Window.ClientBounds.Width, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), ref mPlayer1);
                    mPlayer1.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(0.5f, 1));
                    mPlayer2.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(0.5f, 1));
                    mBackgroundSong = mGame.Content.Load<Song>("music/Electrolyte - New Mission");
                    break;
                case 2:
                    mMap = MapBuilder.BuildSolo(mGame, new Size(game.Window.ClientBounds.Width, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), ref mPlayer1);
                    mPlayer1.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(0.5f, 1));
                    mPlayer2.mPosition = new Pointf(MapHelper.GetPointForColumnAndLevel(MapHelper.GetLastColumn()-1.5f, 1));
                    mBackgroundSong = mGame.Content.Load<Song>("music/Electrolyte - Plus vs Minus");
                    break;
                case 3:
                    mMap = MapBuilder.BuildBossLevel(mGame, new Size(game.Window.ClientBounds.Width, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), ref mPlayer1);
                    mBoss = new Character(game, new Pointf(350, MapHelper.GetPlatformYAtLevel(1.5f)), new Size(64, 64), new Velocity(), PlayerIndex.Three);
                    mBackgroundSong = mGame.Content.Load<Song>("music/Electrolyte - Volt");
                    break;
            }

            mHud = new Hud(new Pointf(0, game.Window.ClientBounds.Height - Hud.HUD_HEIGHT), mGame, level);

            mIsPlayingSound = false;
            mGangnamSound = game.Content.Load<SoundEffect>("newgangnam");
            mGangnamInstance = mGangnamSound.CreateInstance();
        }
        public void LoadContent(SpriteBatch spriteBatch, ContentManager Content, Viewport viewport, 
            Camera camera, Texture2D enemyTexture, GraphicsDeviceManager graphics, 
            SoundEffect _backgroundMusic, GameController _gameController, 
            SoundEffect _fireballSound, SpriteFont _spritefont, Texture2D _bossTexture)
        {
            _enemyTexture = enemyTexture;
            this.camera = camera;
            _graphics = graphics;

            spritefont = _spritefont;

            bossTexture = _bossTexture;

            backgroundMusic = _backgroundMusic;
            fireballSound = _fireballSound;

            _content = Content;
            gameController = _gameController;
            character = Content.Load<Texture2D>("imp");
            Flame.SetTexture(Content.Load<Texture2D>("Flames"));
            
            soundEffectInstance = backgroundMusic.CreateInstance();

            onFirstLevel = false;
            onSecondLevel = false;
            onThirdLevel = false;
            onFourthLevel = false;

        }
Example #32
0
 private void PlatformSetupInstance(SoundEffectInstance inst)
 {
     inst.InitializeSound();
 }
        public bool Play(float volume, float pitch, float pan)
        {
#if DIRECTX
            if (MasterVolume > 0.0f)
            {
                if (_playingInstances == null)
                {
                    // Allocate lists first time we need them.
                    _playingInstances      = new List <SoundEffectInstance>();
                    _availableInstances    = new List <SoundEffectInstance>();
                    _toBeRecycledInstances = new List <SoundEffectInstance>();
                }
                else
                {
                    // Cleanup instances which have finished playing.
                    foreach (var inst in _playingInstances)
                    {
                        if (inst.State == SoundState.Stopped)
                        {
                            _toBeRecycledInstances.Add(inst);
                        }
                    }
                }

                // Locate a SoundEffectInstance either one already
                // allocated and not in use or allocate a new one.
                SoundEffectInstance instance = null;
                if (_toBeRecycledInstances.Count > 0)
                {
                    foreach (var inst in _toBeRecycledInstances)
                    {
                        _availableInstances.Add(inst);
                        _playingInstances.Remove(inst);
                    }
                    _toBeRecycledInstances.Clear();
                }
                if (_availableInstances.Count > 0)
                {
                    instance = _availableInstances[0];
                    _playingInstances.Add(instance);
                    _availableInstances.Remove(instance);
                }
                else
                {
                    instance = CreateInstance();
                    _playingInstances.Add(instance);
                }

                instance.Volume = volume;
                instance.Pitch  = pitch;
                instance.Pan    = pan;
                instance.Play();
            }

            // XNA documentation says this method returns false if the sound limit
            // has been reached. However, there is no limit on PC.
            return(true);
#elif (WINDOWS && OPENGL) || LINUX
            if (MasterVolume > 0.0f)
            {
                SoundEffectInstance instance = CreateInstance();
                instance.Volume = volume;
                instance.Pitch  = pitch;
                instance.Pan    = pan;
                instance.Play();
            }
            return(false);
#else
            if (MasterVolume > 0.0f)
            {
                if (_instance == null)
                {
                    _instance = CreateInstance();
                }
                _instance.Volume = volume;
                _instance.Pitch  = pitch;
                _instance.Pan    = pan;
                _instance.Play();
                return(_instance.Sound.Playing);
            }
            return(false);
#endif
        }
Example #34
0
//		public XactSound (Sound sound) {
//			complexSound = false;
//			wave = sound;
//		}
        public XactSound(SoundEffectInstance sound)
        {
            complexSound = false;
            wave         = sound;
        }
Example #35
0
        public SoundEffectInstance CreateInstance()
        {
            var instance = new SoundEffectInstance(this);

            return(instance);
        }
Example #36
0
 private void PlatformSetupInstance(SoundEffectInstance instance)
 {
 }
Example #37
0
 internal void UnlinkInstance(SoundEffectInstance instance)
 {
     attachedInstances.Remove(instance);
 }
Example #38
0
 /// <summary>
 /// Adds the SoundEffectInstance to the list of playing instances.
 /// </summary>
 /// <param name="inst">The SoundEffectInstance to add to the playing list.</param>
 internal static void Remove(SoundEffectInstance inst)
 {
     _playingInstances.Add(inst);
 }
Example #39
0
        public WaveBank(AudioEngine audioEngine, string nonStreamingWaveBankFilename)
        {
            //XWB PARSING
            //Adapted from MonoXNA
            //Originally adaped from Luigi Auriemma's unxwb

            WaveBankHeader wavebankheader;
            WaveBankData   wavebankdata;
            WaveBankEntry  wavebankentry;

            wavebankdata.EntryNameElementSize = 0;
            wavebankdata.CompactFormat        = 0;
            wavebankdata.Alignment            = 0;
            wavebankdata.BuildTime            = 0;

            wavebankentry.Format            = 0;
            wavebankentry.PlayRegion.Length = 0;
            wavebankentry.PlayRegion.Offset = 0;

            int wavebank_offset = 0;

#if WINRT
            const char notSeparator = '/';
            const char separator    = '\\';
#else
            const char notSeparator = '\\';
            var        separator    = Path.DirectorySeparatorChar;
#endif
            // Check for windows-style directory separator character
            nonStreamingWaveBankFilename = nonStreamingWaveBankFilename.Replace(notSeparator, separator);

#if !ANDROID
            BinaryReader reader = new BinaryReader(TitleContainer.OpenStream(nonStreamingWaveBankFilename));
#else
            Stream       stream = Game.Activity.Assets.Open(nonStreamingWaveBankFilename);
            MemoryStream ms     = new MemoryStream();
            stream.CopyTo(ms);
            stream.Close();
            ms.Position = 0;
            BinaryReader reader = new BinaryReader(ms);
#endif
            reader.ReadBytes(4);

            wavebankheader.Version = reader.ReadInt32();

            int last_segment = 4;
            //if (wavebankheader.Version == 1) goto WAVEBANKDATA;
            if (wavebankheader.Version <= 3)
            {
                last_segment = 3;
            }
            if (wavebankheader.Version >= 42)
            {
                reader.ReadInt32();                                  // skip HeaderVersion
            }
            wavebankheader.Segments = new Segment[5];

            for (int i = 0; i <= last_segment; i++)
            {
                wavebankheader.Segments[i].Offset = reader.ReadInt32();
                wavebankheader.Segments[i].Length = reader.ReadInt32();
            }

            reader.BaseStream.Seek(wavebankheader.Segments[0].Offset, SeekOrigin.Begin);

            //WAVEBANKDATA:

            wavebankdata.Flags      = reader.ReadInt32();
            wavebankdata.EntryCount = reader.ReadInt32();

            if ((wavebankheader.Version == 2) || (wavebankheader.Version == 3))
            {
                wavebankdata.BankName = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(16), 0, 16).Replace("\0", "");
            }
            else
            {
                wavebankdata.BankName = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(64), 0, 64).Replace("\0", "");
            }

            BankName = wavebankdata.BankName;

            if (wavebankheader.Version == 1)
            {
                //wavebank_offset = (int)ftell(fd) - file_offset;
                wavebankdata.EntryMetaDataElementSize = 20;
            }
            else
            {
                wavebankdata.EntryMetaDataElementSize = reader.ReadInt32();
                wavebankdata.EntryNameElementSize     = reader.ReadInt32();
                wavebankdata.Alignment = reader.ReadInt32();
                wavebank_offset        = wavebankheader.Segments[1].Offset; //METADATASEGMENT
            }

            if ((wavebankdata.Flags & Flag_Compact) != 0)
            {
                reader.ReadInt32(); // compact_format
            }

            int playregion_offset = wavebankheader.Segments[last_segment].Offset;
            if (playregion_offset == 0)
            {
                playregion_offset =
                    wavebank_offset +
                    (wavebankdata.EntryCount * wavebankdata.EntryMetaDataElementSize);
            }

            int segidx_entry_name = 2;
            if (wavebankheader.Version >= 42)
            {
                segidx_entry_name = 3;
            }

            if ((wavebankheader.Segments[segidx_entry_name].Offset != 0) &&
                (wavebankheader.Segments[segidx_entry_name].Length != 0))
            {
                if (wavebankdata.EntryNameElementSize == -1)
                {
                    wavebankdata.EntryNameElementSize = 0;
                }
                byte[] entry_name = new byte[wavebankdata.EntryNameElementSize + 1];
                entry_name[wavebankdata.EntryNameElementSize] = 0;
            }

            sounds = new SoundEffectInstance[wavebankdata.EntryCount];

            for (int current_entry = 0; current_entry < wavebankdata.EntryCount; current_entry++)
            {
                reader.BaseStream.Seek(wavebank_offset, SeekOrigin.Begin);
                //SHOWFILEOFF;

                //memset(&wavebankentry, 0, sizeof(wavebankentry));
                wavebankentry.LoopRegion.Length = 0;
                wavebankentry.LoopRegion.Offset = 0;

                if ((wavebankdata.Flags & Flag_Compact) != 0)
                {
                    int len = reader.ReadInt32();
                    wavebankentry.Format            = wavebankdata.CompactFormat;
                    wavebankentry.PlayRegion.Offset = (len & ((1 << 21) - 1)) * wavebankdata.Alignment;
                    wavebankentry.PlayRegion.Length = (len >> 21) & ((1 << 11) - 1);

                    // workaround because I don't know how to handke the deviation length
                    reader.BaseStream.Seek(wavebank_offset + wavebankdata.EntryMetaDataElementSize, SeekOrigin.Begin);

                    //MYFSEEK(wavebank_offset + wavebankdata.dwEntryMetaDataElementSize); // seek to the next
                    if (current_entry == (wavebankdata.EntryCount - 1))
                    {              // the last track
                        len = wavebankheader.Segments[last_segment].Length;
                    }
                    else
                    {
                        len = ((reader.ReadInt32() & ((1 << 21) - 1)) * wavebankdata.Alignment);
                    }
                    wavebankentry.PlayRegion.Length =
                        len -                             // next offset
                        wavebankentry.PlayRegion.Offset;  // current offset
                    goto wavebank_handle;
                }

                if (wavebankheader.Version == 1)
                {
                    wavebankentry.Format            = reader.ReadInt32();
                    wavebankentry.PlayRegion.Offset = reader.ReadInt32();
                    wavebankentry.PlayRegion.Length = reader.ReadInt32();
                    wavebankentry.LoopRegion.Offset = reader.ReadInt32();
                    wavebankentry.LoopRegion.Length = reader.ReadInt32();
                }
                else
                {
                    if (wavebankdata.EntryMetaDataElementSize >= 4)
                    {
                        wavebankentry.FlagsAndDuration = reader.ReadInt32();
                    }
                    if (wavebankdata.EntryMetaDataElementSize >= 8)
                    {
                        wavebankentry.Format = reader.ReadInt32();
                    }
                    if (wavebankdata.EntryMetaDataElementSize >= 12)
                    {
                        wavebankentry.PlayRegion.Offset = reader.ReadInt32();
                    }
                    if (wavebankdata.EntryMetaDataElementSize >= 16)
                    {
                        wavebankentry.PlayRegion.Length = reader.ReadInt32();
                    }
                    if (wavebankdata.EntryMetaDataElementSize >= 20)
                    {
                        wavebankentry.LoopRegion.Offset = reader.ReadInt32();
                    }
                    if (wavebankdata.EntryMetaDataElementSize >= 24)
                    {
                        wavebankentry.LoopRegion.Length = reader.ReadInt32();
                    }
                }

                if (wavebankdata.EntryMetaDataElementSize < 24)
                {                              // work-around
                    if (wavebankentry.PlayRegion.Length != 0)
                    {
                        wavebankentry.PlayRegion.Length = wavebankheader.Segments[last_segment].Length;
                    }
                }// else if(wavebankdata.EntryMetaDataElementSize > sizeof(WaveBankEntry)) {    // skip unused fields
                //   MYFSEEK(wavebank_offset + wavebankdata.EntryMetaDataElementSize);
                //}

wavebank_handle:
                wavebank_offset += wavebankdata.EntryMetaDataElementSize;
                wavebankentry.PlayRegion.Offset += playregion_offset;

                // Parse WAVEBANKMINIWAVEFORMAT

                int codec;
                int chans;
                int rate;
                int align;
                //int bits;

                if (wavebankheader.Version == 1)
                {         // I'm not 100% sure if the following is correct
                    // version 1:
                    // 1 00000000 000101011000100010 0 001 0
                    // | |         |                 | |   |
                    // | |         |                 | |   wFormatTag
                    // | |         |                 | nChannels
                    // | |         |                 ???
                    // | |         nSamplesPerSec
                    // | wBlockAlign
                    // wBitsPerSample

                    codec = (wavebankentry.Format) & ((1 << 1) - 1);
                    chans = (wavebankentry.Format >> (1)) & ((1 << 3) - 1);
                    rate  = (wavebankentry.Format >> (1 + 3 + 1)) & ((1 << 18) - 1);
                    align = (wavebankentry.Format >> (1 + 3 + 1 + 18)) & ((1 << 8) - 1);
                    //bits = (wavebankentry.Format >> (1 + 3 + 1 + 18 + 8)) & ((1 << 1) - 1);

                    /*} else if(wavebankheader.dwVersion == 23) { // I'm not 100% sure if the following is correct
                     *  // version 23:
                     *  // 1000000000 001011101110000000 001 1
                     *  // | |        |                  |   |
                     *  // | |        |                  |   ???
                     *  // | |        |                  nChannels?
                     *  // | |        nSamplesPerSec
                     *  // | ???
                     *  // !!!UNKNOWN FORMAT!!!
                     *
                     *  //codec = -1;
                     *  //chans = (wavebankentry.Format >>  1) & ((1 <<  3) - 1);
                     *  //rate  = (wavebankentry.Format >>  4) & ((1 << 18) - 1);
                     *  //bits  = (wavebankentry.Format >> 31) & ((1 <<  1) - 1);
                     *  codec = (wavebankentry.Format                    ) & ((1 <<  1) - 1);
                     *  chans = (wavebankentry.Format >> (1)             ) & ((1 <<  3) - 1);
                     *  rate  = (wavebankentry.Format >> (1 + 3)         ) & ((1 << 18) - 1);
                     *  align = (wavebankentry.Format >> (1 + 3 + 18)    ) & ((1 <<  9) - 1);
                     *  bits  = (wavebankentry.Format >> (1 + 3 + 18 + 9)) & ((1 <<  1) - 1); */
                }
                else
                {
                    // 0 00000000 000111110100000000 010 01
                    // | |        |                  |   |
                    // | |        |                  |   wFormatTag
                    // | |        |                  nChannels
                    // | |        nSamplesPerSec
                    // | wBlockAlign
                    // wBitsPerSample

                    codec = (wavebankentry.Format) & ((1 << 2) - 1);
                    chans = (wavebankentry.Format >> (2)) & ((1 << 3) - 1);
                    rate  = (wavebankentry.Format >> (2 + 3)) & ((1 << 18) - 1);
                    align = (wavebankentry.Format >> (2 + 3 + 18)) & ((1 << 8) - 1);
                    //bits = (wavebankentry.Format >> (2 + 3 + 18 + 8)) & ((1 << 1) - 1);
                }

                reader.BaseStream.Seek(wavebankentry.PlayRegion.Offset, SeekOrigin.Begin);
                byte[] audiodata = reader.ReadBytes(wavebankentry.PlayRegion.Length);

                if (codec == MiniFormatTag_PCM)
                {
                    //write PCM data into a wav
#if DIRECTX
                    SharpDX.Multimedia.WaveFormat waveFormat = new SharpDX.Multimedia.WaveFormat(rate, chans);
                    sounds[current_entry] = new SoundEffect(waveFormat, audiodata, 0, audiodata.Length, wavebankentry.LoopRegion.Offset, wavebankentry.LoopRegion.Length).CreateInstance();
#else
                    sounds[current_entry] = new SoundEffectInstance(audiodata, rate, chans);
#endif
                }
                else if (codec == MiniForamtTag_WMA)     //WMA or xWMA (or XMA2)
                {
                    byte[] wmaSig = { 0x30, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x0, 0xaa, 0x0, 0x62, 0xce, 0x6c };

                    bool isWma = true;
                    for (int i = 0; i < wmaSig.Length; i++)
                    {
                        if (wmaSig[i] != audiodata[i])
                        {
                            isWma = false;
                            break;
                        }
                    }

                    //Let's support m4a data as well for convenience
                    byte[][] m4aSigs = new byte[][] {
                        new byte[] { 0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, 0x20, 0x00, 0x00, 0x02, 0x00 },
                        new byte[] { 0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, 0x20, 0x00, 0x00, 0x00, 0x00 }
                    };

                    bool isM4a = false;
                    for (int i = 0; i < m4aSigs.Length; i++)
                    {
                        byte[] sig     = m4aSigs[i];
                        bool   matches = true;
                        for (int j = 0; j < sig.Length; j++)
                        {
                            if (sig[j] != audiodata[j])
                            {
                                matches = false;
                                break;
                            }
                        }
                        if (matches)
                        {
                            isM4a = true;
                            break;
                        }
                    }

                    if (isWma || isM4a)
                    {
                        //WMA data can sometimes be played directly
#if DIRECTX
                        throw new NotImplementedException();
#elif !WINRT
                        //hack - NSSound can't play non-wav from data, we have to give a filename
                        string filename = Path.GetTempFileName();
                        if (isWma)
                        {
                            filename = filename.Replace(".tmp", ".wma");
                        }
                        else if (isM4a)
                        {
                            filename = filename.Replace(".tmp", ".m4a");
                        }
                        using (var audioFile = File.Create(filename))
                            audioFile.Write(audiodata, 0, audiodata.Length);

                        sounds[current_entry] = new SoundEffect(filename).CreateInstance();
#else
                        throw new NotImplementedException();
#endif
                    }
                    else
                    {
                        //An xWMA or XMA2 file. Can't be played atm :(
                        throw new NotImplementedException();
                    }
#if !DIRECTX
                    /* DirectX platforms can use XAudio2 to stream MSADPCM natively.
                     * This code is cross-platform, but the problem is that it just
                     * decodes ALL of the wavedata here. For XAudio2 in particular,
                     * this is probably ludicrous.
                     *
                     * You need to write a DIRECTX ADPCM reader that just loads this
                     * into the SoundEffect. No decoding should be necessary.
                     * -flibit
                     */
                }
                else if (codec == MiniFormatTag_ADPCM)
                {
                    using (MemoryStream dataStream = new MemoryStream(audiodata)) {
                        using (BinaryReader source = new BinaryReader(dataStream)) {
                            sounds[current_entry] = new SoundEffectInstance(
                                MSADPCMToPCM.MSADPCM_TO_PCM(source, (short)chans, (short)align),
                                rate,
                                chans
                                );
                        }
                    }
#endif
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            audioEngine.Wavebanks[BankName] = this;
        }
 private void PlatformSetupInstance(SoundEffectInstance instance)
 {
     instance.PlatformInitialize(_buffer);
 }
Example #41
0
        private void Play(bool pickNewWav)
        {
            var trackCount = _tracks.Length;

            // Do we need to pick a new wav to play first?
            if (pickNewWav)
            {
                switch (_variation)
                {
                case VariationType.Ordered:
                    _wavIndex = (_wavIndex + 1) % trackCount;
                    break;

                case VariationType.OrderedFromRandom:
                    _wavIndex = (_wavIndex + 1) % trackCount;
                    break;

                case VariationType.Random:
                    if (_weights == null || trackCount == 1)
                    {
                        _wavIndex = XactHelpers.Random.Next() % trackCount;
                    }
                    else
                    {
                        var sum = XactHelpers.Random.Next(_totalWeights);
                        for (var i = 0; i < trackCount; i++)
                        {
                            sum -= _weights[i];
                            if (sum <= 0)
                            {
                                _wavIndex = i;
                                break;
                            }
                        }
                    }
                    break;

                case VariationType.RandomNoImmediateRepeats:
                {
                    if (_weights == null || trackCount == 1)
                    {
                        _wavIndex = XactHelpers.Random.Next() % trackCount;
                    }
                    else
                    {
                        var last = _wavIndex;
                        var sum  = XactHelpers.Random.Next(_totalWeights);
                        for (var i = 0; i < trackCount; i++)
                        {
                            sum -= _weights[i];
                            if (sum <= 0)
                            {
                                _wavIndex = i;
                                break;
                            }
                        }

                        if (_wavIndex == last)
                        {
                            _wavIndex = (_wavIndex + 1) % trackCount;
                        }
                    }
                    break;
                }

                case VariationType.Shuffle:
                    // TODO: Need some sort of deck implementation.
                    _wavIndex = XactHelpers.Random.Next() % trackCount;
                    break;
                }
                ;
            }

            _wav = _soundBank.GetSoundEffectInstance(_waveBanks[_wavIndex], _tracks[_wavIndex]);
            if (_wav == null)
            {
                // We couldn't create a sound effect instance, most likely
                // because we've reached the sound pool limits.
                return;
            }

            // Set the volume.
            SetTrackVolume(_trackVolume);

            // Set the pitch.
            if (_pitchVar.HasValue)
            {
                _wav.Pitch = _pitchVar.Value.X + ((float)XactHelpers.Random.NextDouble() * _pitchVar.Value.Y);
            }
            else
            {
                _wav.Pitch = 0;
            }

            // This is a shortcut for infinite looping of a single track.
            _wav.IsLooped = _loopCount == 255 && trackCount == 1;
            _wav.Play();
        }
Example #42
0
 public XactSound(SoundEffectInstance sound)
 {
     this.complexSound = false;
     this.wave         = sound;
 }
Example #43
0
 public SoundEffectInstance(Microsoft.Xna.Framework.Audio.SoundEffectInstance soundEffectInstance)
 {
     this._soundEffectInstance = soundEffectInstance;
 }
Example #44
0
        public void Play(float volume, AudioEngine engine)
        {
            _cueVolume = volume;
            var category = engine.Categories[_categoryID];

            var curInstances = category.GetPlayingInstanceCount();

            if (curInstances >= category.maxInstances)
            {
                var prevSound = category.GetOldestInstance();

                if (prevSound != null)
                {
                    prevSound.SetFade(0.0f, category.fadeOut);
                    prevSound.Stop(AudioStopOptions.Immediate);
                    SetFade(category.fadeIn, 0.0f);
                }
            }

            float finalVolume = _volume * _cueVolume * category._volume[0];
            float finalPitch  = _pitch + _cuePitch;
            float finalMix    = _useReverb ? _cueReverbMix : 0.0f;

            if (_complexSound)
            {
                foreach (XactClip clip in _soundClips)
                {
                    clip.UpdateState(finalVolume, finalPitch, finalMix, _cueFilterFrequency, _cueFilterQFactor);
                    clip.Play();
                }
            }
            else
            {
                if (_wave != null)
                {
                    if (_streaming)
                    {
                        _wave.Dispose();
                    }
                    else
                    {
                        _wave._isXAct = false;
                    }
                    _wave = null;
                }

                _wave = _soundBank.GetSoundEffectInstance(_waveBankIndex, _trackIndex, out _streaming);

                if (_wave == null)
                {
                    // We couldn't create a sound effect instance, most likely
                    // because we've reached the sound pool limits.
                    return;
                }

                _wave.Pitch  = finalPitch;
                _wave.Volume = finalVolume;
                _wave.PlatformSetReverbMix(finalMix);
                _wave.Play();
            }
        }
 private void PlatformSetupInstance(SoundEffectInstance inst)
 {
     inst._soundId = _soundID;
 }
Example #46
0
 private void PlatformSetupInstance(SoundEffectInstance instance)
 {
     instance.UnitySetup(this);
 }
Example #47
0
 private void PlatformSetupInstance(SoundEffectInstance inst)
 {
     inst.InitializeSound();
     inst.BindDataBuffer(_data, Format, Size, (int)Rate);
 }
Example #48
0
 private void PlatformSetupInstance(SoundEffectInstance inst)
 {
     inst._audioBuffer = _audioBuffer;
     inst._soundPlayer = _audioBuffer.CreatePlayer();
 }