public AudioManager(MyGame game) : base(game) { myGame = game; events = new List <Event>(); game.mediator.register(this, MyEvent.C_ATTACK_BULLET_END, MyEvent.M_BITE, MyEvent.G_NextLevel, MyEvent.G_GameOver, MyEvent.M_HIT); audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb"); trackCue = soundBank.GetCue("Cowboy"); levelCompleteCue = soundBank.GetCue("LevelComplete"); trackCue.Play(); trackCue.Pause(); }
private void LoadAudioContent() { string filename = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; string path = System.IO.Path.GetDirectoryName(filename) + "\\Resources\\Audio\\"; try { _audioEngine = new AudioEngine(path + "Audio.xgs"); _waveBank = new WaveBank(_audioEngine, path + "Audio.xwb"); _soundBank = new SoundBank(_audioEngine, path + "Audio.xsb"); } catch { _audioEngine = null; _waveBank = null; _soundBank = null; throw; } }
private void SwitchAudioDevice(RendererDetail rendererDetail) { AudioEngine newAudioEngine = new AudioEngine(Path.Combine(Game1.game1.Content.RootDirectory, "XACT", "FarmerSounds.xgs"), TimeSpan.Zero, rendererDetail.RendererId); WaveBank newWaveBank = new WaveBank(newAudioEngine, Path.Combine(Game1.game1.Content.RootDirectory, "XACT", "Wave Bank.xwb")); SoundBank newSoundBank = new SoundBank(newAudioEngine, Path.Combine(Game1.game1.Content.RootDirectory, "XACT", "Sound Bank.xsb")); newAudioEngine.Update(); FixCues(newSoundBank); Game1.audioEngine.Dispose(); Game1.waveBank.Dispose(); Game1.soundBank.Dispose(); Game1.audioEngine = new SDVAudioEngineImpl(newAudioEngine); Game1.waveBank = newWaveBank; Game1.soundBank = new SoundBankWrapper(newSoundBank); Game1.musicCategory = Game1.audioEngine.GetCategory("Music"); Game1.soundCategory = Game1.audioEngine.GetCategory("Sound"); Game1.ambientCategory = Game1.audioEngine.GetCategory("Ambient"); Game1.footstepCategory = Game1.audioEngine.GetCategory("Footsteps"); Game1.musicCategory.SetVolume(Game1.options.musicVolumeLevel); Game1.soundCategory.SetVolume(Game1.options.soundVolumeLevel); Game1.ambientCategory.SetVolume(Game1.options.ambientVolumeLevel); Game1.footstepCategory.SetVolume(Game1.options.footstepVolumeLevel); AmbientLocationSounds.InitShared(); if (Game1.currentLocation != null) { Game1.locationCues.Update(Game1.currentLocation); } string prevAudioDevice = Settings.SelectedAudioDevice; Settings.SelectedAudioDevice = rendererDetail.FriendlyName; StoreSettings(); curAudioOptionsDropDown?.UpdateDeviceList(); Log("Switched Audio Device: " + Settings.SelectedAudioDevice + " (previous: " + prevAudioDevice + ")"); }
protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //load font scoreFont = Content.Load <SpriteFont>(@"fonts\score"); scoreBoldFont = Content.Load <SpriteFont>(@"fonts\scoreBold"); // Load the XACT data audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb"); cursorTexture = Content.Load <Texture2D>(@"Images\background"); // Start the soundtrack audio trackCue = soundBank.GetCue("track"); trackCue.Play(); // Play the start sound soundBank.PlayCue("start"); }
public static void Initial() { try { string dir = Directories.SoundDirectory; audioEngine = new AudioEngine(Path.Combine(dir, "SmartTank1.xgs")); waveBank = new WaveBank(audioEngine, Path.Combine(dir, "Wave Bank.xwb")); if (waveBank != null) { soundBank = new SoundBank(audioEngine, Path.Combine(dir, "Sound Bank.xsb")); } } catch (NoAudioHardwareException ex) { Log.Write("Failed to create sound class: " + ex.ToString()); } }
public void WaveBankCtor() { Assert.Throws <ArgumentNullException>(() => new WaveBank(null, null)); Assert.Throws <ArgumentNullException>(() => new WaveBank(_audioEngine, null)); Assert.Throws <ArgumentNullException>(() => new WaveBank(_audioEngine, "")); //Assert.Throws<DirectoryNotFoundException>(() => new WaveBank(_audioEngine, @"This\Does\Not\Exist.xwb")); Assert.Throws <FileNotFoundException>(() => new WaveBank(_audioEngine, @"Assets\Audio\Win\NotTheFile.xwb")); var waveBank = new WaveBank(_audioEngine, @"Assets\Audio\Win\Tests.xwb"); Assert.False(waveBank.IsInUse); Assert.False(waveBank.IsDisposed); Assert.True(waveBank.IsPrepared); waveBank.Dispose(); Assert.True(waveBank.IsDisposed); Assert.False(waveBank.IsInUse); Assert.False(waveBank.IsPrepared); }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { if (content == null) { content = new ContentManager(ScreenManager.Game.Services, "Content"); } // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); spriteBatch = ScreenManager.SpriteBatch; arial = content.Load <SpriteFont>("Arial"); infoFont = content.Load <SpriteFont>("Info"); level = content.Load <Level>("cool"); cursor = content.Load <Texture2D>("cursor"); bullet = content.Load <Texture2D>("bullet"); enemy = content.Load <Texture2D>("enemy"); gui = content.Load <Texture2D>("gui"); waveButton = content.Load <Texture2D>("wave button"); waveButtonPressed = content.Load <Texture2D>("wave button hover"); window = content.Load <Texture2D>("window"); LoadTowerTextures(); SetUpWaves(); SetUpGui(); audioEngine = new AudioEngine("Content/xactProject3.xgs"); waveBank = new WaveBank(audioEngine, "Content/myWaveBank.xwb"); soundBank = new SoundBank(audioEngine, "Content/mySoundBank.xsb"); }
protected override void Initialize() { if (!initialized) { enterTransitionDuration = 200; exitTransitionDuration = 1000; base.Initialize(); LoadContent(); videoplayer = new VideoPlayer(); videoplayer.IsLooped = false; audioEngine2 = new AudioEngine("Content\\Audio\\MyGameAudio2.xgs"); waveBank2 = new WaveBank(audioEngine2, "Content\\Audio\\Wave Bank2.xwb"); soundBank2 = new SoundBank(audioEngine2, "Content\\Audio\\Sound Bank2.xsb"); BTX = new Texture2D[2] { BTxN, BTxO }; vbtx = new Rectangle(950, 0, BTX[indiceDoBotão].Width / 6, BTX[indiceDoBotão].Height / 6); } }
/******************************************************************************************* * Main Load * *****************************************************************************************/ protected override void LoadContent() { // load font spriteBatch = new SpriteBatch(GraphicsDevice); statsFont = Content.Load <SpriteFont>("Fonts/StatsFont"); instructionsFont = Content.Load <SpriteFont>("Fonts/InstructionsFont"); // load sounds and play initial sound audioEngine = new AudioEngine("Content/Audio/GameAudio.xgs"); waveBank = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb"); trackCue = soundBank.GetCue("Tracks"); trackCue.Play(); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // load spaceship spaceship.LoadContent(Content, "Models/spaceship"); CreateObstacles1(); CreateObstacles2(); CreateObstacles3(); CreateObstacles4(); CreateObstacles5(); CreateObstacles6(); CreateAstronauts(); CreateStars(); // load ground ground.LoadContent(Content, "Models/ground"); // load lifebar lifebar = Content.Load <Texture2D>("Textures/lifebar5"); // load uhd uhd = Content.Load <Texture2D>("Textures/uhd"); // load logo logo = Content.Load <Texture2D>("Textures/logo"); }
public ShipGameGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; audioEngine = new AudioEngine("content/sounds/sounds.xgs"); waveBank = new WaveBank(audioEngine, "content/sounds/Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, "content/sounds/Sound Bank.xsb"); game = new GameManager(soundBank); graphics.PreferredBackBufferWidth = GameOptions.ScreenWidth; graphics.PreferredBackBufferHeight = GameOptions.ScreenHeight; //graphics.MinimumPixelShaderProfile = ShaderProfile.PS_2_0; //graphics.MinimumVertexShaderProfile = ShaderProfile.VS_1_1; IsFixedTimeStep = renderVsync; graphics.SynchronizeWithVerticalRetrace = renderVsync; }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { // TODO: Add your initialization code here #if WINDOWS m_audioEngine = new AudioEngine("Content/Audio/Praedonum.xgs"); m_waveBank = new WaveBank(m_audioEngine, "Content/Audio/Wave Bank.xwb"); m_soundBank = new SoundBank(m_audioEngine, "Content/Audio/Sound Bank.xsb"); #endif #if XBOX // TODO CHANGE THESE m_audioEngine = new AudioEngine("Content/Xact Tower.xgs"); m_waveBank = new WaveBank(m_audioEngine, "Content/WaveBank.xwb"); m_soundBank = new SoundBank(m_audioEngine, "Content/SoundBank.xsb"); #endif m_sounds = new List <Cue>(); base.Initialize(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("Main"); GUISprites = Content.Load <Texture2D>("robotica_sprites_new"); PlayerSprites = Content.Load <Texture2D>("robotica_player_new_bright"); Shadow = Content.Load <Texture2D>("robotica_shadow"); RoomBack = Content.Load <Texture2D>("robotica_green"); Lock = Content.Load <Texture2D>("lock"); Missing = Content.Load <Texture2D>("missing"); Weapon = Content.Load <Texture2D>("robotica_weapon"); Audio = new AudioEngine("Content\\Robotica.xgs"); SoundEffectsBank = new SoundBank(Audio, "Content\\Sound Bank.xsb"); WaveEffectsBank = new WaveBank(Audio, "Content\\Wave Bank.xwb"); for (var i = 0; i < 16; i++) { Entities.Add(new EntityWeapon(new Vector2(128 + i % 4 * 64, 128 + (i / 4) * 64))); } try { var reader = new FileStream("./Config/splash.txt", FileMode.Open); var sb = new StringBuilder(); var c = '\0'; while (reader.Position < reader.Length) { while ((c = (char)reader.ReadByte()) != '\n' && reader.Position != reader.Length) { sb.Append(c); } SplashStrings.Add(sb.ToString().Trim()); sb.Clear(); } splash = rand.Next(SplashStrings.Count); } catch (Exception) { SplashStrings.Add("YOU REALLY SHOULD HAVE THAT FILE!"); } // TODO: use this.Content to load your game content here }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { Sonya.Initialize(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); SubZero.Initialize(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); SonyaGreenBar.health(new Vector2(graphics.PreferredBackBufferWidth / 45, graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.LimeGreen); SonyaRedBar.health(new Vector2(graphics.PreferredBackBufferWidth / 45, graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.Red); SubZGreenBar.health(new Vector2(graphics.PreferredBackBufferWidth - 580, graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.LimeGreen); SubZRedBar.health(new Vector2(graphics.PreferredBackBufferWidth - 580, graphics.PreferredBackBufferHeight / 30), SonyaHealth, Color.Red); audioEngine = new AudioEngine("Content\\game music.xgs"); waveBank = new WaveBank(audioEngine, "Content\\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, "Content\\Sound Bank.xsb"); musicCue = soundBank.GetCue("fighting backgorund music"); musicCue.Play(); base.Initialize(); this.IsMouseVisible = false; }
public void LoadSounds() { _engine = new AudioEngine("Content\\Sounds\\BackSounds.xgs"); _soundBank = new SoundBank(_engine, "Content\\Sounds\\Sound Bank.xsb"); _waveBank = new WaveBank(_engine, "Content\\Sounds\\Wave Bank.xwb"); _engine.GetCategory("Music"); Sounds.Add(SoundEnum.Click, _soundBank.GetCue("RICOCHET")); Sounds.Add(SoundEnum.Desert, _soundBank.GetCue("wind03")); Sounds.Add(SoundEnum.DeadSpider, _soundBank.GetCue("guts04a")); Sounds.Add(SoundEnum.Grass, _soundBank.GetCue("cricket00")); Sounds.Add(SoundEnum.Gunshot, _soundBank.GetCue("GUNSHOT")); Sounds.Add(SoundEnum.Heartbeat, _soundBank.GetCue("heartbeat")); Sounds.Add(SoundEnum.Laser, _soundBank.GetCue("LASER")); Sounds.Add(SoundEnum.Lava, _soundBank.GetCue("lava_burn1")); Sounds.Add(SoundEnum.Lava2, _soundBank.GetCue("lava")); Sounds.Add(SoundEnum.MainTheme, _soundBank.GetCue("STARWARS")); Sounds.Add(SoundEnum.Sand, _soundBank.GetCue("wind03")); Sounds.Add(SoundEnum.Snow, _soundBank.GetCue("wind01b")); Sounds.Add(SoundEnum.Spider, _soundBank.GetCue("angry")); }
/// <summary> /// Removes a wave bank /// </summary> /// <param name="waveBankFile">The wave bank to remove</param> #endregion public static void RemoveWaveBank(string waveBankFile) { if (mXnaWaveBanks.ContainsKey(waveBankFile)) { WaveBank wb = mXnaWaveBanks[waveBankFile]; mXnaWaveBanks.Remove(waveBankFile); wb.Dispose(); if (mDefaultWaveBank == waveBankFile) { if (mXnaWaveBanks.Count > 0) { mDefaultWaveBank = mXnaWaveBanks.Keys.GetEnumerator().Current; } else { mDefaultWaveBank = string.Empty; } } } }
public override void Entry(IModHelper helper) { DefaultSoundBank = Game1.soundBank; DefaultWaveBank = Game1.waveBank; ModHelper = helper; ModMonitor = Monitor; StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; musicManager = new MusicManager(); MusicPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Music"); WavMusicDirectory = Path.Combine(MusicPath, "Wav"); XACTMusicDirectory = Path.Combine(MusicPath, "XACT"); TemplateMusicDirectory = Path.Combine(MusicPath, "Templates"); this.createDirectories(); this.createBlankXACTTemplate(); //load in all packs here. }
/********* ** Public methods *********/ /// <inheritdoc /> /// <summary>Initialise the mod.</summary> /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param> public override void Entry(IModHelper helper) { _config = helper.ReadConfig <ModConfigModel>(); if (Constants.TargetPlatform == GamePlatform.Windows && _config.EnableWhistleAudio) { try { _customSoundBank = new SoundBankWrapper(new SoundBank(Game1.audioEngine, Path.Combine(helper.DirectoryPath, "assets", "CustomSoundBank.xsb"))); _customWaveBank = new WaveBank(Game1.audioEngine, Path.Combine(helper.DirectoryPath, "assets", "CustomWaveBank.xwb")); _hasAudio = true; } catch (ArgumentException ex) { _customSoundBank = null; _customWaveBank = null; _hasAudio = false; Monitor.Log("Couldn't load audio, so the whistle sound won't play."); Monitor.Log(ex.ToString(), LogLevel.Trace); } } // add all event listener methods Helper.Events.Input.ButtonPressed += OnButtonPressed; if (!_config.EnableGrid) { return; } Helper.Events.GameLoop.UpdateTicked += (sender, e) => { if (e.IsMultipleOf(2)) { UpdateGrid(); } }; Helper.Events.Display.Rendered += (sender, e) => DrawGrid(Game1.spriteBatch); }
/// <summary> /// Garbage collection. /// </summary> protected override void Dispose(bool disposing) { try { if (disposing) { if (_MusicCue1 != null) { _MusicCue1.Dispose(); _MusicCue1 = null; } if (_MusicCue2 != null) { _MusicCue2.Dispose(); _MusicCue2 = null; } if (_SoundBank != null) { _SoundBank.Dispose(); _SoundBank = null; } if (_WaveBank != null) { _WaveBank.Dispose(); _WaveBank = null; } if (_AudioEngine != null) { _AudioEngine.Dispose(); _AudioEngine = null; } } } finally { base.Dispose(disposing); } }
private static void PlayWhistle() { if (LoadSound < 0) { return; } if (LoadSound == 0) { try { MySoundBank = new SoundBankWrapper(new SoundBank(Game1.audioEngine, Path.Combine(ModMain.ModHelper.DirectoryPath, "Assets", "WhistleSoundBank.xsb"))); MyWaveBank = new WaveBank(Game1.audioEngine, Path.Combine(ModMain.ModHelper.DirectoryPath, "Assets", "WhistleWaveBank.xwb")); OrgSoundBank = Game1.soundBank; OrgWaveBank = Game1.waveBank; LoadSound = 1; } catch (ArgumentException ex) { LoadSound = -1; } } try { Game1.soundBank = MySoundBank; Game1.waveBank = MyWaveBank; Game1.audioEngine.Update(); Game1.playSound("horseWhistle"); } finally { Game1.soundBank = OrgSoundBank; Game1.waveBank = OrgWaveBank; Game1.audioEngine.Update(); } }
void LoadContent_Sound() { beep = Content.Load <SoundEffect>("button-42"); beepInstance = beep.Create(); // Load Sounds ergonWave = Content.Load <SoundEffect>("ergon.adpcm"); ergonWaveInstance = ergonWave.Create(); ergonWaveInstance.IsLooped = true; waveBank = Content.Load <WaveBank>("TestBank"); // setup tests tiles = new List <SoundTile>(); Rectangle border = new Rectangle(); border.X = SoundTile.Padding.X; border.Y = SoundTile.Padding.Y; AddTile(ref border, "Click to play looped SoundEffectInstance of " + ergonWave.Name, PlayMusic, PauseMusic); AddTile(ref border, "Click to play 'PewPew' wave bank entry", () => waveBank.Play("PewPew")); AddTile(ref border, "Click to play 'PewPew' wave bank entry with random pitch and pan", () => waveBank.Play("PewPew", 1, random.NextFloat(-1, 1), random.NextFloat(-1, 1))); AddTile(ref border, "Click to play 'PewPew' with 3D audio", PlayAudio3D, StopAudio3D); AddTile(ref border, "Click to play 'Button-42' ", beepInstance.Play, beepInstance.Stop); // setup 3D geometryEffect = ToDisposeContent(new BasicEffect(GraphicsDevice) { View = Matrix.LookAtRH(new Vector3(0, 10, 20), new Vector3(0, 0, 0), Vector3.UnitY), Projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f), World = Matrix.Identity }); cube = ToDisposeContent(GeometricPrimitive.Cube.New(GraphicsDevice)); // Load the texture listenerTexture = Content.Load <Texture2D>("listen"); emitterTexture = Content.Load <Texture2D>("speaker"); geometryEffect.TextureEnabled = true; }
/// <summary> /// Constructor. /// </summary> /// <param name="name"></param> /// <param name="directoryToXwb"></param> /// <param name="pathToWaveBank"></param> /// <param name="pathToSoundBank"></param> public XACTMusicPack(string directoryToXwb, string pathToWaveBank, string pathToSoundBank) { this.directory = directoryToXwb; this.WaveBankPath = pathToWaveBank; this.SoundBankPath = pathToSoundBank; this.setModDirectoryFromFullDirectory(); this.songInformation = new SongSpecifics(); this.currentCue = null; this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToXwb); if (this.musicPackInformation == null) { if (StardewSymphony.Config.EnableDebugLog) { StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToXwb + ". Blank information will be put in place.", StardewModdingAPI.LogLevel.Warn); } this.musicPackInformation = new MusicPackMetaData("???", "???", "", "0.0.0", ""); } this.WaveBank = new WaveBank(Game1.audioEngine, this.WaveBankPath); this.SoundBank = (ISoundBank) new SoundBankWrapper(new SoundBank(Game1.audioEngine, this.SoundBankPath)); this.loadMusicFiles(); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); audioEngine = new AudioEngine(@"Content\Audio\GameAudio.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb"); bgm = Content.Load <Song>("irisu_05"); gameOver_sfx = Content.Load <Song>("irisu_gos1"); bg1_texture = Content.Load <Texture2D>("bg1"); bg2_texture = Content.Load <Texture2D>("bg2"); bg3_texture = Content.Load <Texture2D>("bg3"); asteroid_texture = Content.Load <Texture2D>("asteroid"); player_texture = Content.Load <Texture2D>("Ship"); bullet_texture = Content.Load <Texture2D>("Bullet"); gameOver_texture = Content.Load <Texture2D>("GameOver1"); explosion_texture = Content.Load <Texture2D>("explosion"); player_explode = Content.Load <Texture2D>("player_explosion"); powerup_texture = Content.Load <Texture2D>("powerups"); font1 = Content.Load <SpriteFont>("font1"); player = new Player(player_texture, playerStartPos, Vector2.Zero, playerAcc); powerup = new Powerup(powerup_texture, Vector2.Zero, Vector2.Zero, new Rectangle(0, 0, 0, 0), 0); bg1 = new bg(bg1_texture, new Rectangle(0, 0, bg1_texture.Width, bg1_texture.Height), new Rectangle(0, -bg1_texture.Height, bg1_texture.Width, bg1_texture.Height), 1f, 2); bg2 = new bg(bg2_texture, new Rectangle(0, 0, bg2_texture.Width, bg2_texture.Height), new Rectangle(0, -bg2_texture.Height, bg2_texture.Width, bg2_texture.Height), 0.3f, 3); bg3 = new bg(bg3_texture, new Rectangle(0, 0, bg3_texture.Width, bg3_texture.Height), new Rectangle(0, -bg3_texture.Height, bg3_texture.Width, bg3_texture.Height), 0.5f, 4); asteroids = new List <Asteroid>(); bullets = new List <Bullet>(); rand = new Random(); MediaPlayer.IsRepeating = true; MediaPlayer.Volume = 0.1f; MediaPlayer.Play(bgm); }
private void LoadEnemies() { enemies = new List <Enemy>(); AudioEngine enemyAudioEngine = new AudioEngine(@"Content\Audio\ZombieSounds\ZombieAttack.xgs"); WaveBank enemyWaveBank = new WaveBank(enemyAudioEngine, @"Content\Audio\ZombieSounds\ZombieAttackWaveBank.xwb"); //2 Priesai prie tako i miesteli Populate(new Vector2(627.3666f, 417.6126f), 1, 10, enemyAudioEngine, enemyWaveBank); Populate(new Vector2(610.3666f, 414.6126f), 1, 10, enemyAudioEngine, enemyWaveBank); //8 Priesai lauke siaure rytuose nuo miestelio Populate(new Vector2(2131.857f, 118.0393f), 8, 100, enemyAudioEngine, enemyWaveBank); //20 Priesu lauke rytuose nuo miestelio (Boso chebra) Populate(new Vector2(2801.631f, 792.6567f), 20, 100, enemyAudioEngine, enemyWaveBank); //Sukuriame Mister Death Texture2D deathWalkingSpriteSheet = Game.Content.Load <Texture2D>(@"EnemySprites\MisterDeath\MisterDeath_Walking"); SpriteSheet deathWalkingSS = new SpriteSheet(deathWalkingSpriteSheet, 8); Texture2D deathAttackingSpriteSheet = Game.Content.Load <Texture2D>(@"EnemySprites\MisterDeath\MisterDeath_Attacking"); SpriteSheet deathAttackingSS = new SpriteSheet(deathAttackingSpriteSheet, 13); Death death = new Death(deathWalkingSS, deathWalkingSS, deathWalkingSS, deathAttackingSS, new Vector2(2890.631f, 792.6567f), gameRef, player.Camera, enemyAudioEngine, enemyWaveBank); death.Dead += OnBossDeath; enemies.Add(death); foreach (Enemy e in enemies) { e.CreatePathFinder(oMap.Grid); } }
public static void Initialize(Dictionary <string, string> parameters) { try { audioEngine = new AudioEngine(parameters["settingsFile"]); bgmBank = new WaveBank(audioEngine, parameters["bgmBank"]); sfxBank = new WaveBank(audioEngine, parameters["sfxBank"]); soundBank = new SoundBank(audioEngine, parameters["soundBank"]); } catch (NoAudioHardwareException) { audioEngine = null; bgmBank = null; sfxBank = null; soundBank = null; } sfxCategory = audioEngine.GetCategory(parameters["sfxCategory"]); bgmCategory = audioEngine.GetCategory(parameters["bgmCategory"]); sfxCategory.SetVolume(sfxVolume); bgmCategory.SetVolume(bgmVolume); }
public void Initailise() { engine = new AudioEngine("Content\\Materia TD.xgs"); soundBank = new SoundBank(engine, "Content\\Sound Bank.xsb"); waveBank = new WaveBank(engine, "Content\\Wave Bank.xwb"); soundLibrary["MainMenu"] = soundBank.GetCue("MainMenu"); soundLibrary["SilverSageIntro"] = soundBank.GetCue("SilverSageIntro"); soundLibrary["PauseScreen"] = soundBank.GetCue("PauseScreen"); soundLibrary["MenuButtonClick"] = soundBank.GetCue("MenuButtonClick"); soundLibrary["TowersFiring"] = soundBank.GetCue("TowersFiring"); soundLibrary["EnemiesDyingNew"] = soundBank.GetCue("EnemiesDyingNew"); soundLibrary["OnTowerSell"] = soundBank.GetCue("OnTowerSell"); soundLibrary["OnTowerCreation"] = soundBank.GetCue("OnTowerCreation"); soundLibrary["WaitingForWaves"] = soundBank.GetCue("WaitingForWaves"); soundLibrary["EarthEnemies"] = soundBank.GetCue("EarthEnemies"); soundLibrary["WaterEnemies"] = soundBank.GetCue("WaterEnemies"); soundLibrary["WindEnemies"] = soundBank.GetCue("WindEnemies"); soundLibrary["FireEnemies"] = soundBank.GetCue("FireEnemies"); soundLibrary["LightningEnemies"] = soundBank.GetCue("LightningEnemies"); soundLibrary["DarknessEnemies"] = soundBank.GetCue("DarknessEnemies"); soundLibrary["DarknessAlly"] = soundBank.GetCue("DarknessAlly"); soundLibrary["CannotBuildTower"] = soundBank.GetCue("CannotBuildTower"); soundLibrary["FoolishDecision"] = soundBank.GetCue("FoolishDecision"); soundLibrary["SoYouThink"] = soundBank.GetCue("SoYouThink"); soundLibrary["EarthTower"] = soundBank.GetCue("EarthTower"); soundLibrary["DarkTower"] = soundBank.GetCue("DarkTower"); soundLibrary["FireTower"] = soundBank.GetCue("FireTower"); soundLibrary["WaterTower"] = soundBank.GetCue("WaterTower"); soundLibrary["WindTower"] = soundBank.GetCue("WindTower"); soundLibrary["LightTower"] = soundBank.GetCue("LightTower"); soundLibrary["TowersUpgrade"] = soundBank.GetCue("TowersUpgrade"); soundLibrary["Marching"] = soundBank.GetCue("Marching"); soundLibrary["Evil_laugh"] = soundBank.GetCue("Evil_laugh"); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { _spr_font = Content.Load <SpriteFont>(@"Fonts\ItemDataFont"); damageTakenFont = Content.Load <SpriteFont>(@"Fonts\DamageTaken"); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //Screen rectangle is saved into a static variable for easier access GameSettings.ScreenRectangle = screenRectangle; //Item factory is initialized ItemFactory.Content = Content; ItemFactory.ItemTexturePath = @"GUI\Inventory\Items\"; ItemFactory.ItemDataPath = @"ItemData\"; ItemFactory.BorderResource = @"GUI\Inventory\Tooltip\border-v6"; ItemFactory.BackgroundResource = @"GUI\Inventory\Tooltip\background-v2"; ItemFactory.FontResource = @"Fonts\ItemDataFont"; //Control factory is initialized ComponentFactory.Content = Content; ComponentFactory.ButtonFontResource = @"Fonts\ButtonFont"; ComponentFactory.ButtonHoverResource = @"GUI\Buttons\button_hover"; //Window factory is initialized WindowFactory.Content = Content; WindowFactory.WindowFontResource = @"Fonts\ControlFont"; WindowFactory.BorderResource = @"GUI\Inventory\Tooltip\border-v6"; audioEngine = new AudioEngine(@"Content\Audio\zombiai.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Audio\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Audio\Sound Bank.xsb"); soundBank.PlayCue("zombies"); }
/// <summary>Set up audio by loading the XACT generated files.</summary> private void LoadAudio() { // Set up audio stuff by loading our XACT project files. try { // Load data. _audioEngine = new AudioEngine("data/Audio/SpaceAudio.xgs"); _waveBank = new WaveBank(_audioEngine, "data/Audio/Wave Bank.xwb"); _soundBank = new SoundBank(_audioEngine, "data/Audio/Sound Bank.xsb"); // Do a first update, as recommended in the documentation. _audioEngine.Update(); // Make the sound and wave bank available as a service. Services.AddService(typeof(AudioEngine), _audioEngine); Services.AddService(typeof(SoundBank), _soundBank); Services.AddService(typeof(WaveBank), _waveBank); } catch (Exception ex) { Logger.ErrorException("Failed initializing AudioEngine.", ex); } }
} // enum Sounds #endregion #region Constructor /// <summary> /// Create sound /// </summary> static Sound() { try { audioEngine = new AudioEngine(@"Content\Sounds\GameSounds.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Sounds\Wave Bank.xwb"); if (waveBank != null) { soundBank = new SoundBank(audioEngine, @"Content\Sounds\Sound Bank.xsb"); } // Get the music category to change the music volume and stop music musicCategory = audioEngine.GetCategory("Music"); } // try catch (Exception ex) { Log.Instance.Write("Failed to create sound class: " + ex.ToString()); } // catch } // Sound()
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { SoundEffect soundEffect = Content.Load <SoundEffect>(@"Poetry"); sound = soundEffect.CreateInstance(); soundEffect = Content.Load <SoundEffect>(@"PoetryBackwards"); soundBackwards = soundEffect.CreateInstance(); audioEngine = new AudioEngine(@"Content\Sound.xgs"); waveBank = new WaveBank(audioEngine, @"Content\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Sound Bank.xsb"); // soundBank.PlayCue("07"); sound.Play(); // mask = Content.Load<Texture2D>(@"singleWasp"); bark = Content.Load <Texture2D>(@"bark5"); redSpot = Content.Load <Texture2D>(@"RedSpot"); framesAnimation = Content.Load <Texture2D>(@"frames0Wasp"); backGroundTexture = Content.Load <Texture2D>(@"BackField"); // thisModel = new BasicModel(Content.Load<Model>(@"bark")); hat = Content.Load <Texture2D>(@"hat"); // texture = Content.Load<Texture2D>(@"transparent"); this.kinectColorVisualizer = Content.Load <Effect>("KinectColorVisualizer"); // TODO: use this.Content to load your game content here }
/// <summary> /// Loads the audio engine, sound bank and wave bank. Must be called before the audio system can be used. /// </summary> /// <param name="settingsFilePath">The filepath to the .xgs file.</param> /// <param name="memoryWBFilePath">The filepath to the .xwb in-memory wave bank.</param> /// <param name="streamWBFilePath">The filepath to the streaming wave bank with default -- offset: 0, packetsize: 64</param> /// <param name="SBFilePath">The filepath to the .xsb file.</param> public void Initialize(string settingsFilePath, string memoryWBFilePath, string streamWBFilePath, string SBFilePath) { try { audioEngine = new AudioEngine(settingsFilePath + ".xgs"); memoryWaveBank = new WaveBank(audioEngine, memoryWBFilePath + ".xwb"); if (!string.IsNullOrEmpty(streamWBFilePath)) { streamWaveBank = new WaveBank(audioEngine, streamWBFilePath + ".xwb", 0, 64); } soundBank = new SoundBank(audioEngine, SBFilePath + ".xsb"); isInitialized = true; } catch (Exception e) { MessageBox.Show(e.Message, "Audio System Initialization Failed !"); isInitialized = false; } // Attempt to load some default AudioCatagories LoadCategories("Global", "Default", "Music"); }