public static void LoadFonts(ContentManager content, GraphicsDevice graphicsDevice) { FontSystem = FontSystemFactory.Create(graphicsDevice, 2048, 2048); FontSystem.AddFont(TitleContainer.OpenStream($"{content.RootDirectory}/source-code-pro-medium.ttf")); }
private void EndRound() { holderControl1.ResetHolder(); //get the current round var round = game.Rounds.ElementAt(roundNumber - 1); round.RoundScore = slots.Where(z => !z.Hand.IsBusted).Sum(p => p.Hand.Total); //if this is the last round - GameOver if (game.Rounds.Count() == roundNumber) { GameOver(); return; } //mark the current round as no longer the current round round.CurrentRound = false; //increment the round number roundNumber++; //set the new current round as the next round game.Rounds.ElementAt(roundNumber - 1).CurrentRound = true; //clear the cards from the deck and the discard deckControl1.Deck = null; holderControl1.Cards.Clear(); round.RoundTime = roundTimerControl1.time; // scoreControl1.UpdateScore(); if (round.ShouldPlayerGetNewRound) { game.Rounds.Insert(roundNumber - 1, new Round() { IsBonusRound = true }); //if the round time is less than 20 seconds show the speed bonus panel bool showSpeedBonus = false; if (round.RoundTime <= 20) { showSpeedBonus = true; } if (round.NumberOf21s == 4) { using (var stream = TitleContainer.OpenStream("sounds/shufflin.wav")) { var effect = SoundEffect.FromStream(stream); FrameworkDispatcher.Update(); effect.Play(); } bonusControl.ShowSpeedBonus(showSpeedBonus); bonusControl.RideUp.Begin(); //for speed bonus if (showSpeedBonus) { round.RoundScore += 10; } } if (round.NumberOf21s == 5) { using (var stream = TitleContainer.OpenStream("sounds/shufflin.wav")) { var effect = SoundEffect.FromStream(stream); FrameworkDispatcher.Update(); effect.Play(); } fivebonusControl.ShowSpeedBonus(showSpeedBonus); fivebonusControl.RideUp.Begin(); //add bonus pts for 5 21s round.RoundScore += 15; //for speed bonus if (showSpeedBonus) { round.RoundScore += 10; } } } roundTimerControl1.StopTimer(); roundControl1.UpdateRounds(); }
private T InternalLoad <T>(string assetName, string path, bool weakReference) { T result = default(T); bool useContentReader = true; try { //Special types if (typeof(T) == typeof(string)) { //TODO: No need CCContent, use TileContainer var content = ReadAsset <CCContent>(path, null); result = (T)(object)content.Content; useContentReader = false; } else { // Load the asset. result = ReadAsset <T>(path, null); } } catch (ContentLoadException) { try { string assetPath = Path.Combine(RootDirectory, path); if (typeof(T) == typeof(string)) { using (var streamContent = TitleContainer.OpenStream(assetPath)) { using (StreamReader reader = new StreamReader(streamContent, Encoding.UTF8)) { result = (T)(object)reader.ReadToEnd(); } } useContentReader = false; } else if (typeof(T) == typeof(PlistDocument)) { try { using (var streamContent = TitleContainer.OpenStream(assetPath)) { result = (T)(object)new PlistDocument(streamContent); } } catch (Exception) { //TODO: Remove This var content = ReadAsset <CCContent>(path, null); result = (T)(object)new PlistDocument(content.Content); } useContentReader = false; } #if XNA else if (typeof(T) == typeof(Texture2D) && Path.HasExtension(path)) { var service = (IGraphicsDeviceService)ServiceProvider.GetService(typeof(IGraphicsDeviceService)); using (var streamContent = TitleContainer.OpenStream(assetPath)) { result = (T)(object)Texture2D.FromStream(service.GraphicsDevice, streamContent); } useContentReader = false; } #endif else { throw; } } catch (Exception) { throw new ContentLoadException("Failed to load the asset file from " + assetName); } } var assetEntry = new AssetEntry(result, path, weakReference, useContentReader); _loadedAssets[assetName] = assetEntry; if (result is GraphicsResource) { (result as GraphicsResource).Disposing += AssetDisposing; } return(result); }
protected T ReadAsset <T>(string assetName, Action <IDisposable> recordDisposableObject) { if (string.IsNullOrEmpty(assetName)) { throw new ArgumentNullException("assetName"); } if (disposed) { throw new ObjectDisposedException("ContentManager"); } object result = null; Stream stream = null; string modifiedAssetName = String.Empty; // Will be used if we have to guess a filename try { stream = OpenStream(assetName); } catch (Exception e) { // Okay, so we couldn't open it. Maybe it needs a different extension? // FIXME: This only works for files on the disk, what about custom streams? -flibit modifiedAssetName = MonoGame.Utilities.FileHelpers.NormalizeFilePathSeparators( Path.Combine(RootDirectoryFullPath, assetName) ); if (typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Texture)) { modifiedAssetName = Texture2DReader.Normalize(modifiedAssetName); } else if (typeof(T) == typeof(TextureCube)) { modifiedAssetName = Texture2DReader.Normalize(modifiedAssetName); } else if ((typeof(T) == typeof(SoundEffect))) { modifiedAssetName = SoundEffectReader.Normalize(modifiedAssetName); } else if ((typeof(T) == typeof(Effect))) { modifiedAssetName = EffectReader.Normalize(modifiedAssetName); } else if ((typeof(T) == typeof(Song))) { modifiedAssetName = SongReader.Normalize(modifiedAssetName); } else if ((typeof(T) == typeof(Video))) { modifiedAssetName = VideoReader.Normalize(modifiedAssetName); } else { // No raw format available, disregard! modifiedAssetName = null; } // Did we get anything...? if (String.IsNullOrEmpty(modifiedAssetName)) { // Nope, nothing we're aware of! throw new ContentLoadException( "Could not load asset " + assetName + "! Error: " + e.Message, e ); } stream = TitleContainer.OpenStream(modifiedAssetName); } // Check for XNB header stream.Read(xnbHeader, 0, xnbHeader.Length); if (xnbHeader[0] == 'X' && xnbHeader[1] == 'N' && xnbHeader[2] == 'B' && targetPlatformIdentifiers.Contains((char)xnbHeader[3])) { using (BinaryReader xnbReader = new BinaryReader(stream)) using (ContentReader reader = GetContentReaderFromXnb(assetName, ref stream, xnbReader, (char)xnbHeader[3], recordDisposableObject)) { result = reader.ReadAsset <T>(); GraphicsResource resource = result as GraphicsResource; if (resource != null) { resource.Name = assetName; } } } else { // It's not an XNB file. Try to load as a raw asset instead. // FIXME: Assuming seekable streams! -flibit stream.Seek(0, SeekOrigin.Begin); if (typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Texture)) { Texture2D texture; if (xnbHeader[0] == 'D' && xnbHeader[1] == 'D' && xnbHeader[2] == 'S' && xnbHeader[3] == ' ') { texture = Texture2D.DDSFromStreamEXT( GetGraphicsDevice(), stream ); } else { texture = Texture2D.FromStream( GetGraphicsDevice(), stream ); } texture.Name = assetName; result = texture; } else if (typeof(T) == typeof(TextureCube)) { TextureCube texture = TextureCube.DDSFromStreamEXT( GetGraphicsDevice(), stream ); texture.Name = assetName; result = texture; } else if (typeof(T) == typeof(SoundEffect)) { SoundEffect effect = SoundEffect.FromStream(stream); effect.Name = assetName; result = effect; } else if (typeof(T) == typeof(Effect)) { byte[] data = new byte[stream.Length]; stream.Read(data, 0, (int)stream.Length); Effect effect = new Effect(GetGraphicsDevice(), data); effect.Name = assetName; result = effect; } else if (typeof(T) == typeof(Song)) { // FIXME: Not using the stream! -flibit result = new Song(modifiedAssetName); } else if (typeof(T) == typeof(Video)) { // FIXME: Not using the stream! -flibit result = new Video(modifiedAssetName, GetGraphicsDevice()); FNALoggerEXT.LogWarn( "Video " + modifiedAssetName + " does not have an XNB file! Hacking Duration property!" ); } else { stream.Close(); throw new ContentLoadException("Could not load " + assetName + " asset!"); } /* Because Raw Assets skip the ContentReader step, they need to have their * disposables recorded here. Doing it outside of this catch will * result in disposables being logged twice. */ IDisposable disposableResult = result as IDisposable; if (disposableResult != null) { if (recordDisposableObject != null) { recordDisposableObject(disposableResult); } else { disposableAssets.Add(disposableResult); } } /* Because we're not using a BinaryReader for raw assets, we * need to close the stream ourselves. * -flibit */ stream.Close(); } return((T)result); }
/// <param name="settingsFile">Path to a XACT settings file.</param> /// <param name="lookAheadTime">Determines how many milliseconds the engine will look ahead when determing when to transition to another sound.</param> /// <param name="rendererId">A string that specifies the audio renderer to use.</param> /// <remarks>For the best results, use a lookAheadTime of 250 milliseconds or greater.</remarks> public AudioEngine(string settingsFile, TimeSpan lookAheadTime, string rendererId) { //Read the xact settings file //Credits to alisci01 for initial format documentation #if !ANDROID using (var stream = TitleContainer.OpenStream(settingsFile)) { #else using (var fileStream = Game.Activity.Assets.Open(settingsFile)) { MemoryStream stream = new MemoryStream(); fileStream.CopyTo(stream); stream.Position = 0; #endif using (var reader = new BinaryReader(stream)) { uint magic = reader.ReadUInt32(); if (magic != 0x46534758) //'XGFS' { throw new ArgumentException("XGS format not recognized"); } reader.ReadUInt16(); // toolVersion #if DEBUG uint formatVersion = reader.ReadUInt16(); if (formatVersion != 42) { System.Diagnostics.Debug.WriteLine("Warning: XGS format not supported"); } #else reader.ReadUInt16(); // formatVersion #endif reader.ReadUInt16(); // crc reader.ReadUInt32(); // lastModifiedLow reader.ReadUInt32(); // lastModifiedHigh reader.ReadByte(); //unkn, 0x03. Platform? uint numCats = reader.ReadUInt16(); uint numVars = reader.ReadUInt16(); reader.ReadUInt16(); //unkn, 0x16 reader.ReadUInt16(); //unkn, 0x16 uint numRpc = reader.ReadUInt16(); reader.ReadUInt16(); // numDspPresets reader.ReadUInt16(); // numDspParams uint catsOffset = reader.ReadUInt32(); uint varsOffset = reader.ReadUInt32(); reader.ReadUInt32(); //unknown, leads to a short with value of 1? reader.ReadUInt32(); // catNameIndexOffset reader.ReadUInt32(); //unknown, two shorts of values 2 and 3? reader.ReadUInt32(); // varNameIndexOffset uint catNamesOffset = reader.ReadUInt32(); uint varNamesOffset = reader.ReadUInt32(); uint rpcOffset = reader.ReadUInt32(); reader.ReadUInt32(); // dspPresetsOffset reader.ReadUInt32(); // dspParamsOffset reader.BaseStream.Seek(catNamesOffset, SeekOrigin.Begin); string[] categoryNames = readNullTerminatedStrings(numCats, reader); categories = new AudioCategory[numCats]; reader.BaseStream.Seek(catsOffset, SeekOrigin.Begin); for (int i = 0; i < numCats; i++) { categories [i] = new AudioCategory(this, categoryNames [i], reader); categoryLookup.Add(categoryNames [i], i); } reader.BaseStream.Seek(varNamesOffset, SeekOrigin.Begin); string[] varNames = readNullTerminatedStrings(numVars, reader); variables = new Variable[numVars]; reader.BaseStream.Seek(varsOffset, SeekOrigin.Begin); for (int i = 0; i < numVars; i++) { variables [i].name = varNames [i]; byte flags = reader.ReadByte(); variables [i].isPublic = (flags & 0x1) != 0; variables [i].isReadOnly = (flags & 0x2) != 0; variables [i].isGlobal = (flags & 0x4) == 0; variables [i].isReserved = (flags & 0x8) != 0; variables [i].initValue = reader.ReadSingle(); variables [i].minValue = reader.ReadSingle(); variables [i].maxValue = reader.ReadSingle(); variables [i].value = variables [i].initValue; variableLookup.Add(varNames [i], i); } rpcCurves = new RpcCurve[numRpc]; reader.BaseStream.Seek(rpcOffset, SeekOrigin.Begin); for (int i = 0; i < numRpc; i++) { rpcCurves [i].variable = reader.ReadUInt16(); int pointCount = (int)reader.ReadByte(); rpcCurves [i].parameter = (RpcParameter)reader.ReadUInt16(); rpcCurves [i].points = new RpcPoint[pointCount]; for (int j = 0; j < pointCount; j++) { rpcCurves [i].points [j].x = reader.ReadSingle(); rpcCurves [i].points [j].y = reader.ReadSingle(); rpcCurves [i].points [j].type = (RpcPointType)reader.ReadByte(); } } } } _stopwatch = new Stopwatch(); _stopwatch.Start(); }
public MainGame() : base() { graphics = new GraphicsDeviceManager(this); // Set device to Fullscreen-Mode graphics.ToggleFullScreen(); Content.RootDirectory = "Content"; graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; hZero = graphics.PreferredBackBufferHeight; bZero = graphics.PreferredBackBufferWidth; btnViewPostions = Extension.GenerateViewButtonPositions(ref graphics); GameSpecs.SoundOn = true; btnHeightPhotoViewCommon = (int)(btnViewPostions[3].Height * 0.86); btnWidthPhotoViewCommon = (int)(btnViewPostions[3].Width * 0.97); GameSpecs.Difficulty = 1; GameSpecs.SoundOn = true; GameSpecs.MusicOn = true; btnHeightNormal = 150; btnWidthNormal = 350; btnHeightHalf = 150; btnWidthHalf = 150; btnHeightSmall = 110; btnWidthSmall = 110; #region Button Initializations /// <summary> /// Creating new Button-Objects /// </summary> btnNewGame = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.2), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnNewGame.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/NewGame.png")); btnOptions = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.45), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnOptions.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Options.png")); btnQuitGame = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.7), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnQuitGame.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Quit.png")); btnOptionsBack = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.2), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnOptionsBack.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Back.png")); btnOptionsSound = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.45), new Rectangle(0, 0, btnWidthHalf, btnHeightHalf)); btnOptionsSound.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Back.png")); btnOptionsMusic = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2) + (50 + btnWidthHalf), hZero * (float)0.45), new Rectangle(0, 0, btnWidthHalf, btnHeightHalf)); btnOptionsMusic.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Back.png")); btnResume = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.2), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnResume.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Resume.png")); btnQuitSession = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.7), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnQuitSession.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Quit.png")); btnOptionsDifficultyEasy = new Button(this, new Vector2((bZero / 2) - (btnWidthNormal / 2), hZero * (float)0.45), new Rectangle(0, 0, btnWidthSmall, btnHeightSmall)); btnOptionsDifficultyEasy.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Easy.png")); btnOptionsDifficultyMedium = new Button(this, new Vector2(((bZero / 2) - (btnWidthNormal / 2)) + (btnWidthSmall + 9), hZero * (float)0.45), new Rectangle(0, 0, btnWidthSmall, btnHeightSmall)); btnOptionsDifficultyMedium.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Medium.png")); btnOptionsDifficultyHard = new Button(this, new Vector2(((bZero / 2) - (btnWidthNormal / 2)) + (2 * btnWidthSmall + 18), hZero * (float)0.45), new Rectangle(0, 0, btnWidthSmall, btnHeightSmall)); btnOptionsDifficultyHard.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/Hard.png")); btnBackToMenu = new Button(this, new Vector2((float)((bZero * 0.025)), hZero * (float)0.3), new Rectangle(0, 0, btnWidthSmall, btnHeightSmall)); btnBackToMenu.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/BackArrow.png")); btnDirectRetry = new Button(this, new Vector2((float)((bZero * 0.025)), hZero * (float)0.55), new Rectangle(0, 0, btnWidthSmall, btnHeightSmall)); btnDirectRetry.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/BackArrow.png")); btnPhotoYes = new Button(this, new Vector2((int)(bZero * 0.015), hZero * (float)0.5), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnPhotoYes.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/yes.png")); btnPhotoNo = new Button(this, new Vector2(((bZero - btnWidthNormal) - (int)(bZero * 0.015)), hZero * (float)0.5), new Rectangle(0, 0, btnWidthNormal, btnHeightNormal)); btnPhotoNo.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/no.png")); /// PICTURE-VIEWING BUTTONS btnViewPicture1 = new Button(this, new Vector2(btnViewPostions[0].X, btnViewPostions[0].Y), new Rectangle(0, 0, btnViewPostions[0].Width, btnViewPostions[0].Height)); btnViewPicture1.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Others/placeholder_player.png")); btnViewPicture2 = new Button(this, new Vector2(btnViewPostions[1].X, btnViewPostions[1].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture2.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture3 = new Button(this, new Vector2(btnViewPostions[2].X, btnViewPostions[2].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture3.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture4 = new Button(this, new Vector2(btnViewPostions[3].X, btnViewPostions[3].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture4.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture5 = new Button(this, new Vector2(btnViewPostions[4].X, btnViewPostions[4].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture5.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture6 = new Button(this, new Vector2(btnViewPostions[5].X, btnViewPostions[5].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture6.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture7 = new Button(this, new Vector2(btnViewPostions[6].X, btnViewPostions[6].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture7.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture8 = new Button(this, new Vector2(btnViewPostions[7].X, btnViewPostions[7].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture8.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture9 = new Button(this, new Vector2(btnViewPostions[8].X, btnViewPostions[8].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture9.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); btnViewPicture10 = new Button(this, new Vector2(btnViewPostions[9].X, btnViewPostions[9].Y), new Rectangle(0, 0, btnWidthPhotoViewCommon, btnHeightPhotoViewCommon)); btnViewPicture10.Texture = Texture2D.FromStream(graphics.GraphicsDevice, TitleContainer.OpenStream("Content/Textures/Buttons/button_photo.png")); // Adding all Buttons to their respective Lists btnListMainMenuNoSession = new List <Button>() { btnNewGame, btnOptions, btnQuitGame }; btnListMainMenuSession = new List <Button>() { btnResume, btnQuitSession }; btnListOptionsMenu = new List <Button>() { btnOptionsBack, btnOptionsSound, btnOptionsMusic }; btnListRunning = new List <Button>() { btnBackToMenu }; btnListChooseDifficulty = new List <Button>() { btnOptionsDifficultyEasy, btnOptionsDifficultyMedium, btnOptionsDifficultyHard }; btnListEndgame = new List <Button>() { btnPhotoYes, btnPhotoNo }; btnListHighscore = new List <Button>() { btnBackToMenu, btnDirectRetry, btnViewPicture1, btnViewPicture2, btnViewPicture3, btnViewPicture4, btnViewPicture5, btnViewPicture6, btnViewPicture7, btnViewPicture8, btnViewPicture9, btnViewPicture10 }; #endregion // Initializing of all Gamestates this.startscreen = new Startscreen(); this.mainmenuNoSession = new MainMenuNoSession(btnListMainMenuNoSession); this.mainmenuSession = new MainMenuSession(btnListMainMenuSession); this.choosedifficulty = new ChooseDifficulty(btnListChooseDifficulty); this.running = new Running(btnListRunning); this.optionmenu = new OptionMenu(btnListOptionsMenu); this.highscore = new Highscore(btnListHighscore, ref graphics); this.endgame = new Endgame(btnListEndgame); this.imagedetailview = new ImageDetailView(); // INITIAL GAMESTATE // WHERE TO START THE GAME this.GameState = GameState.Startscreen; }
public static void loadUpsellScreen() { try { Upsell.bg = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4us_bg.png")); Upsell.cursor1 = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4us_arrow.png")); Upsell.screenshot = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4us_ss_" + (object)Upsell.ss_num + ".png")); string str = LiveFeature.lang_suffix[AppMain.GsEnvGetLanguage()]; Upsell.button1 = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4" + str + "_back.png")); Upsell.button1hl = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4" + str + "_back_HL.png")); Upsell.button2 = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4" + str + "_buy.png")); Upsell.button2hl = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4" + str + "_buy_HL.png")); Upsell.showUpsell = true; } catch (Exception ex) { } }
protected override void LoadContent() { // Load shader, set up settings var black = Game.Content.Load <Texture2D>("Textures/black"); basicShader = Game.Content.Load <Effect>("Shaders/BasicColorMapped"); basicShader.CurrentTechnique = basicShader.Techniques["DefaultTechnique"]; basicShader.Parameters["ColorMapTexture"].SetValue(black); basicShader.Parameters["ColorInfluence"].SetValue(1.0f); basicShader.Parameters["FogColor"].SetValue(SkyColor.ToVector4()); basicShader.Parameters["FogEndDistance"].SetValue(FogDistance); // Load models, decoration and biome data var modelLoader = new AtlasModelLoader(2048, 2048, basicShader, Game.Content); var decorationData = orbis.Content.Load <XMLModel.DecorationCollection>("Config/Decorations"); var decorationManager = new DecorationManager(decorationData, modelLoader, GraphicsDevice); // Load decorations foreach (var data in decorationData.Decorations) { decorations.Add(data.Name, new DecorationPool(decorationManager.GetDecorationMesh(data.Name), GraphicsDevice, 1)); } var biomeData = orbis.Content.Load <XMLModel.BiomeCollection>("Config/Biomes"); biomeMappedData = new Dictionary <string, BiomeMappedData>(); // Load biomes foreach (var biome in biomeData.Biomes) { biomeMappedData.Add(biome.Name, new BiomeMappedData { HexMesh = modelLoader.LoadModel(biome.HexModel.Name, biome.HexModel.Texture, biome.HexModel.ColorTexture).Mesh, DefaultDecoration = biome.DefaultDecoration, DefaultDensity = biome.DecorationDensity, }); } // Load tile highlight mesh var model = modelLoader.LoadModel("flag", "flag"); tileHighlightMesh = new RenderableMesh(GraphicsDevice, model.Mesh); modelLoader.FinializeLoading(GraphicsDevice); // Set up shader textures basicShader.Parameters["MainTexture"].SetValue(modelLoader.Material.Texture); basicShader.Parameters["ColorMapTexture"].SetValue(modelLoader.Material.ColorMap); if (atlasDebugEnabled) { // Atlas texture debugging Mesh mesh = null; using (var stream = TitleContainer.OpenStream("Content/Meshes/quad_up.obj")) { mesh = ObjParser.FromStream(stream); } atlasDebugInstance = new RenderInstance { mesh = new RenderableMesh(GraphicsDevice, mesh), matrix = Matrix.CreateScale(10) * Matrix.CreateTranslation(0, 0, 30), }; basicShader.Parameters["ColorMapTexture"].SetValue(black); } base.LoadContent(); }
public Level Load(int levelId) { GridPosition playerPosition = null; walls.SetAll(false); items.Clear(); obstacles.Clear(); string instruction = string.Empty; string fileName = GetLevelPath(levelId); if (levelId == -1 || !File.Exists(GetFullLevelPath(levelId))) { fileName = Path.Combine(".", "Content", "TEMPLATE.txt"); } using (StreamReader reader = new StreamReader(TitleContainer.OpenStream(fileName))) { for (int j = 0; j < GridPosition.GRID_SIZE; j++) { string line = reader.ReadLine(); for (int i = 0; i < GridPosition.GRID_SIZE; i++) { switch (line.Substring(i, 1)) { case EMPTY: break; case WALL: walls[i + j * GridPosition.GRID_SIZE] = true; break; case SWORD: CreateItem(Collectible.Type.SWORD, i, j); break; case SHIELD: CreateItem(Collectible.Type.SHIELD, i, j); break; case HEART: CreateItem(Collectible.Type.HEART, i, j); break; case KEY: CreateItem(Collectible.Type.KEY, i, j); break; case PLAYER: playerPosition = new GridPosition(i, j); break; case MONSTER: CreateObstacle(Collectible.Type.SWORD, i, j); break; case DOOR: CreateObstacle(Collectible.Type.KEY, i, j); break; case FIRE: CreateObstacle(Collectible.Type.SHIELD, i, j); break; case LOVER: CreateObstacle(Collectible.Type.HEART, i, j); break; } } } instruction = reader.ReadLine(); } Level level = new Level(walls, items, obstacles, atlas, playerPosition); if (!string.IsNullOrWhiteSpace(instruction)) { level.Instruction = instruction; } return(level); }
public override Stream OpenStream(string path) { var contentPath = Path.Combine(_contentManager.RootDirectory, path); return(TitleContainer.OpenStream(contentPath)); }
/// <summary> /// Load game content file, returns null if file was not found. /// </summary> /// <param name="relativeFilename">Relative filename</param> /// <returns>File stream</returns> public static Stream LoadGameContentFile(string relativeFilename) { return(TitleContainer.OpenStream(relativeFilename)); }
public void LoadLevels() { Stream stream = TitleContainer.OpenStream(@"levels.txt"); StreamReader reader = new System.IO.StreamReader(stream); Level currentLevel = null; Map currentMap = null; House currentDeliveryHouse = null; List <Ingredient> currentPizza = null; bool readInPickUps = false; bool readInObstacles = false; bool readInRandoms = false; int numDeliveries = 0; while (!reader.EndOfStream) { string line = reader.ReadLine(); if (line != null && line != string.Empty) { if (line.ToLower().Contains("LEVEL".ToLower())) { if (currentLevel != null && currentDeliveryHouse != null && currentPizza != null) { currentLevel.AddDelivery(currentDeliveryHouse, currentPizza); } Level level = new Level(new Vector2(-1, -1)); Levels.Add(level); currentLevel = level; currentMap = null; currentDeliveryHouse = null; currentPizza = null; readInPickUps = false; readInObstacles = false; readInRandoms = false; //Debug.WriteLine("----------------------------------NEW Level ----------------------------------"); } else if (currentLevel != null && line.ToLower().Contains("DH".ToLower())) { numDeliveries = numDeliveries++; string[] delivery = line.Split(','); currentMap = TheLastSliceGame.MapManager.Maps[Convert.ToInt32(delivery[1])]; int houseRow = Convert.ToInt32(delivery[2]); int houseColumn = Convert.ToInt32(delivery[3]); currentDeliveryHouse = currentMap.EntityGrid[houseRow, houseColumn] as House; currentPizza = new List <Ingredient>(); if (currentDeliveryHouse == null) { Debug.WriteLine("!!!! The delivery house row/column is incorrect! !!!!"); } //Debug.WriteLine("----------------------------------NEW House ----------------------------------"); } else if (currentLevel != null && line.ToLower().Contains("PICKUPS".ToLower())) { if (currentDeliveryHouse != null && currentPizza != null) { currentLevel.AddDelivery(currentDeliveryHouse, currentPizza); currentDeliveryHouse = null; currentPizza = null; currentMap = null; } readInPickUps = true; //Debug.WriteLine("----------------------------------NEW Pickups ----------------------------------"); } else if (currentLevel != null && line.ToLower().Contains("OBSTACLES".ToLower())) { if (currentDeliveryHouse != null && currentPizza != null) { currentLevel.AddDelivery(currentDeliveryHouse, currentPizza); currentDeliveryHouse = null; currentPizza = null; currentMap = null; } readInObstacles = true; //Debug.WriteLine("----------------------------------NEW Pickups ----------------------------------"); } else if (currentLevel != null && line.ToLower().Contains("RANDOMS".ToLower())) { if (currentDeliveryHouse != null && currentPizza != null) { currentLevel.AddDelivery(currentDeliveryHouse, currentPizza); currentDeliveryHouse = null; currentPizza = null; currentMap = null; } readInRandoms = true; //Debug.WriteLine("----------------------------------NEW Pickups ----------------------------------"); } else if (readInPickUps == true && currentLevel != null) { string[] pickupString = line.Split(','); string assetCode = pickupString[0]; Map map = TheLastSliceGame.MapManager.Maps[Convert.ToInt32(pickupString[1])]; int row = Convert.ToInt32(pickupString[2]); int column = Convert.ToInt32(pickupString[3]); int xPos = (int)map.EntityGrid[row, column].Position.X; int yPos = (int)map.EntityGrid[row, column].Position.Y; bool isHeart = Pickup.isPickupType(PickupType.HE, assetCode); bool isBox = Pickup.isPickupType(PickupType.BX, assetCode); bool isCube = Pickup.isPickupType(PickupType.CU, assetCode); bool isGas = Pickup.isPickupType(PickupType.GS, assetCode); bool isTrash = Pickup.isPickupType(PickupType.TC, assetCode); if (isHeart || isBox || isCube || isGas || isTrash) { Pickup pickup = new Pickup(new Vector2(xPos, yPos), assetCode); pickup.Map = map; currentLevel.Pickups.Add(pickup); } else { Ingredient ingredient = new Ingredient(new Vector2(xPos, yPos), assetCode); ingredient.Map = map; currentLevel.Pickups.Add(ingredient); } } else if (readInObstacles == true && currentLevel != null) { string[] obstacleString = line.Split(','); string assetCode = obstacleString[0]; int mapNumber = Convert.ToInt32(obstacleString[1]); Map map = TheLastSliceGame.MapManager.Maps[mapNumber]; int row = Convert.ToInt32(obstacleString[2]); int column = Convert.ToInt32(obstacleString[3]); int xPos = (int)map.EntityGrid[row, column].Position.X; int yPos = (int)map.EntityGrid[row, column].Position.Y; Obstacle obstacle = new Obstacle(new Vector2(xPos, yPos), assetCode); obstacle.Map = map; if (assetCode == "PB") { obstacle.PBTravelDistanceX = Convert.ToInt32(obstacleString[4]) * TheLastSliceGame.Instance.EntityWidth; } currentLevel.Obstacles.Add(obstacle); currentLevel.Entities.Add(new Vector3(column, row, mapNumber), obstacle); } else if (readInRandoms == true && currentLevel != null) { string[] pickupString = line.Split(','); string assetCode = pickupString[0]; int mapNumber = Convert.ToInt32(pickupString[1]); Map map = TheLastSliceGame.MapManager.Maps[mapNumber]; Vector2 location = currentLevel.GetRandomValidCell(map, mapNumber); int row = Convert.ToInt32(location.Y); int column = Convert.ToInt32(location.X); int xPos = (int)map.EntityGrid[row, column].Position.X; int yPos = (int)map.EntityGrid[row, column].Position.Y; bool isHeart = Pickup.isPickupType(PickupType.HE, assetCode); bool isBox = Pickup.isPickupType(PickupType.BX, assetCode); bool isCube = Pickup.isPickupType(PickupType.CU, assetCode); bool isGas = Pickup.isPickupType(PickupType.GS, assetCode); bool isTrash = Pickup.isPickupType(PickupType.TC, assetCode); if (isHeart || isBox || isCube || isGas || isTrash) { Pickup pickup = new Pickup(new Vector2(xPos, yPos), assetCode); pickup.Map = map; currentLevel.Pickups.Add(pickup); currentLevel.Entities.Add(new Vector3(column, row, mapNumber), pickup); } else { //Ingredients/Toppings Ingredient ingredient = new Ingredient(new Vector2(xPos, yPos), assetCode); ingredient.Map = map; currentLevel.Pickups.Add(ingredient); currentLevel.Entities.Add(new Vector3(column, row, mapNumber), ingredient); } } else if (currentMap != null && currentLevel != null && currentDeliveryHouse != null) { string[] ingredientString = line.Split(','); string assetCode = ingredientString[0]; int mapNumber = Convert.ToInt32(ingredientString[1]); Map map = TheLastSliceGame.MapManager.Maps[mapNumber]; Vector2 ingredientLocation = currentLevel.GetRandomValidCell(map, mapNumber, currentPizza); int row = Convert.ToInt32(ingredientLocation.Y); int column = Convert.ToInt32(ingredientLocation.X); int xPos = (int)map.EntityGrid[row, column].Position.X; int yPos = (int)map.EntityGrid[row, column].Position.Y; Ingredient ingredient = new Ingredient(new Vector2(xPos, yPos), assetCode); ingredient.Map = map; currentPizza.Add(ingredient); } } else if (currentLevel != null && currentDeliveryHouse != null && currentPizza != null) { currentLevel.AddDelivery(currentDeliveryHouse, currentPizza); currentDeliveryHouse = null; } else { readInPickUps = false; readInObstacles = false; readInRandoms = false; } } //Case where the delivery is the last thing in the txt file. if (currentLevel != null && currentDeliveryHouse != null && currentPizza != null) { currentLevel.AddDelivery(currentDeliveryHouse, currentPizza); currentDeliveryHouse = null; } }
public AudioEngine(string settingsFile) { if (String.IsNullOrEmpty(settingsFile)) { throw new ArgumentNullException("settingsFile"); } using (Stream stream = TitleContainer.OpenStream(settingsFile)) using (BinaryReader reader = new BinaryReader(stream)) { // Check the file header. Should be 'XGFS' if (reader.ReadUInt32() != 0x46534758) { throw new ArgumentException("XGFS format not recognized!"); } // Check the Content and Tool versions if (reader.ReadUInt16() != ContentVersion) { throw new ArgumentException("XGFS Content version!"); } if (reader.ReadUInt16() != 42) { throw new ArgumentException("XGFS Tool version!"); } // Unknown value reader.ReadUInt16(); // Last Modified, Unused reader.ReadUInt64(); // Unknown value reader.ReadByte(); // Number of AudioCategories ushort numCategories = reader.ReadUInt16(); // Number of XACT Variables ushort numVariables = reader.ReadUInt16(); // Unknown value, KEY#1 Length? reader.ReadUInt16(); // Unknown value, KEY#2 Length? reader.ReadUInt16(); // Number of RPC Variables ushort numRPCs = reader.ReadUInt16(); // Number of DSP Presets/Parameters ushort numDSPPresets = reader.ReadUInt16(); ushort numDSPParameters = reader.ReadUInt16(); // Category Offset in XGS File uint categoryOffset = reader.ReadUInt32(); // Variable Offset in XGS File uint variableOffset = reader.ReadUInt32(); // Unknown value, KEY#1 Offset? reader.ReadUInt32(); // Category Name Index Offset, unused reader.ReadUInt32(); // Unknown value, KEY#2 Offset? reader.ReadUInt32(); // Variable Name Index Offset, unused reader.ReadUInt32(); // Category Name Offset in XGS File uint categoryNameOffset = reader.ReadUInt32(); // Variable Name Offset in XGS File uint variableNameOffset = reader.ReadUInt32(); // RPC Variable Offset in XGS File uint rpcOffset = reader.ReadUInt32(); // DSP Preset/Parameter Offsets in XGS File uint dspPresetOffset = reader.ReadUInt32(); uint dspParameterOffset = reader.ReadUInt32(); // Obtain the Audio Category Names reader.BaseStream.Seek(categoryNameOffset, SeekOrigin.Begin); string[] categoryNames = new string[numCategories]; for (int i = 0; i < numCategories; i += 1) { List <char> builtString = new List <char>(); while (reader.PeekChar() != 0) { builtString.Add(reader.ReadChar()); } reader.ReadChar(); // Null terminator categoryNames[i] = new string(builtString.ToArray()); } // Obtain the Audio Categories reader.BaseStream.Seek(categoryOffset, SeekOrigin.Begin); INTERNAL_categories = new List <AudioCategory>(); for (int i = 0; i < numCategories; i += 1) { // Maximum instances byte maxInstances = reader.ReadByte(); // Fade In/Out ushort fadeInMS = reader.ReadUInt16(); ushort fadeOutMS = reader.ReadUInt16(); // Instance Behavior Flags int maxBehavior = reader.ReadByte() & 0x0F; // FIXME: What? // Unknown value reader.ReadUInt16(); // Volume float volume = XACTCalculator.CalculateVolume(reader.ReadByte()); // Visibility Flags, unused reader.ReadByte(); // Add to the engine list INTERNAL_categories.Add( new AudioCategory( categoryNames[i], volume, maxInstances, maxBehavior, fadeInMS, fadeOutMS ) ); } // Obtain the Variable Names reader.BaseStream.Seek(variableNameOffset, SeekOrigin.Begin); string[] variableNames = new string[numVariables]; for (int i = 0; i < numVariables; i += 1) { List <char> builtString = new List <char>(); while (reader.PeekChar() != 0) { builtString.Add(reader.ReadChar()); } reader.ReadChar(); // Null terminator variableNames[i] = new string(builtString.ToArray()); } // Obtain the Variables reader.BaseStream.Seek(variableOffset, SeekOrigin.Begin); INTERNAL_variables = new List <Variable>(); for (int i = 0; i < numVariables; i += 1) { // Variable Accessibility (See Variable constructor) byte varFlags = reader.ReadByte(); // Variable Value, Boundaries float initialValue = reader.ReadSingle(); float minValue = reader.ReadSingle(); float maxValue = reader.ReadSingle(); // Add to the engine list INTERNAL_variables.Add( new Variable( variableNames[i], (varFlags & 0x01) != 0, (varFlags & 0x02) != 0, (varFlags & 0x04) == 0, (varFlags & 0x08) != 0, initialValue, minValue, maxValue ) ); } // Append built-in properties to Variable list bool hasVolume = false; foreach (Variable curVar in INTERNAL_variables) { if (curVar.Name.Equals("Volume")) { hasVolume = true; } } if (!hasVolume) { INTERNAL_variables.Add( new Variable( "Volume", true, false, false, false, 1.0f, 0.0f, 1.0f ) ); } // Obtain the RPC Curves reader.BaseStream.Seek(rpcOffset, SeekOrigin.Begin); INTERNAL_RPCs = new Dictionary <long, RPC>(); for (int i = 0; i < numRPCs; i += 1) { // RPC "Code", used by the SoundBanks long rpcCode = reader.BaseStream.Position; // RPC Variable ushort rpcVariable = reader.ReadUInt16(); // Number of RPC Curve Points byte numPoints = reader.ReadByte(); // RPC Parameter ushort rpcParameter = reader.ReadUInt16(); // RPC Curve Points RPCPoint[] rpcPoints = new RPCPoint[numPoints]; for (byte j = 0; j < numPoints; j += 1) { float x = reader.ReadSingle(); float y = reader.ReadSingle(); byte type = reader.ReadByte(); rpcPoints[j] = new RPCPoint( x, y, (RPCPointType)type ); } // Add to the engine list INTERNAL_RPCs.Add( rpcCode, new RPC( INTERNAL_variables[rpcVariable].Name, rpcParameter, rpcPoints ) ); } // Obtain the DSP Parameters reader.BaseStream.Seek(dspParameterOffset, SeekOrigin.Begin); INTERNAL_dspParameters = new List <DSPParameter>(); for (int i = 0; i < numDSPParameters; i += 1) { // Effect Parameter Type byte type = reader.ReadByte(); // Effect value, boundaries float value = reader.ReadSingle(); float minVal = reader.ReadSingle(); float maxVal = reader.ReadSingle(); // Unknown value reader.ReadUInt16(); // Add to Parameter list INTERNAL_dspParameters.Add( new DSPParameter( type, value, minVal, maxVal ) ); } // Obtain the DSP Presets reader.BaseStream.Seek(dspPresetOffset, SeekOrigin.Begin); INTERNAL_dspPresets = new Dictionary <long, DSPPreset>(); int total = 0; for (int i = 0; i < numDSPPresets; i += 1) { // DSP "Code", used by the SoundBanks long dspCode = reader.BaseStream.Position; // Preset Accessibility bool global = (reader.ReadByte() == 1); // Number of preset parameters uint numParams = reader.ReadUInt32(); // Obtain DSP Parameters DSPParameter[] parameters = new DSPParameter[numParams]; for (uint j = 0; j < numParams; j += 1) { parameters[j] = INTERNAL_dspParameters[total]; total += 1; } // Add to DSP Preset list INTERNAL_dspPresets.Add( dspCode, new DSPPreset( global, parameters ) ); } } // Create the WaveBank Dictionary INTERNAL_waveBanks = new Dictionary <string, WaveBank>(); // Finally. IsDisposed = false; }
/// <summary> /// Loads map from the Tiled "tmx" file. /// </summary> /// <param name="tmxFile">TMX File path.</param> /// <returns>Loaded map.</returns> private static Level LoadMap(int id, string tmxFile) { Map map = null; List <Entity> entities = new List <Entity>(); using (var stream = TitleContainer.OpenStream(tmxFile)) { XDocument doc = XDocument.Load(stream); #region Create Map XElement mapElement = doc.Element("map"); string name = Path.GetFileName(tmxFile).Replace(".tmx", ""); Point size = new Point(int.Parse(mapElement.Attribute("width").Value), int.Parse(mapElement.Attribute("height").Value)); Point tileSize = new Point(int.Parse(mapElement.Attribute("tilewidth").Value), int.Parse(mapElement.Attribute("tileheight").Value)); map = new Map(name, size, tileSize); #endregion Create Map #region Tilesets foreach (XElement set in mapElement.Elements("tileset")) { Tileset tileset; int firstgid = int.Parse(set.Attribute("firstgid").Value.Replace("../", "")); if (set.Attribute("source") == null) { string tilename = set.Attribute("name").Value; Point tilesSize = new Point(int.Parse(set.Attribute("tilewidth").Value), int.Parse(set.Attribute("tileheight").Value)); XElement image = set.Element("image"); string imageSource = image.Attribute("source").Value.Replace("../", ""); //Removes relative path (since we'll use Content) Point imageSize = new Point(int.Parse(image.Attribute("width").Value), int.Parse(image.Attribute("height").Value)); tileset = new Tileset(firstgid, tilename, tilesSize, imageSource, imageSize); #region Tiles foreach (XElement element in set.Elements("tile")) { int tileid = int.Parse(element.Attribute("id").Value); string[] terrain = element.Attribute("terrain").Value.Split(','); tileset.Tiles[tileid].SetCollision(CollisionPosition.UpperLeft, int.Parse(terrain[0])); tileset.Tiles[tileid].SetCollision(CollisionPosition.UpperRight, int.Parse(terrain[1])); tileset.Tiles[tileid].SetCollision(CollisionPosition.DownLeft, int.Parse(terrain[2])); tileset.Tiles[tileid].SetCollision(CollisionPosition.DownRight, int.Parse(terrain[3])); } #endregion Tiles } else { tileset = LoadTileset(firstgid, "Content/" + set.Attribute("source").Value.Replace("../", "")); } map.Tilesets.Add(tileset); } map.UpdateTilesets(); #endregion Tilesets #region Layers foreach (XElement lay in mapElement.Elements("layer")) { string layerName = lay.Attribute("name").Value; Point layersize = new Point(int.Parse(lay.Attribute("width").Value), int.Parse(lay.Attribute("height").Value)); string csvdata = lay.Element("data").Value; Layer layer = new Layer(layerName, layersize, csvdata); map.Layers.Add(layer); } #endregion Layers #region Objects var enemyFactory = new Dictionary <string, Func <Entity> > { { "Crab", () => new Crab() }, { "Slime", () => new Slime() }, { "SlimeWorm", () => new SlimeWorm() }, { "FlameDragon", () => new FlameDragon() }, { "WaterDragon", () => new WaterDragon() }, { "Bat", () => new Bat() }, { "Zombie", () => new Zombie() }, { "Skelleton", () => new Skeleton() }, { "Goon", () => new Goon() }, { "MasterGoon", () => new MasterGoon() }, { "BoomerangSkeleton", () => new BoomerangSkeleton() }, { "Poltergeist", () => new Poltergeist() }, { "Knight", () => new Knight() }, }; var itemFactory = new Dictionary <string, Func <Entity> > { { "Sword", () => new Sword() }, { "Bow", () => new Bow() }, { "Boomerang", () => new Boomerang() }, { "FireWand", () => new FireWand() }, }; var objectFactory = new Dictionary <string, Func <Entity> > { { "Bush", () => new Bush() } }; var entityFactory = new Dictionary <string, Func <string, Entity> > { { "Player", n => new Player() }, { "Entrance", n => new Entrance(int.Parse(n)) }, { "SavePoint", n => new SavePoint() }, { "Item", n => itemFactory.ContainsKey(n)? itemFactory[n]() : new Item() }, { "Enemy", n => enemyFactory.ContainsKey(n)? enemyFactory[n]() : new Slime() }, { "Object", n => objectFactory.ContainsKey(n)? objectFactory[n]() : new Bush() } }; entities = mapElement.Elements("objectgroup") .Elements("object") .Select(n => CreateEntity(entityFactory, id, n)).ToList(); #endregion Objects } return(new Level(id, map, entities)); }
private void LoadNextLevel() { // move to the next level if (level != null) { levelIndex = (PlatformerGame.attacker_id == 0) ? (levelIndex + 1) % numberOfLevels : (levelIndex - 1) % numberOfLevels; } else { levelIndex = (levelIndex + 1) % numberOfLevels; } // Provide the background set string[] backgroundSet = new string[3] { "Backgrounds/Background0_0", "Backgrounds/Background0_1", "Backgrounds/Background0_2" }; switch (levelIndex) { case 2: case 4: backgroundSet[0] = "Backgrounds/Background1_0"; backgroundSet[1] = "Backgrounds/Background1_1"; backgroundSet[2] = "Backgrounds/Background1_2"; break; case 3: backgroundSet[0] = "Backgrounds/Background0_0"; backgroundSet[1] = "Backgrounds/Background0_1"; backgroundSet[2] = "Backgrounds/Background0_2"; break; case 1: case 5: backgroundSet[0] = "Backgrounds/Background2_0"; backgroundSet[1] = "Backgrounds/Background2_1"; backgroundSet[2] = "Backgrounds/Background2_2"; break; case 0: case 6: backgroundSet[0] = null; backgroundSet[1] = null; backgroundSet[2] = null; break; } //If the either reaches the last level, remove the other player if (levelIndex == 6 || levelIndex == 0) { int idx = (attacker_id == 0) ? 1 : 0; Players[idx].IsRespawnable = false; Players[idx].Reset(Vector2.Zero); bossFight = true; try { MediaPlayer.Stop(); MediaPlayer.Play(content.Load <Song>("Sounds/Music/smb-castle")); } catch { } } // Unloads the content for the current level before loading the next one. if (level != null) { foreach (Player player in PlatformerGame.Players) { player.OnHit -= player_OnHit; player.IsRespawnable = true; } level.Dispose(); } // Load the level. string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex); using (Stream fileStream = TitleContainer.OpenStream(levelPath)) { level = new Level(ScreenManager.Game.Services, fileStream, levelIndex, backgroundSet, this); foreach (Player player in PlatformerGame.Players) { player.OnHit += new OnHitHandler(player_OnHit); } } startLevelDelayTimer = true; }
/// <summary> /// 读取图片内容 /// </summary> /// <param name="p_DirectoryName">文件夹名称</param> /// <returns></returns> public static Stream ReadFile(String p_FileName) { return(TitleContainer.OpenStream(p_FileName)); }
/// <summary> /// /// </summary> /// <param name="containerName"></param> /// <param name="fileName"></param> /// <param name="loadAction"></param> public void Load(String containerName, String fileName, FileAction loadAction) { loadAction.Invoke(TitleContainer.OpenStream(String.Join(@"\", containerName, fileName))); }
public static void Setup(ContentManager content) { Content = content; SoundManager = new SoundManager(); UpdateVolume(); Infinite = content.Load <Effect>("infinite"); Sky = content.Load <Texture2D>("sky"); Mountains = content.Load <Texture2D>("mountains_2"); Clouds = content.Load <Texture2D>("clouds"); Ground = content.Load <Texture2D>("grass_and_path"); Shrub1 = content.Load <Texture2D>("shrub_1"); Shrub2 = content.Load <Texture2D>("shrub_2"); Shrub3 = content.Load <Texture2D>("shrub_3"); Shrub4 = content.Load <Texture2D>("shrub_4"); Tree = content.Load <Texture2D>("tree"); UIFont = DynamicSpriteFont.FromTtf(TitleContainer.OpenStream("Content/Lato-Bold.ttf"), 16); CharacterSprites = new Dictionary <CharacterType, CharacterSprite>() { { CharacterType.Warrior, new CharacterSprite() { Texture = content.Load <Texture2D>("warrior"), HitTexture = content.Load <Texture2D>("warrior_hit") } }, { CharacterType.Archer, new CharacterSprite() { Texture = content.Load <Texture2D>("archer"), HitTexture = content.Load <Texture2D>("archer_hit") } }, { CharacterType.Wizard, new CharacterSprite() { Texture = content.Load <Texture2D>("wizard"), HitTexture = content.Load <Texture2D>("wizard_hit") } }, { CharacterType.Cleric, new CharacterSprite() { Texture = content.Load <Texture2D>("cleric"), HitTexture = content.Load <Texture2D>("cleric_hit") } }, { CharacterType.GoblinMinion, new CharacterSprite() { Texture = content.Load <Texture2D>("goblin_minion"), HitTexture = content.Load <Texture2D>("goblin_minion_hit") } }, { CharacterType.GoblinBrute, new CharacterSprite() { Texture = content.Load <Texture2D>("goblin_brute"), HitTexture = content.Load <Texture2D>("goblin_brute_hit") } }, { CharacterType.GoblinShaman, new CharacterSprite() { Texture = content.Load <Texture2D>("goblin_shaman"), HitTexture = content.Load <Texture2D>("goblin_shaman_hit") } }, { CharacterType.Dragon, new CharacterSprite() { Texture = content.Load <Texture2D>("dragon"), HitTexture = content.Load <Texture2D>("dragon_hit") } }, }; AbilitySpecialEffectTextures = new Dictionary <AbilitySpecialEffectType, Texture2D>() { { AbilitySpecialEffectType.Shield, content.Load <Texture2D>("effect_shield") }, { AbilitySpecialEffectType.Slash, content.Load <Texture2D>("effect_slash") }, { AbilitySpecialEffectType.Fireball, content.Load <Texture2D>("effect_fireball") }, { AbilitySpecialEffectType.Fire, content.Load <Texture2D>("effect_fire") }, { AbilitySpecialEffectType.Poison, content.Load <Texture2D>("effect_poison") }, { AbilitySpecialEffectType.Magic, content.Load <Texture2D>("effect_magic") }, { AbilitySpecialEffectType.Arrow, content.Load <Texture2D>("effect_arrow") }, { AbilitySpecialEffectType.Heal, content.Load <Texture2D>("effect_heal") } }; }
public AudioEngine(string settingsFile) { if (String.IsNullOrEmpty(settingsFile)) { throw new ArgumentNullException("settingsFile"); } using (Stream stream = TitleContainer.OpenStream(settingsFile)) using (BinaryReader reader = new BinaryReader(stream)) { // Check the file header. Should be 'XGSF' if (reader.ReadUInt32() != 0x46534758) { throw new ArgumentException("XGSF format not recognized!"); } // Check the Content and Tool versions if (reader.ReadUInt16() != ContentVersion) { throw new ArgumentException("XGSF Content version!"); } if (reader.ReadUInt16() != 42) { throw new ArgumentException("XGSF Tool version!"); } // Unknown value reader.ReadUInt16(); // Last Modified, Unused reader.ReadUInt64(); // XACT Version, Unused reader.ReadByte(); // Number of AudioCategories ushort numCategories = reader.ReadUInt16(); // Number of XACT Variables ushort numVariables = reader.ReadUInt16(); // KEY#1 Length /*ushort numKeyOne =*/ reader.ReadUInt16(); // KEY#2 Length /*ushort numKeyTwo =*/ reader.ReadUInt16(); // Number of RPC Variables ushort numRPCs = reader.ReadUInt16(); // Number of DSP Presets/Parameters ushort numDSPPresets = reader.ReadUInt16(); ushort numDSPParameters = reader.ReadUInt16(); // Category Offset in XGS File uint categoryOffset = reader.ReadUInt32(); // Variable Offset in XGS File uint variableOffset = reader.ReadUInt32(); // KEY#1 Offset /*uint keyOneOffset =*/ reader.ReadUInt32(); // Category Name Index Offset, unused reader.ReadUInt32(); // KEY#2 Offset /*uint keyTwoOffset =*/ reader.ReadUInt32(); // Variable Name Index Offset, unused reader.ReadUInt32(); // Category Name Offset in XGS File uint categoryNameOffset = reader.ReadUInt32(); // Variable Name Offset in XGS File uint variableNameOffset = reader.ReadUInt32(); // RPC Variable Offset in XGS File uint rpcOffset = reader.ReadUInt32(); // DSP Preset/Parameter Offsets in XGS File uint dspPresetOffset = reader.ReadUInt32(); uint dspParameterOffset = reader.ReadUInt32(); /* Unknown table #1 * reader.BaseStream.Seek(keyOneOffset, SeekOrigin.Begin); * for (int i = 0; i < numKeyOne; i += 1) * { * // Appears to consistently be 16 shorts? * System.Console.WriteLine(reader.ReadInt16()); * } * /* OhGodNo * 1, -1, 4, -1, * 3, -1, -1, 7, * -1, 2, 5, -1, * 6, 0, -1, -1 * * Naddachance * 1, -1, 4, -1, * 5, -1, -1, -1, * -1, 2, -1, -1, * 3, 0, -1, -1 * * TFA * 1, -1, -1, -1, * -1, -1, -1, -1, * -1, 2, -1, -1, * -1, -0, -1, -1 */ /* Unknown table #2 * reader.BaseStream.Seek(keyTwoOffset, SeekOrigin.Begin); * for (int i = 0; i < numKeyTwo; i += 1) * { * // Appears to be between 16-20 shorts? * System.Console.WriteLine(reader.ReadInt16()); * } * /* OhGodNo * 2, 7, 1, -1, * -1, 10, 19, -1, * 11, 3, -1, -1, * 8, -1, 14, 5, * 12, 0, 4, 6 * * Naddachance * 2, 3, -1, -1, * 9, -1, 7, -1, * 10, 0, 1, 5, * -1, -1, -1, -1 * * TFA * 2, 3, -1, -1, * -1, -1, -1, -1, * -1, 0, 1, 5, * -1, -1, -1, -1 */ // Obtain the Audio Category Names reader.BaseStream.Seek(categoryNameOffset, SeekOrigin.Begin); string[] categoryNames = new string[numCategories]; for (int i = 0; i < numCategories; i += 1) { List <char> builtString = new List <char>(); while (reader.PeekChar() != 0) { builtString.Add(reader.ReadChar()); } reader.ReadChar(); // Null terminator categoryNames[i] = new string(builtString.ToArray()); } // Obtain the Audio Categories reader.BaseStream.Seek(categoryOffset, SeekOrigin.Begin); INTERNAL_categories = new List <AudioCategory>(); for (int i = 0; i < numCategories; i += 1) { // Maximum instances byte maxInstances = reader.ReadByte(); // Fade In/Out ushort fadeInMS = reader.ReadUInt16(); ushort fadeOutMS = reader.ReadUInt16(); // Instance Behavior Flags byte instanceFlags = reader.ReadByte(); int fadeType = instanceFlags & 0x07; int maxBehavior = instanceFlags >> 3; // Parent Category short parent = reader.ReadInt16(); // Volume float volume = XACTCalculator.CalculateVolume(reader.ReadByte()); // Visibility Flags, unused reader.ReadByte(); // Add to the engine list and the parent category INTERNAL_categories.Add( new AudioCategory( categoryNames[i], volume, maxInstances, maxBehavior, fadeInMS, fadeOutMS, fadeType ) ); if (parent != -1) { INTERNAL_categories[parent].subCategories.Add( INTERNAL_categories[i] ); } } // Obtain the Variable Names reader.BaseStream.Seek(variableNameOffset, SeekOrigin.Begin); string[] variableNames = new string[numVariables]; for (int i = 0; i < numVariables; i += 1) { List <char> builtString = new List <char>(); while (reader.PeekChar() != 0) { builtString.Add(reader.ReadChar()); } reader.ReadChar(); // Null terminator variableNames[i] = new string(builtString.ToArray()); } // Obtain the Variables reader.BaseStream.Seek(variableOffset, SeekOrigin.Begin); INTERNAL_variables = new List <Variable>(); for (int i = 0; i < numVariables; i += 1) { // Variable Accessibility (See Variable constructor) byte varFlags = reader.ReadByte(); // Variable Value, Boundaries float initialValue = reader.ReadSingle(); float minValue = reader.ReadSingle(); float maxValue = reader.ReadSingle(); // Add to the engine list INTERNAL_variables.Add( new Variable( variableNames[i], (varFlags & 0x01) != 0, (varFlags & 0x02) != 0, (varFlags & 0x04) == 0, (varFlags & 0x08) != 0, initialValue, minValue, maxValue ) ); } // Obtain the RPC Curves reader.BaseStream.Seek(rpcOffset, SeekOrigin.Begin); INTERNAL_RPCs = new Dictionary <long, RPC>(); for (int i = 0; i < numRPCs; i += 1) { // RPC "Code", used by the SoundBanks long rpcCode = reader.BaseStream.Position; // RPC Variable ushort rpcVariable = reader.ReadUInt16(); // Number of RPC Curve Points byte numPoints = reader.ReadByte(); // RPC Parameter ushort rpcParameter = reader.ReadUInt16(); // RPC Curve Points RPCPoint[] rpcPoints = new RPCPoint[numPoints]; for (byte j = 0; j < numPoints; j += 1) { float x = reader.ReadSingle(); float y = reader.ReadSingle(); byte type = reader.ReadByte(); rpcPoints[j] = new RPCPoint( x, y, (RPCPointType)type ); } // Add to the engine list INTERNAL_RPCs.Add( rpcCode, new RPC( INTERNAL_variables[rpcVariable].Name, rpcParameter, rpcPoints ) ); } // Obtain the DSP Parameters reader.BaseStream.Seek(dspParameterOffset, SeekOrigin.Begin); INTERNAL_dspParameters = new List <DSPParameter>(); for (int i = 0; i < numDSPParameters; i += 1) { // Effect Parameter Type byte type = reader.ReadByte(); // Effect value, boundaries float value = reader.ReadSingle(); float minVal = reader.ReadSingle(); float maxVal = reader.ReadSingle(); // Unknown value reader.ReadUInt16(); // Add to Parameter list INTERNAL_dspParameters.Add( new DSPParameter( type, value, minVal, maxVal ) ); } // Obtain the DSP Presets reader.BaseStream.Seek(dspPresetOffset, SeekOrigin.Begin); INTERNAL_dspPresets = new Dictionary <long, DSPPreset>(); int total = 0; for (int i = 0; i < numDSPPresets; i += 1) { // DSP "Code", used by the SoundBanks long dspCode = reader.BaseStream.Position; // Preset Accessibility bool global = (reader.ReadByte() == 1); // Number of preset parameters uint numParams = reader.ReadUInt32(); // Obtain DSP Parameters DSPParameter[] parameters = new DSPParameter[numParams]; for (uint j = 0; j < numParams; j += 1) { parameters[j] = INTERNAL_dspParameters[total]; total += 1; } // Add to DSP Preset list INTERNAL_dspPresets.Add( dspCode, new DSPPreset( global, parameters ) ); } } // Create the WaveBank Dictionary INTERNAL_waveBanks = new Dictionary <string, WaveBank>(); // Finally. IsDisposed = false; }
public Texture2D LoadTexture(GraphicsDevice device, string filepath) => FromStream(device, TitleContainer.OpenStream(filepath));
public static bool inputUpsellScreen() { if (!Upsell.showUpsell) { return(false); } Upsell.pressed_button = -1; if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { if (Upsell.anm_progress != -1) { Upsell.anm_progress = -1; return(true); } Upsell.disposeUpsellScreen(); if (Upsell.buy_scr_work != null) { Upsell.buy_scr_work.result[0] = 2; AppMain.DmSndBgmPlayerPlayBgm(0); } else { AppMain.SyDecideEvtCase((short)1); AppMain.SyChangeNextEvt(); } return(true); } TouchCollection state = TouchPanel.GetState(); if (state.Count == 0) { if (Upsell.px == 0 && Upsell.py == 0) { return(true); } Upsell.curState = 1; Upsell.cx = Upsell.px; Upsell.cy = Upsell.py; Upsell.px = 0; Upsell.py = 0; } else { TouchLocation touchLocation = state[0]; if (touchLocation.State == TouchLocationState.Pressed || touchLocation.State == TouchLocationState.Moved) { Upsell.curState = 0; Upsell.cx = (int)touchLocation.Position.X; Upsell.cy = (int)touchLocation.Position.Y; } if (touchLocation.State == TouchLocationState.Released || touchLocation.State == TouchLocationState.Invalid) { Upsell.curState = 1; Upsell.cx = Upsell.px; Upsell.cy = Upsell.py; Upsell.px = 0; Upsell.py = 0; } } Upsell.hl_buttons[0] = false; Upsell.hl_buttons[1] = false; if (Upsell.anm_progress > 100) { Upsell.anm_progress = -Upsell.anm_progress; Upsell.curState = 1; Upsell.cx = Upsell.px; Upsell.cy = Upsell.py; Upsell.px = 0; Upsell.py = 0; return(true); } if (Upsell.anm_progress != -1) { return(true); } for (int index = 0; index < 5; ++index) { if (Upsell.rects[index].Contains(Upsell.cx, Upsell.cy)) { Upsell.pressed_button = index; break; } } switch (Upsell.pressed_button) { case 0: if (Upsell.curState == 0) { Upsell.hl_buttons[0] = true; break; } Upsell.disposeUpsellScreen(); if (Upsell.buy_scr_work != null) { Upsell.buy_scr_work.result[0] = 2; AppMain.DmSndBgmPlayerPlayBgm(0); break; } AppMain.SyDecideEvtCase((short)1); AppMain.SyChangeNextEvt(); break; case 1: if (Upsell.curState == 0) { Upsell.hl_buttons[1] = true; break; } Upsell.wasUpsell = true; XBOXLive.showGuide(); break; case 2: if (Upsell.curState == 1) { --Upsell.ss_num; if (Upsell.ss_num < 1) { Upsell.ss_num = 5; } Upsell.screenshot.Dispose(); Upsell.screenshot = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4us_ss_" + (object)Upsell.ss_num + ".png")); break; } break; case 3: if (Upsell.curState == 1) { ++Upsell.ss_num; if (Upsell.ss_num >= 5) { Upsell.ss_num = 1; } Upsell.screenshot.Dispose(); Upsell.screenshot = Texture2D.FromStream(LiveFeature.GAME.GraphicsDevice, TitleContainer.OpenStream("Content\\UPSELL\\s4us_ss_" + (object)Upsell.ss_num + ".png")); break; } break; case 4: if (Upsell.curState == 0) { Upsell.anm_progress = 0; break; } break; } if (Upsell.curState == 0) { Upsell.px = Upsell.cx; Upsell.py = Upsell.cy; } else { Upsell.curState = -1; } return(true); }
static ParticleEmitterConfig Load(XDocument xDoc, string rootDir) { var root = xDoc.Element("particleEmitterConfig"); var config = new ParticleEmitterConfig { SourcePosition = GetVectorElement(root, "sourcePosition"), SourcePositionVariance = GetVectorElement(root, "sourcePositionVariance"), Speed = GetFloatElement(root, "speed"), SpeedVariance = GetFloatElement(root, "speedVariance"), ParticleLifespan = GetFloatElement(root, "particleLifeSpan"), ParticleLifespanVariance = GetFloatElement(root, "particleLifespanVariance"), Angle = GetFloatElement(root, "angle"), AngleVariance = GetFloatElement(root, "angleVariance"), Gravity = GetVectorElement(root, "gravity"), RadialAcceleration = GetFloatElement(root, "radialAcceleration"), RadialAccelVariance = GetFloatElement(root, "radialAccelVariance"), TangentialAcceleration = GetFloatElement(root, "tangentialAcceleration"), TangentialAccelVariance = GetFloatElement(root, "tangentialAccelVariance"), StartColor = GetColorElement(root, "startColor"), StartColorVariance = GetColorElement(root, "startColorVariance"), FinishColor = GetColorElement(root, "finishColor"), FinishColorVariance = GetColorElement(root, "finishColorVariance"), MaxParticles = (uint)GetIntElement(root, "maxParticles"), StartParticleSize = GetFloatElement(root, "startParticleSize"), StartParticleSizeVariance = GetFloatElement(root, "startParticleSizeVariance"), FinishParticleSize = GetFloatElement(root, "finishParticleSize"), FinishParticleSizeVariance = root.Element("finishParticleSizeVariance") != null?GetFloatElement(root, "finishParticleSizeVariance") : GetFloatElement(root, "FinishParticleSizeVariance"), Duration = GetFloatElement(root, "duration"), EmitterType = (ParticleEmitterType)GetIntElement(root, "emitterType"), MaxRadius = GetFloatElement(root, "maxRadius"), MaxRadiusVariance = GetFloatElement(root, "maxRadiusVariance"), MinRadius = GetFloatElement(root, "minRadius"), MinRadiusVariance = GetFloatElement(root, "minRadiusVariance"), RotatePerSecond = GetFloatElement(root, "rotatePerSecond"), RotatePerSecondVariance = GetFloatElement(root, "rotatePerSecondVariance"), BlendFuncSource = GetBlendElement(root, "blendFuncSource"), BlendFuncDestination = GetBlendElement(root, "blendFuncDestination"), RotationStart = GetFloatElement(root, "rotationStart"), RotationStartVariance = GetFloatElement(root, "rotationStartVariance"), RotationEnd = GetFloatElement(root, "rotationEnd"), RotationEndVariance = GetFloatElement(root, "rotationEndVariance") }; config.EmissionRate = config.MaxParticles / config.ParticleLifespan; if (float.IsInfinity(config.EmissionRate)) { Debug.Error("---- particle system EmissionRate (MaxParticles / ParticleLifespace) is infinity. Resetting to 10000"); config.EmissionRate = 10000; } var textureElement = root.Element("texture"); var data = textureElement.Attribute("data"); // texture could be either a separate file or base64 encoded tiff if (data != null) { using (var memoryStream = new MemoryStream(Convert.FromBase64String((string)data), writable: false)) { using (var stream = new GZipStream(memoryStream, CompressionMode.Decompress)) { using (var mem = new MemoryStream()) { stream.CopyTo(mem); var bitmap = System.Drawing.Image.FromStream(mem) as System.Drawing.Bitmap; var colors = new Color[bitmap.Width * bitmap.Height]; for (var x = 0; x < bitmap.Width; x++) { for (var y = 0; y < bitmap.Height; y++) { var drawColor = bitmap.GetPixel(x, y); colors[x + y * bitmap.Width] = new Color(drawColor.R, drawColor.G, drawColor.B, drawColor.A); } } var texture = new Texture2D(Core.GraphicsDevice, bitmap.Width, bitmap.Height); texture.SetData(colors); config.Sprite = new Textures.Sprite(texture); } } } } else { var path = Path.Combine(rootDir, (string)textureElement.Attribute("name")); using (var stream = TitleContainer.OpenStream(path)) { var texture = Texture2D.FromStream(Core.GraphicsDevice, stream); config.Sprite = new Textures.Sprite(texture); } } return(config); }
public static Dictionary <String, T> LoadContent <T>(this ContentManager contentManager) { Dictionary <String, T> result = new Dictionary <String, T>(); string key = string.Empty; string extension = string.Empty; #if ANDROID string sResults = string.Empty; var filePath = Path.Combine("", "results.txt"); using (var stream = TitleContainer.OpenStream(filePath)) { sResults = Utils.StreamToString(stream); stream.Close(); } string[] sArray = sResults.Split('\r'); int xCount = 0; for (int x = 0; x < sArray.Count(); x++) { LoaderCount = (int)Math.Round((double)(100 * ++xCount) / sArray.Count()); int a = sArray[x].IndexOf("Content\\"); if (a == -1) { continue; } extension = sArray[x].Substring(sArray[x].Length - 4, 4); sArray[x] = sArray[x].Remove(0, a + "Content\\".Length); if (extension != ".xnb") { if (extension != ".fnt") { continue; } } sArray[x] = sArray[x].Replace('\\', '/'); key = sArray[x].Substring(0, sArray[x].Length - 4); if (extension == ".xnb") { result[key] = contentManager.Load <T>(key); } else { result[key] = (T)(object)FontLoader.Load(PoP.CONFIG_PATH_CONTENT + key + extension); } } #else //Load directory info, abort if none System.Console.WriteLine("---------------------------------------------"); System.Console.WriteLine(contentManager.RootDirectory); DirectoryInfo dir = new DirectoryInfo(contentManager.RootDirectory); System.Console.WriteLine("---------------------------------------------"); if (!dir.Exists) { throw new DirectoryNotFoundException(); } var files = Directory .GetFiles(contentManager.RootDirectory, "*.*", SearchOption.AllDirectories) .Where(file => file.ToLower().EndsWith("xnb") || file.ToLower().EndsWith("fnt")) .ToList(); int xCount = 0; foreach (object f in files) { LoaderCount = (int)Math.Round((double)(100 * ++xCount) / files.Count); key = string.Empty; string fileName = f.ToString().Replace('\\', '/'); extension = fileName.Substring(fileName.Length - 4); int fileExtPos = fileName.LastIndexOf("."); if (fileExtPos >= 0) { fileName = fileName.Substring(0, fileExtPos); } //remove contentManager.RootDirectory fileExtPos = fileName.LastIndexOf(contentManager.RootDirectory) + (contentManager.RootDirectory + "/").Length; if (fileExtPos > 1) { key = fileName.Substring(fileExtPos); } try { //bug in the monogame load song, i will add the wav extension??!?!? if (extension.Contains(".wav") == true) { result[key] = (T)(object)contentManager.Load <Song>(key + extension); } else if (extension.Contains(".fnt") == true) { result[key] = (T)(object)FontLoader.Load(PoP.CONFIG_PATH_CONTENT + key + extension); } else { result[key] = contentManager.Load <T>(key); } } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } //result[f.N] = contentManager.Load<T>(sFolder + key); } #endif return(result); }
private static SoundEffectInstance get_music(string cue_name) { SoundEffect song = null; SoundEffectInstance music = null; int intro_start = 0, loop_start = -1, loop_length = -1; NVorbis.VorbisReader vorbis = null; try { try { Stream cue_stream = TitleContainer.OpenStream(@"Content\Audio\BGM\" + cue_name + ".ogg"); #if __ANDROID__ MemoryStream stream = new MemoryStream(); cue_stream.CopyTo(stream); vorbis = new NVorbis.VorbisReader(stream, cue_name, true); #else vorbis = new NVorbis.VorbisReader(cue_stream, cue_name, true); #endif get_loop_data(vorbis, out intro_start, out loop_start, out loop_length); // If the loop points are set past the end of the song, don't play if (vorbis.TotalSamples < loop_start || vorbis.TotalSamples < loop_start + loop_length) { #if DEBUG throw new IndexOutOfRangeException("Loop points are set past the end of the song"); #endif #if __ANDROID__ cue_stream.Dispose(); vorbis.Dispose(); #else vorbis.Dispose(); #endif throw new FileNotFoundException(); } #if __ANDROID__ cue_stream.Dispose(); #endif } catch (FileNotFoundException ex) { throw; } #if __ANDROID__ catch (Java.IO.FileNotFoundException e) { throw; } #endif } // If loaded as an ogg failed, try loading as a SoundEffect catch (FileNotFoundException ex) { intro_start = 0; loop_start = -1; loop_length = -1; song = Global.Content.Load <SoundEffect>(@"Audio/" + cue_name); } // If the file is an ogg file and was found and initialized successfully if (vorbis != null) { music = get_vorbis_music(vorbis, cue_name, intro_start, loop_start, loop_length); } else { music = get_effect_music(song, cue_name, intro_start, loop_start, loop_length); } if (music != null) { music.IsLooped = true; } #if !__ANDROID__ if (song != null) { song.Dispose(); } #endif return(music); }
/// <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); // Load menu items // Menu design thanks to: https://youtu.be/54L_w0PiRa8 // Source: http://pixshark.com/cool-black-backgrounds-for-powerpoint.htm // Title: black history menuBackground = Content.Load <Texture2D>("menu\\background"); // All text buttons generated on cooltext.com // Baskerville font btnPlay = new cButton(Content.Load <Texture2D>("menu\\play"), graphics.GraphicsDevice); btnPlay.setPosition(new Vector2(350, 250)); btnOptions = new cButton(Content.Load <Texture2D>("menu\\options"), graphics.GraphicsDevice); btnOptions.setPosition(new Vector2(350, 350)); btnExit = new cButton(Content.Load <Texture2D>("menu\\exit"), graphics.GraphicsDevice); btnExit.setPosition(new Vector2(350, 450)); // Dashboard items blackRectangleTexture = new Texture2D(graphics.GraphicsDevice, 1, 1); blackRectangleTexture.SetData(new[] { Color.Navy }); blackRectangle = new Rectangle(0, GameConstants.WINDOW_HEIGHT - GameConstants.DASHBOARD_HEIGHT, GameConstants.DASHBOARD_WIDTH, GameConstants.DASHBOARD_HEIGHT); // Load fonts arialFont = Content.Load <SpriteFont>("fonts\\Arial20"); // Load sounds keyPressSound = Content.Load <SoundEffect>("sounds\\keypress"); wordSuccessSound = Content.Load <SoundEffect>("sounds\\wordsuccess"); lifeLostSound = Content.Load <SoundEffect>("sounds\\lifelost"); // Source: http://freesound.org/people/Autistic%20Lucario/sounds/142608/ errorSound = Content.Load <SoundEffect>("sounds\\error"); // Source: http://www.freesfx.co.uk/download/?type=mp3&id=9630 wordDeleteSound = Content.Load <SoundEffect>("sounds\\worddelete"); // Source also freesfx letterDeleteSound = Content.Load <SoundEffect>("sounds\\deleteletter"); // Source: http://www.freesound.org/people/themusicalnomad/sounds/253886/ gameOverSound = Content.Load <SoundEffect>("sounds\\gameover"); // Load and play game music gameMusic = Content.Load <Song>("sounds\\shiningstar"); // Load letter textures List <Texture2D> textureList; for (char c = 'a'; c <= 'z'; c++) { textureList = new List <Texture2D>(10); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_black")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_blue")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_dg")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_gold")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_grey")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_lg")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_orange")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_pink")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_red")); textureList.Add(Content.Load <Texture2D>("letters\\64\\" + c + "_violet")); letterDictionary.Add(c, textureList); textureList = null; } // Set the letter width letterWidth = letterDictionary['a'][0].Width; // Load lives texture appleTexture = Content.Load <Texture2D>("apple"); // Add three lives to list livesList.Add(appleTexture); // livesList.Add(appleTexture); // livesList.Add(appleTexture); // Load word list string lineOfText; using (var stream = TitleContainer.OpenStream("words.txt")) { using (var reader = new StreamReader(stream)) { while ((lineOfText = reader.ReadLine()) != null) { // Remove all periods from words if (lineOfText.Trim().Contains('.')) { lineOfText.Replace(".", ""); } // Check if duplicates exist in the list that's being loaded lineOfText = lineOfText.ToLower().Trim(); if (wordDictionary.ContainsKey(lineOfText)) { // Don't add again } else { wordDictionary.Add(lineOfText.ToLower().Trim(), false); } } } } currentWord = GetRandomLetterCombo(); stringToList(currentWord); // Play game music MediaPlayer.Play(gameMusic); }
public SoundBank(AudioEngine audioEngine, string filename) { if (audioEngine == null) { throw new ArgumentNullException("audioEngine"); } if (String.IsNullOrEmpty(filename)) { throw new ArgumentNullException("filename"); } INTERNAL_baseEngine = audioEngine; using (Stream soundBankStream = TitleContainer.OpenStream(filename)) using (BinaryReader reader = new BinaryReader(soundBankStream)) { // Check the file header. Should be 'SDBK' if (reader.ReadUInt32() != 0x4B424453) { throw new ArgumentException("SDBK format not recognized!"); } // Check the content version. Assuming XNA4 Refresh. if (reader.ReadUInt16() != AudioEngine.ContentVersion) { throw new ArgumentException("SDBK Content version!"); } // Check the tool version. Assuming XNA4 Refresh. if (reader.ReadUInt16() != 43) { throw new ArgumentException("SDBK Tool version!"); } // CRC, unused reader.ReadUInt16(); // Last modified, unused reader.ReadUInt64(); // Unknown value, Internet suggests platform reader.ReadByte(); // Cue Counts ushort numCueSimple = reader.ReadUInt16(); ushort numCueComplex = reader.ReadUInt16(); // Unknown value reader.ReadUInt16(); // Total Cues, unused reader.ReadUInt16(); // Number of associated WaveBanks byte numWaveBanks = reader.ReadByte(); // Unknown, Internet suggest number of "sounds" reader.ReadUInt16(); // Cue Name Table Length ushort cueNameTableLength = reader.ReadUInt16(); // Unknown value reader.ReadUInt16(); // Cue Offsets uint cueSimpleOffset = reader.ReadUInt32(); uint cueComplexOffset = reader.ReadUInt32(); // Cue Name Table Offset uint cueNameTableOffset = reader.ReadUInt32(); // Unknown value reader.ReadUInt32(); // Variable Tables Offset, unused reader.ReadUInt32(); // Unknown value reader.ReadUInt32(); // WaveBank Name Table Offset uint waveBankNameTableOffset = reader.ReadUInt32(); // Cue Name Hash Offsets, unused reader.ReadUInt32(); reader.ReadUInt32(); // Unknown value, Internet suggest "sounds" offset reader.ReadUInt32(); // SoundBank Name, unused reader.ReadBytes(64); // Parse WaveBank names soundBankStream.Seek(waveBankNameTableOffset, SeekOrigin.Begin); INTERNAL_waveBankNames = new List <string>(); for (byte i = 0; i < numWaveBanks; i += 1) { INTERNAL_waveBankNames.Add( System.Text.Encoding.UTF8.GetString( reader.ReadBytes(64), 0, 64 ).Replace("\0", "") ); } // Parse Cue name list soundBankStream.Seek(cueNameTableOffset, SeekOrigin.Begin); string[] cueNames = System.Text.Encoding.UTF8.GetString( reader.ReadBytes(cueNameTableLength), 0, cueNameTableLength ).Split('\0'); // Create our CueData Dictionary INTERNAL_cueData = new Dictionary <string, CueData>(); // Parse Simple Cues soundBankStream.Seek(cueSimpleOffset, SeekOrigin.Begin); for (ushort i = 0; i < numCueSimple; i += 1) { // Cue flags, unused reader.ReadByte(); // Cue Sound Offset uint offset = reader.ReadUInt32(); // Store this for when we're done reading the sound. long curPos = reader.BaseStream.Position; // Go to the sound in the Bank. reader.BaseStream.Seek(offset, SeekOrigin.Begin); // Parse the Sound INTERNAL_cueData.Add( cueNames[i], new CueData(new XACTSound(reader)) ); // Back to where we were... reader.BaseStream.Seek(curPos, SeekOrigin.Begin); } // Parse Complex Cues soundBankStream.Seek(cueComplexOffset, SeekOrigin.Begin); for (ushort i = 0; i < numCueComplex; i += 1) { // Cue flags byte cueFlags = reader.ReadByte(); if ((cueFlags & 0x04) != 0) // FIXME: ??? { // Cue Sound Offset uint offset = reader.ReadUInt32(); // Unknown value reader.ReadUInt32(); // Store this for when we're done reading the sound. long curPos = reader.BaseStream.Position; // Go to the sound in the bank reader.BaseStream.Seek(offset, SeekOrigin.Begin); // Parse the Sound INTERNAL_cueData.Add( cueNames[numCueSimple + i], new CueData(new XACTSound(reader)) ); // Back to where we were... reader.BaseStream.Seek(curPos, SeekOrigin.Begin); } else { // Variation Table Offset for this Cue uint offset = reader.ReadUInt32(); // Transition Table Offset for this Cue, unused reader.ReadUInt32(); // Store this for when we're done reading the Variation Table long curPos = reader.BaseStream.Position; // Seek to the Variation Table in the file reader.BaseStream.Seek(offset, SeekOrigin.Begin); // Number of Variations in the Table ushort numVariations = reader.ReadUInt16(); // Variation Table Flags ushort varTableFlags = reader.ReadUInt16(); // Unknown value reader.ReadUInt16(); // Probability Control Variable, if applicable ushort variable = reader.ReadUInt16(); // Create data for the CueData XACTSound[] cueSounds = new XACTSound[numVariations]; float[,] cueProbs = new float[numVariations, 2]; // Used to determine Variation storage format int varTableType = (varTableFlags >> 3) & 0x0007; for (ushort j = 0; j < numVariations; j += 1) { if (varTableType == 0) { // Wave with byte min/max ushort track = reader.ReadUInt16(); byte waveBank = reader.ReadByte(); byte wMin = reader.ReadByte(); byte wMax = reader.ReadByte(); // Create the Sound cueSounds[j] = new XACTSound(track, waveBank); // Calculate probability based on weight cueProbs[j, 0] = wMax / 255.0f; cueProbs[j, 1] = wMin / 255.0f; } else if (varTableType == 1) { // Complex with byte min/max uint varOffset = reader.ReadUInt32(); byte wMin = reader.ReadByte(); byte wMax = reader.ReadByte(); // Store for sound read long varPos = reader.BaseStream.Position; // Seek to the sound in the Bank reader.BaseStream.Seek(varOffset, SeekOrigin.Begin); // Read the sound cueSounds[j] = new XACTSound(reader); // Back to where we were... reader.BaseStream.Seek(varPos, SeekOrigin.Begin); // Calculate probability based on weight cueProbs[j, 0] = wMax / 255.0f; cueProbs[j, 1] = wMin / 255.0f; } else if (varTableType == 3) { // Complex with float min/max uint varOffset = reader.ReadUInt32(); float wMin = reader.ReadSingle(); float wMax = reader.ReadSingle(); // Unknown value reader.ReadUInt32(); // Store for sound read long varPos = reader.BaseStream.Position; // Seek to the sound in the Bank reader.BaseStream.Seek(varOffset, SeekOrigin.Begin); // Read the sound cueSounds[j] = new XACTSound(reader); // Back to where we were... reader.BaseStream.Seek(varPos, SeekOrigin.Begin); // Calculate probability based on weight cueProbs[j, 0] = wMax; cueProbs[j, 1] = wMin; } else if (varTableType == 4) { // Compact Wave ushort track = reader.ReadUInt16(); byte waveBank = reader.ReadByte(); // Create the Sound cueSounds[j] = new XACTSound(track, waveBank); // FIXME: Assume Sound weight is 100% cueProbs[j, 0] = 1.0f; cueProbs[j, 1] = 0.0f; } else { throw new NotSupportedException(); } } // Back to where we were... reader.BaseStream.Seek(curPos, SeekOrigin.Begin); // Add Built CueData to Dictionary INTERNAL_cueData.Add( cueNames[numCueSimple + i], new CueData( cueSounds, cueProbs, (varTableType == 3) ? INTERNAL_baseEngine.INTERNAL_getVariableName(variable) : String.Empty ) ); } // Cue instance limit byte instanceLimit = reader.ReadByte(); // Fade In/Out ushort fadeIn = reader.ReadUInt16(); ushort fadeOut = reader.ReadUInt16(); // Cue max instance behavior byte behavior = reader.ReadByte(); INTERNAL_cueData[cueNames[numCueSimple + i]].SetLimit( instanceLimit, behavior, fadeIn, fadeOut ); } } IsDisposed = false; }
//Defer loading because some programs load soundbanks before wavebanks private void Load() { #if !ANDROID using (Stream soundbankstream = TitleContainer.OpenStream(filename)) { #else using (var fileStream = Game.Activity.Assets.Open(filename)) { MemoryStream soundbankstream = new MemoryStream(); fileStream.CopyTo(soundbankstream); soundbankstream.Position = 0; #endif using (BinaryReader soundbankreader = new BinaryReader(soundbankstream)) { //Parse the SoundBank. //Thanks to Liandril for "xactxtract" for some of the offsets uint magic = soundbankreader.ReadUInt32(); if (magic != 0x4B424453) //"SDBK" { throw new Exception("Bad soundbank format"); } soundbankreader.ReadUInt16(); // toolVersion uint formatVersion = soundbankreader.ReadUInt16(); if (formatVersion != 46) { #if DEBUG System.Diagnostics.Debug.WriteLine("Warning: SoundBank format not supported"); #endif } soundbankreader.ReadUInt16(); // crc, TODO: Verify crc (FCS16) soundbankreader.ReadUInt32(); // lastModifiedLow soundbankreader.ReadUInt32(); // lastModifiedHigh soundbankreader.ReadByte(); // platform ??? uint numSimpleCues = soundbankreader.ReadUInt16(); uint numComplexCues = soundbankreader.ReadUInt16(); soundbankreader.ReadUInt16(); //unkn soundbankreader.ReadUInt16(); // numTotalCues uint numWaveBanks = soundbankreader.ReadByte(); soundbankreader.ReadUInt16(); // numSounds uint cueNameTableLen = soundbankreader.ReadUInt16(); soundbankreader.ReadUInt16(); //unkn uint simpleCuesOffset = soundbankreader.ReadUInt32(); uint complexCuesOffset = soundbankreader.ReadUInt32(); //unkn uint cueNamesOffset = soundbankreader.ReadUInt32(); soundbankreader.ReadUInt32(); //unkn soundbankreader.ReadUInt32(); // variationTablesOffset soundbankreader.ReadUInt32(); //unkn uint waveBankNameTableOffset = soundbankreader.ReadUInt32(); soundbankreader.ReadUInt32(); // cueNameHashTableOffset soundbankreader.ReadUInt32(); // cueNameHashValsOffset soundbankreader.ReadUInt32(); // soundsOffset //name = System.Text.Encoding.UTF8.GetString(soundbankreader.ReadBytes(64),0,64).Replace("\0",""); //parse wave bank name table soundbankstream.Seek(waveBankNameTableOffset, SeekOrigin.Begin); waveBanks = new WaveBank[numWaveBanks]; for (int i = 0; i < numWaveBanks; i++) { string bankname = System.Text.Encoding.UTF8.GetString(soundbankreader.ReadBytes(64), 0, 64).Replace("\0", ""); waveBanks[i] = audioengine.Wavebanks[bankname]; } //parse cue name table soundbankstream.Seek(cueNamesOffset, SeekOrigin.Begin); string[] cueNames = System.Text.Encoding.UTF8.GetString(soundbankreader.ReadBytes((int)cueNameTableLen), 0, (int)cueNameTableLen).Split('\0'); soundbankstream.Seek(simpleCuesOffset, SeekOrigin.Begin); for (int i = 0; i < numSimpleCues; i++) { soundbankreader.ReadByte(); // flags uint soundOffset = soundbankreader.ReadUInt32(); XactSound sound = new XactSound(this, soundbankreader, soundOffset); Cue cue = new Cue(audioengine, cueNames[i], sound); cues.Add(cue.Name, cue); } soundbankstream.Seek(complexCuesOffset, SeekOrigin.Begin); for (int i = 0; i < numComplexCues; i++) { Cue cue; byte flags = soundbankreader.ReadByte(); if (((flags >> 2) & 1) != 0) { //not sure :/ uint soundOffset = soundbankreader.ReadUInt32(); soundbankreader.ReadUInt32(); //unkn XactSound sound = new XactSound(this, soundbankreader, soundOffset); cue = new Cue(audioengine, cueNames[numSimpleCues + i], sound); } else { uint variationTableOffset = soundbankreader.ReadUInt32(); soundbankreader.ReadUInt32(); // transitionTableOffset //parse variation table long savepos = soundbankstream.Position; soundbankstream.Seek(variationTableOffset, SeekOrigin.Begin); uint numEntries = soundbankreader.ReadUInt16(); uint variationflags = soundbankreader.ReadUInt16(); soundbankreader.ReadByte(); soundbankreader.ReadUInt16(); soundbankreader.ReadByte(); XactSound[] cueSounds = new XactSound[numEntries]; float[] probs = new float[numEntries]; uint tableType = (variationflags >> 3) & 0x7; for (int j = 0; j < numEntries; j++) { switch (tableType) { case 0: //Wave { uint trackIndex = soundbankreader.ReadUInt16(); byte waveBankIndex = soundbankreader.ReadByte(); soundbankreader.ReadByte(); // weightMin soundbankreader.ReadByte(); // weightMax cueSounds[j] = new XactSound(this.GetWave(waveBankIndex, trackIndex)); break; } case 1: { uint soundOffset = soundbankreader.ReadUInt32(); soundbankreader.ReadByte(); // weightMin soundbankreader.ReadByte(); // weightMax cueSounds[j] = new XactSound(this, soundbankreader, soundOffset); break; } case 4: //CompactWave { uint trackIndex = soundbankreader.ReadUInt16(); byte waveBankIndex = soundbankreader.ReadByte(); cueSounds[j] = new XactSound(this.GetWave(waveBankIndex, trackIndex)); break; } default: throw new NotSupportedException(); } } soundbankstream.Seek(savepos, SeekOrigin.Begin); cue = new Cue(cueNames[numSimpleCues + i], cueSounds, probs); } //Instance Limit soundbankreader.ReadUInt32(); soundbankreader.ReadByte(); soundbankreader.ReadByte(); cues.Add(cue.Name, cue); } } } loaded = true; }
public Stage(ADHDGame g, string file) { game = g; mainTex = g.Content.Load <Texture2D>(texName); objTex = g.Content.Load <Texture2D>(objTexName); batch = new SpriteBatch(g.GraphicsDevice); //get xml data in a document XmlDocument xml = new XmlDocument(); string xmlString = ""; using (StreamReader fr = new StreamReader(TitleContainer.OpenStream("Content\\" + file))) { xmlString = fr.ReadToEnd(); } xml.LoadXml(xmlString); //read the width and height Width = Convert.ToInt32(xml.SelectSingleNode("map/layer/@width").Value); Height = Convert.ToInt32(xml.SelectSingleNode("map/layer/@height").Value); InitObjects(); MainLayer = new int[Width, Height]; TopLayer = new int[Width, Height]; //get main layer int x = 0, y = 0; XmlNodeList list = xml.SelectNodes("map/layer[@name='" + mainLayerName + "']/data/tile/@gid"); foreach (XmlNode node in list) { //minus 1 because Tiled uses 0 as blank, we won't! MainLayer[x, y] = Convert.ToInt32(node.Value) - 1; //hack special objects if (MainLayer[x, y] == TileToID(0, 12)) { AddConveyor(new Point(x, y), Robot.Direction.Right); } else if (MainLayer[x, y] == TileToID(0, 13)) { AddConveyor(new Point(x, y), Robot.Direction.Left); } else if (MainLayer[x, y] == TileToID(0, 14)) { AddConveyor(new Point(x, y), Robot.Direction.Up); } else if (MainLayer[x, y] == TileToID(0, 15)) { AddConveyor(new Point(x, y), Robot.Direction.Down); } ++x; //test for next row if (x >= Width) { ++y; x = 0; } } //get main layer x = 0; y = 0; list = xml.SelectNodes("map/layer[@name='" + topLayerName + "']/data/tile/@gid"); foreach (XmlNode node in list) { //minus 1 because Tiled uses 0 as blank, we won't! TopLayer[x, y] = Convert.ToInt32(node.Value) - 1; ++x; //test for next row if (x >= Width) { ++y; x = 0; } } InitPassables(); }
public static Stream OpenStream(this ContentManager contentManager, string path) { return(TitleContainer.OpenStream(contentManager.RootDirectory + DirectorySeparatorChar + path)); }
public static Stream GetFileStream(string fileName) { fileName = Path.Combine(CCContentManager.SharedContentManager.RootDirectory, fileName); return(TitleContainer.OpenStream(fileName)); }