private async void LoadSong(string fileName) { _soundEffect = await SoundEffect.FromURL(fileName); _soundEffectInstance = _soundEffect.CreateInstance(); Content.ContentManager.BlockContentLoaading = false; }
public static async Task Init(ContentManager content, GraphicsDevice graphics) { Counter = 0; Texture.Pixel = await content.LoadAsync <Texture2D>("Pixel"); Font.hudFont = await content.LoadAsync <SpriteFont>("Fonts/Hud"); IsBaseLoaded = true; Texture.winOverlay = await content.LoadAsync <Texture2D>("Overlays/you_win"); Counter++; Texture.loseOverlay = await content.LoadAsync <Texture2D>("Overlays/you_lose"); Counter++; Texture.diedOverlay = await content.LoadAsync <Texture2D>("Overlays/you_died"); Counter++; Texture.VirtualControlArrow = await content.LoadAsync <Texture2D>("Sprites/VirtualControlArrow"); Counter++; Texture.Idle = await content.LoadAsync <Texture2D>("Sprites/Player/Idle"); Counter++; Texture.Run = await content.LoadAsync <Texture2D>("Sprites/Player/Run"); Counter++; Texture.Jump = await content.LoadAsync <Texture2D>("Sprites/Player/Jump"); Counter++; Texture.Celebrate = await content.LoadAsync <Texture2D>("Sprites/Player/Celebrate"); Counter++; Texture.Die = await content.LoadAsync <Texture2D>("Sprites/Player/Die"); Counter++; Texture.Gem = await content.LoadAsync <Texture2D>("Sprites/Gem"); Counter++; Texture.BackgroundLayer = new Texture2D[3, 3]; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { Texture.BackgroundLayer[x, y] = await content.LoadAsync <Texture2D>("Backgrounds/Layer" + x + "_" + y); Counter++; } } Texture.MonsterIdle = new Texture2D[4]; Texture.MonsterRun = new Texture2D[4]; for (int i = 0; i < 4; i++) { Texture.MonsterIdle[i] = await content.LoadAsync <Texture2D>("Sprites/Monster" + i + "/Idle"); Counter++; Texture.MonsterRun[i] = await content.LoadAsync <Texture2D>("Sprites/Monster" + i + "/Run"); Counter++; } Texture.Tiles = new Dictionary <string, Texture2D>(); Texture.Tiles["BlockA0"] = await content.LoadAsync <Texture2D>("Tiles/BlockA0"); Counter++; Texture.Tiles["BlockA1"] = await content.LoadAsync <Texture2D>("Tiles/BlockA1"); Counter++; Texture.Tiles["BlockA2"] = await content.LoadAsync <Texture2D>("Tiles/BlockA2"); Counter++; Texture.Tiles["BlockA3"] = await content.LoadAsync <Texture2D>("Tiles/BlockA3"); Counter++; Texture.Tiles["BlockA4"] = await content.LoadAsync <Texture2D>("Tiles/BlockA4"); Counter++; Texture.Tiles["BlockA5"] = await content.LoadAsync <Texture2D>("Tiles/BlockA5"); Counter++; Texture.Tiles["BlockA6"] = await content.LoadAsync <Texture2D>("Tiles/BlockA6"); Counter++; Texture.Tiles["BlockB0"] = await content.LoadAsync <Texture2D>("Tiles/BlockB0"); Counter++; Texture.Tiles["BlockB1"] = await content.LoadAsync <Texture2D>("Tiles/BlockB1"); Counter++; Texture.Tiles["Exit"] = await content.LoadAsync <Texture2D>("Tiles/Exit"); Counter++; Texture.Tiles["Platform"] = await content.LoadAsync <Texture2D>("Tiles/Platform"); Counter++; Songs.Music = await content.LoadAsync <Song>("Sounds/Music"); Counter++; SoundEffects.killedSound = await SoundEffect.FromURL("Content/Sounds/PlayerKilled.wav"); Counter++; SoundEffects.jumpSound = await SoundEffect.FromURL("Content/Sounds/PlayerJump.wav"); Counter++; SoundEffects.fallSound = await SoundEffect.FromURL("Content/Sounds/PlayerFall.wav"); Counter++; SoundEffects.exitReachedSound = await SoundEffect.FromURL("Content/Sounds/ExitReached.wav"); Counter++; SoundEffects.collectedSound = await SoundEffect.FromURL("Content/Sounds/GemCollected.wav"); Counter++; Levels = new List <string[]>(); for (int i = 0; i < 3; i++) { Levels.Add(System.IO.File.ReadAllLines("Content/Levels/" + i + ".txt")); Counter++; } IsLoaded = true; }