Example #1
0
 public static void LoadStaticContent(string contentManagerName)
 {
     if (string.IsNullOrEmpty(contentManagerName))
     {
         throw new System.ArgumentException("contentManagerName cannot be empty or null");
     }
     #if DEBUG
     if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
     {
         HasBeenLoadedWithGlobalContentManager = true;
     }
     else if (HasBeenLoadedWithGlobalContentManager)
     {
         throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
     }
     #endif
     pongsound = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/screens/gamescreen/pongsound", contentManagerName);
     PongNewTry.Entities.PongBall.LoadStaticContent(contentManagerName);
     PongNewTry.Entities.Border1.LoadStaticContent(contentManagerName);
     PongNewTry.Entities.Border2.LoadStaticContent(contentManagerName);
     PongNewTry.Entities.Border3.LoadStaticContent(contentManagerName);
     PongNewTry.Entities.Player1.LoadStaticContent(contentManagerName);
     PongNewTry.Entities.Player2.LoadStaticContent(contentManagerName);
     PongNewTry.Entities.HUD.LoadStaticContent(contentManagerName);
     PongNewTry.Entities.HUD2.LoadStaticContent(contentManagerName);
     CustomLoadStaticContent(contentManagerName);
 }
Example #2
0
        /// <summary>
        /// Create the Sound Effect component.
        /// </summary>
        /// <param name="sound">Sound effect to play.</param>
        public SoundEffect(Microsoft.Xna.Framework.Audio.SoundEffect sound)
        {
            // create the sound player
            _soundPlayer = new Core.Sound.SoundPlayer(sound);

            // by default sound effects are not looping
            IsLooped = false;
        }
        public static new void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            ContentManagerName = contentManagerName;
            AbbatoirIntergrade.Entities.BaseEntities.BaseStructure.LoadStaticContent(contentManagerName);
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = contentManagerName;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            bool registerUnload = false;
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("PiercingTowerStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
                PiercingShot1 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/structures/piercingtower/piercingshot1", ContentManagerName);
                PiercingShot2 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/structures/piercingtower/piercingshot2", ContentManagerName);
                PiercingShot3 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/structures/piercingtower/piercingshot3", ContentManagerName);
            }
            if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("PiercingTowerStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
            }
            CustomLoadStaticContent(contentManagerName);
        }
        public override void Destroy()
        {
            base.Destroy();
            pongsound = null;

            if (PongBallInstance != null)
            {
                PongBallInstance.Destroy();
                PongBallInstance.Detach();
            }
            if (BorderInstance != null)
            {
                BorderInstance.Destroy();
                BorderInstance.Detach();
            }
            if (Border1Instance != null)
            {
                Border1Instance.Destroy();
                Border1Instance.Detach();
            }
            if (Border2Instance != null)
            {
                Border2Instance.Destroy();
                Border2Instance.Detach();
            }
            if (Border3Instance != null)
            {
                Border3Instance.Destroy();
                Border3Instance.Detach();
            }
            if (Player1Instance != null)
            {
                Player1Instance.Destroy();
                Player1Instance.Detach();
            }
            if (Player2Instance != null)
            {
                Player2Instance.Destroy();
                Player2Instance.Detach();
            }
            if (HUDInstance != null)
            {
                HUDInstance.Destroy();
                HUDInstance.Detach();
            }
            if (HUD2Instance != null)
            {
                HUD2Instance.Destroy();
                HUD2Instance.Detach();
            }
            FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Clear();
            CustomDestroy();
        }
        public static new void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            // Set to use global content
            contentManagerName = FlatRedBall.FlatRedBallServices.GlobalContentManager;
            ContentManagerName = FlatRedBall.FlatRedBallServices.GlobalContentManager;
            AbbatoirIntergrade.Entities.BaseEntities.BasePlayerProjectile.LoadStaticContent(contentManagerName);
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = FlatRedBall.FlatRedBallServices.GlobalContentManager;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("FrostProjectileStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
                FrostProjectileAnimationChainListFile = FlatRedBall.FlatRedBallServices.Load <FlatRedBall.Graphics.Animation.AnimationChainList>(@"content/entities/projectiles/frostprojectile/frostprojectileanimationchainlistfile.achx", ContentManagerName);
                FrostImpact1       = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/projectiles/frostprojectile/frostimpact1", ContentManagerName);
                FrostImpact2       = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/projectiles/frostprojectile/frostimpact2", ContentManagerName);
                FrostImpact3       = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/projectiles/frostprojectile/frostimpact3", ContentManagerName);
                FrostGroundImpact1 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/projectiles/frostprojectile/frostgroundimpact1", ContentManagerName);
                FrostGroundImpact2 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/projectiles/frostprojectile/frostgroundimpact2", ContentManagerName);
            }
            CustomLoadStaticContent(contentManagerName);
        }
        public static new void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            // Set to use global content
            contentManagerName = FlatRedBall.FlatRedBallServices.GlobalContentManager;
            ContentManagerName = FlatRedBall.FlatRedBallServices.GlobalContentManager;
            AbbatoirIntergrade.Entities.BaseEntities.BaseEnemy.LoadStaticContent(contentManagerName);
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = FlatRedBall.FlatRedBallServices.GlobalContentManager;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("Rabbit1EnemyStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
                Rabbit1Animations = FlatRedBall.FlatRedBallServices.Load <FlatRedBall.Graphics.Animation.AnimationChainList>(@"content/screens/gamescreen/monsters/rabbit1animations.achx", ContentManagerName);
                Stage1            = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/screens/gamescreen/monsters/stage1.png", ContentManagerName);
                Rabbit1Death1     = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/enemies/rabbit1enemy/rabbit1death1", ContentManagerName);
                Rabbit1Death2     = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/enemies/rabbit1enemy/rabbit1death2", ContentManagerName);
                Rabbit1Death3     = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/enemies/rabbit1enemy/rabbit1death3", ContentManagerName);
            }
            CustomLoadStaticContent(contentManagerName);
        }
Example #7
0
        public CameraPreview()
        {
            System.IO.Stream stream = System.Windows.Application.GetResourceStream(new Uri(SHUTTERSOUND_FILEPATH, UriKind.Relative)).Stream;
            _shutterSound = Microsoft.Xna.Framework.Audio.SoundEffect.FromStream(stream);

            int minWorker, minIOC;

            ThreadPool.GetMinThreads(out minWorker, out minIOC);
            if (ThreadPool.SetMinThreads(5, minIOC))
            {
                Debug.WriteLine("Set min thread count to {0}", MIN_THREAD_POOL_THREADS);
            }
            else
            {
                Debug.WriteLine("Could not change min thread count. Using {0} threads.", minWorker);
            }
        }
 public static new void UnloadStaticContent()
 {
     if (LoadedContentManagers.Count != 0)
     {
         LoadedContentManagers.RemoveAt(0);
         mRegisteredUnloads.RemoveAt(0);
     }
     if (LoadedContentManagers.Count == 0)
     {
         if (CannonShot1 != null)
         {
             CannonShot1 = null;
         }
         if (CannonShot2 != null)
         {
             CannonShot2 = null;
         }
     }
 }
        public static void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = contentManagerName;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            worldmap = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/screens/mapscreen/worldmap.png", contentManagerName);
            Gum.Wireframe.GraphicalUiElement.IsAllLayoutSuspended = true;  MapScreenGum = new FlatRedBall.Gum.GumIdb();  MapScreenGum.LoadFromFile("content/gumproject/screens/mapscreengum.gusx");  MapScreenGum.AssignReferences(); Gum.Wireframe.GraphicalUiElement.IsAllLayoutSuspended = false; MapScreenGum.Element.UpdateLayout(); MapScreenGum.Element.UpdateLayout();
            if (Messages == null)
            {
                {
                    // We put the { and } to limit the scope of oldDelimiter
                    char oldDelimiter = FlatRedBall.IO.Csv.CsvFileManager.Delimiter;
                    FlatRedBall.IO.Csv.CsvFileManager.Delimiter = ',';
                    System.Collections.Generic.Dictionary <string, AbbatoirIntergrade.DataTypes.Messages> temporaryCsvObject = new System.Collections.Generic.Dictionary <string, AbbatoirIntergrade.DataTypes.Messages>();
                    FlatRedBall.IO.Csv.CsvFileManager.CsvDeserializeDictionary <string, AbbatoirIntergrade.DataTypes.Messages>("content/screens/mapscreen/messages.csv", temporaryCsvObject);
                    FlatRedBall.IO.Csv.CsvFileManager.Delimiter = oldDelimiter;
                    Messages = temporaryCsvObject;
                }
            }
            StructureSelection = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/screens/mapscreen/structureselection", contentManagerName);
            CustomLoadStaticContent(contentManagerName);
        }
Example #10
0
 public static void UnloadStaticContent()
 {
     if (LoadedContentManagers.Count != 0)
     {
         LoadedContentManagers.RemoveAt(0);
         mRegisteredUnloads.RemoveAt(0);
     }
     if (LoadedContentManagers.Count == 0)
     {
         if (BoatSprite != null)
         {
             BoatSprite = null;
         }
         if (AnchorSprite != null)
         {
             AnchorSprite = null;
         }
         if (fire != null)
         {
             fire = null;
         }
     }
 }
Example #11
0
        /// <summary>
        /// Loads the resources from any other XNA game like if they were form this one and extracts them.
        /// Tested with the XNA resources from the games "Terraria" and "Stardew Valley" with success.
        /// With applications like "ILSpy" you can see the source code from XNA games since they are .NET.
        /// The idea of this application is to find secrets hidden in the game textures and resources,
        /// but it should never be used to do anything illegal, so be sure you have the proper
        /// permissions before you start using it on random games. Jupisoft will never be responsible.
        /// </summary>
        protected override void LoadContent()
        {
            try
            {
                try { if (!Directory.Exists(Program.Ruta_XNA))
                      {
                          Directory.CreateDirectory(Program.Ruta_XNA);
                      }
                }
                catch (Exception Excepción) { Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null); }

                List <string> Lista_Rutas     = new List <string>();
                List <string> Lista_Rutas_XSB = new List <string>();
                string[]      Matriz_Rutas    = Directory.GetFiles(Program.Ruta_XNA, "*.xnb", SearchOption.AllDirectories);
                if (Matriz_Rutas != null && Matriz_Rutas.Length > 0)
                {
                    Lista_Rutas.AddRange(Matriz_Rutas);
                    Matriz_Rutas = null;
                }
                Matriz_Rutas = Directory.GetFiles(Program.Ruta_XNA, "*.xwb", SearchOption.AllDirectories);
                if (Matriz_Rutas != null && Matriz_Rutas.Length > 0)
                {
                    Lista_Rutas.AddRange(Matriz_Rutas);
                    Matriz_Rutas = null;
                }
                Matriz_Rutas = Directory.GetFiles(Program.Ruta_XNA, "*.xgs", SearchOption.AllDirectories);
                if (Matriz_Rutas != null && Matriz_Rutas.Length > 0)
                {
                    Lista_Rutas.AddRange(Matriz_Rutas);
                    Matriz_Rutas = null;
                }
                Matriz_Rutas = Directory.GetFiles(Program.Ruta_XNA, "*.xsb", SearchOption.AllDirectories);
                if (Matriz_Rutas != null && Matriz_Rutas.Length > 0)
                {
                    //Lista_Rutas.AddRange(Matriz_Rutas);
                    Lista_Rutas_XSB.AddRange(Matriz_Rutas);
                    if (Lista_Rutas_XSB.Count > 1)
                    {
                        Lista_Rutas.Sort();
                    }
                    Matriz_Rutas = null;
                }
                if (Lista_Rutas.Count > 1)
                {
                    Lista_Rutas.Sort();
                }
                Matriz_Rutas = Lista_Rutas.ToArray();
                Lista_Rutas  = null;

                if (Matriz_Rutas != null && Matriz_Rutas.Length > 0) // There are files to extract.
                {
                    foreach (string Ruta in Matriz_Rutas)
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(Ruta) && File.Exists(Ruta))
                            {
                                string Ruta_Relativa = '.' + Ruta.Substring(Program.Ruta_Aplicación.Length).Substring(0, (Ruta.Length - Program.Ruta_Aplicación.Length) - 4);
                                string Ruta_Salida   = Ruta.Substring(0, Ruta.Length - 4);

                                try // Try to read as a 2D texture and export as a PNG image.
                                {
                                    Microsoft.Xna.Framework.Graphics.Texture2D Textura = base.Content.Load <Texture2D>(Ruta_Relativa);
                                    if (Textura != null)
                                    {
                                        MemoryStream Lector_Memoria = new MemoryStream();
                                        int          Ancho          = 16; // Default on error.
                                        int          Alto           = 16;
                                        try { Ancho = Textura.Width; }
                                        catch { Ancho = 16; }
                                        try { Alto = Textura.Height; }
                                        catch { Alto = 16; }
                                        Textura.SaveAsPng(Lector_Memoria, Ancho, Textura.Height);
                                        byte[] Matriz_Bytes = Lector_Memoria.ToArray();
                                        Lector_Memoria.Close();
                                        Lector_Memoria.Dispose();
                                        Lector_Memoria = null;
                                        Lector_Memoria = new MemoryStream(Matriz_Bytes);
                                        Image Imagen_Original = null;
                                        try { Imagen_Original = Image.FromStream(Lector_Memoria, false, false); }
                                        catch { Imagen_Original = null; }
                                        Lector_Memoria.Close();
                                        Lector_Memoria.Dispose();
                                        Lector_Memoria = null;
                                        Matriz_Bytes   = null;
                                        if (Imagen_Original != null) // Reconvert the image to 24 or 32 bits with alpha.
                                        {
                                            //Ancho = Imagen_Original.Width; // Could the width or height change?
                                            //Alto = Imagen_Original.Height;
                                            Bitmap   Imagen = new Bitmap(Ancho, Alto, !Image.IsAlphaPixelFormat(Imagen_Original.PixelFormat) ? PixelFormat.Format24bppRgb : PixelFormat.Format32bppArgb);
                                            Graphics Pintar = Graphics.FromImage(Imagen);
                                            Pintar.CompositingMode    = CompositingMode.SourceCopy;
                                            Pintar.CompositingQuality = CompositingQuality.HighQuality;
                                            Pintar.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                                            Pintar.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                                            Pintar.SmoothingMode      = SmoothingMode.None;
                                            Pintar.TextRenderingHint  = TextRenderingHint.AntiAlias;
                                            Pintar.DrawImage(Imagen_Original, new System.Drawing.Rectangle(0, 0, Ancho, Alto), new System.Drawing.Rectangle(0, 0, Ancho, Alto), GraphicsUnit.Pixel);
                                            Pintar.Dispose();
                                            Pintar = null;
                                            while (File.Exists(Ruta_Salida + ".png"))
                                            {
                                                Ruta_Salida += '_';
                                            }
                                            Imagen.Save(Ruta_Salida + ".png", ImageFormat.Png);
                                            Ruta_Salida = null;
                                            Imagen.Dispose();
                                            Imagen = null;
                                            Imagen_Original.Dispose();
                                            Imagen_Original = null;
                                            Ruta_Relativa   = null;
                                            Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                            continue;                               // Go to the next XNB resource file.
                                        }
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                try // Try to read as a string and string dictionary and export as Unicode text.
                                {
                                    Dictionary <string, string> Diccionario = base.Content.Load <Dictionary <string, string> >(Ruta_Relativa);
                                    if (Diccionario != null && Diccionario.Count > 0)
                                    {
                                        while (File.Exists(Ruta_Salida + ".txt"))
                                        {
                                            Ruta_Salida += '_';
                                        }
                                        FileStream Lector = new FileStream(Ruta_Salida + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
                                        Lector.SetLength(0L);
                                        Lector.Seek(0L, SeekOrigin.Begin);
                                        StreamWriter Lector_Texto = new StreamWriter(Lector, Encoding.Unicode);
                                        foreach (KeyValuePair <string, string> Entrada in Diccionario)
                                        {
                                            try
                                            {
                                                Lector_Texto.WriteLine(Entrada.Key);
                                                Lector_Texto.WriteLine(Entrada.Value);
                                                Lector_Texto.WriteLine();
                                                Lector_Texto.Flush();
                                            }
                                            catch (Exception Excepción)
                                            {
                                                Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                                continue;
                                            }
                                        }
                                        Lector_Texto.Close();
                                        Lector_Texto.Dispose();
                                        Lector_Texto = null;
                                        Lector.Close();
                                        Lector.Dispose();
                                        Lector      = null;
                                        Diccionario = null;
                                        Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                        continue;                               // Go to the next XNB resource file.
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                try // Try to read as an int and text dictionary and export as Unicode text.
                                {
                                    Dictionary <int, string> Diccionario = base.Content.Load <Dictionary <int, string> >(Ruta_Relativa);
                                    if (Diccionario != null && Diccionario.Count > 0)
                                    {
                                        while (File.Exists(Ruta_Salida + ".txt"))
                                        {
                                            Ruta_Salida += '_';
                                        }
                                        FileStream Lector = new FileStream(Ruta_Salida + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
                                        Lector.SetLength(0L);
                                        Lector.Seek(0L, SeekOrigin.Begin);
                                        StreamWriter Lector_Texto = new StreamWriter(Lector, Encoding.Unicode);
                                        foreach (KeyValuePair <int, string> Entrada in Diccionario)
                                        {
                                            try
                                            {
                                                Lector_Texto.WriteLine(Entrada.Key.ToString());
                                                Lector_Texto.WriteLine(Entrada.Value);
                                                Lector_Texto.WriteLine();
                                                Lector_Texto.Flush();
                                            }
                                            catch (Exception Excepción)
                                            {
                                                Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                                continue;
                                            }
                                        }
                                        Lector_Texto.Close();
                                        Lector_Texto.Dispose();
                                        Lector_Texto = null;
                                        Lector.Close();
                                        Lector.Dispose();
                                        Lector      = null;
                                        Diccionario = null;
                                        Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                        continue;                               // Go to the next XNB resource file.
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                try // Try to read as an int and int array dictionary and export as Unicode text.
                                {
                                    Dictionary <int, int[]> Diccionario = base.Content.Load <Dictionary <int, int[]> >(Ruta_Relativa);
                                    if (Diccionario != null && Diccionario.Count > 0)
                                    {
                                        while (File.Exists(Ruta_Salida + ".txt"))
                                        {
                                            Ruta_Salida += '_';
                                        }
                                        FileStream Lector = new FileStream(Ruta_Salida + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
                                        Lector.SetLength(0L);
                                        Lector.Seek(0L, SeekOrigin.Begin);
                                        StreamWriter Lector_Texto = new StreamWriter(Lector, Encoding.Unicode); // .Default?
                                        foreach (KeyValuePair <int, int[]> Entrada in Diccionario)
                                        {
                                            try
                                            {
                                                Lector_Texto.WriteLine(Entrada.Key.ToString());
                                                if (Entrada.Value != null && Entrada.Value.Length > 0)
                                                {
                                                    for (int Índice = 0; Índice < Entrada.Value.Length; Índice++)
                                                    {
                                                        try
                                                        {
                                                            Lector_Texto.Write(Entrada.Value[Índice].ToString() + (Índice + 1 < Entrada.Value.Length ? ", " : null));
                                                        }
                                                        catch (Exception Excepción)
                                                        {
                                                            Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                                            continue;
                                                        }
                                                    }
                                                    Lector_Texto.WriteLine();
                                                }
                                                else
                                                {
                                                    Lector_Texto.WriteLine();
                                                }
                                                Lector_Texto.WriteLine();
                                                Lector_Texto.Flush();
                                            }
                                            catch (Exception Excepción)
                                            {
                                                Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                                continue;
                                            }
                                        }
                                        Lector_Texto.Close();
                                        Lector_Texto.Dispose();
                                        Lector_Texto = null;
                                        Lector.Close();
                                        Lector.Dispose();
                                        Lector      = null;
                                        Diccionario = null;
                                        Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                        continue;                               // Go to the next XNB resource file.
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                try // Try to read as a sprite font and export as a PNG image.
                                {
                                    Microsoft.Xna.Framework.Graphics.SpriteFont Fuente = base.Content.Load <SpriteFont>(Ruta_Relativa);
                                    if (Fuente != null)
                                    {
                                        Fuente = null;
                                        while (File.Exists(Ruta_Salida + ".png"))
                                        {
                                            Ruta_Salida += '_';
                                        }
                                        if (XNA_Extractor.Extract.XnbExtractor.Extract(Ruta, Ruta_Salida + ".png", false, false, false, true))
                                        {
                                            Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                            continue;                               // Go to the next XNB resource file.
                                        }
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                try // Try to read as a sound effect and export as WAV audio file.
                                {
                                    Microsoft.Xna.Framework.Audio.SoundEffect Efecto_Sonido = base.Content.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(Ruta_Relativa);
                                    if (Efecto_Sonido != null)
                                    {
                                        Efecto_Sonido.Dispose();
                                        Efecto_Sonido = null;
                                        while (File.Exists(Ruta_Salida + ".wav"))
                                        {
                                            Ruta_Salida += '_';
                                        }
                                        if (XNA_Extractor.Extract.XnbExtractor.Extract(Ruta, Ruta_Salida + ".wav", false, false, true, false))
                                        {
                                            //Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                            continue; // Go to the next XNB resource file.
                                        }
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                /*try // Try to read as an effect and export as ?.
                                 * {
                                 *  Microsoft.Xna.Framework.Graphics.Effect Efecto = base.Content.Load<Effect>(Ruta_Relativa);
                                 *  if (Efecto != null)
                                 *  {
                                 *      Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                 *      continue; // Go to the next XNB resource file.
                                 *  }
                                 * }
                                 * catch (Exception Excepción)
                                 * {
                                 *  //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                 * }*/

                                try // Try to read as a multiple type and export as a PNG image.
                                {
                                    while (File.Exists(Ruta_Salida + ".png"))
                                    {
                                        Ruta_Salida += '_';
                                    }
                                    if (XNA_Extractor.Extract.XnbExtractor.Extract(Ruta, Ruta_Salida + ".png", false, true, true, true))
                                    {
                                        Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                        continue;                               // Go to the next XNB resource file.
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                try // Try to read as a bank wave file and export as multiple WAV sound files.
                                {
                                    //while (File.Exists(Ruta_Salida + ".wav")) Ruta_Salida += '_';
                                    //MessageBox.Show(Path.GetDirectoryName(Ruta_Salida), Ruta_Salida);
                                    if (/*string.Compare(Path.GetExtension(Ruta), ".xwb", true) == 0 && */ XNA_Extractor.Extract.XactExtractor.Extract(Ruta, Path.GetDirectoryName(Ruta)))
                                    {
                                        Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                        continue;                               // Go to the next XNB resource file.
                                    }
                                }
                                catch (Exception Excepción)
                                {
                                    //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                }

                                // TODO: Add support for more resource types...
                            }
                        }
                        catch (Exception Excepción)
                        {
                            //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                            continue;
                        }
                    }
                    Matriz_Rutas = null;
                }
                // This works perfectly, but the class from "XactExtractor.cs" seems to export too many files?
                if (Lista_Rutas_XSB != null && Lista_Rutas_XSB.Count > 0) // Post-process the track names if present.
                {
                    List <char> Lista_Caracteres_Inválidos = new List <char>(Path.GetInvalidFileNameChars());
                    foreach (string Ruta in Lista_Rutas_XSB)
                    {
                        try
                        {
                            FileStream Lector_Entrada = new FileStream(Ruta, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
                            if (Lector_Entrada.Length > 0L)                            // Not empty.
                            {
                                byte[] Matriz_Bytes = new byte[Lector_Entrada.Length]; // Read the whole file at once.
                                int    Longitud     = Lector_Entrada.Read(Matriz_Bytes, 0, Matriz_Bytes.Length);
                                Lector_Entrada.Close();
                                Lector_Entrada.Dispose();
                                Lector_Entrada = null;
                                if (Longitud < Matriz_Bytes.Length)
                                {
                                    Array.Resize(ref Matriz_Bytes, Longitud);
                                }
                                string Ruta_Actual  = Path.GetDirectoryName(Ruta);
                                int    Total_Pistas = 0;
                                for (int Índice = 1; Índice < int.MaxValue; Índice++)
                                {
                                    if (File.Exists(Ruta_Actual + "\\" + Índice.ToString() + " Unknown.wav"))
                                    {
                                        Total_Pistas++;
                                    }
                                    else
                                    {
                                        break;  // Stop when a track in order is missing.
                                    }
                                }
                                List <string> Lista_Nombres   = new List <string>();
                                int           Índice_Anterior = Matriz_Bytes.Length - 1; // This byte should be zero (string ender).
                                for (int Índice = Matriz_Bytes.Length - 2; Índice >= 0; Índice--)
                                {
                                    if (Matriz_Bytes[Índice] == 0)
                                    {
                                        if (Índice + 1 != Índice_Anterior) // Avoid multiple nulls.
                                        {
                                            string Nombre = null;
                                            for (int Índice_Caracter = Índice + 1; Índice_Caracter < Índice_Anterior; Índice_Caracter++)
                                            {
                                                char Caracter = (char)Matriz_Bytes[Índice_Caracter];
                                                if (!char.IsControl(Caracter) && Caracter != 'ÿ' && !Lista_Caracteres_Inválidos.Contains(Caracter))
                                                {
                                                    Nombre += Caracter;
                                                }
                                            }
                                            if (string.IsNullOrEmpty(Nombre))
                                            {
                                                Nombre = "Unknown";
                                            }
                                            Lista_Nombres.Add(Nombre);
                                            //if (Lista_Nombres.Count >= Total_Pistas) break;
                                        }
                                        Índice_Anterior = Índice;
                                    }
                                }
                                if (Lista_Nombres != null && Lista_Nombres.Count > 0)
                                {
                                    for (int Índice_Pista = Total_Pistas, Índice_Nombre = 0; Índice_Pista >= 1; Índice_Pista--, Índice_Nombre++)
                                    {
                                        try
                                        {
                                            File.Move(Ruta_Actual + "\\" + Índice_Pista.ToString() + " Unknown.wav", Ruta_Actual + "\\" + Índice_Pista.ToString() + " " + Lista_Nombres[Índice_Nombre] + ".wav");
                                        }
                                        catch (Exception Excepción)
                                        {
                                            //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                            continue;
                                        }
                                    }
                                    Lista_Nombres.Reverse();
                                    string Ruta_Salida = Ruta.Substring(0, Ruta.Length - 4);
                                    while (File.Exists(Ruta_Salida + ".txt"))
                                    {
                                        Ruta_Salida += '_';
                                    }
                                    FileStream Lector = new FileStream(Ruta_Salida + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
                                    Lector.SetLength(0L);
                                    Lector.Seek(0L, SeekOrigin.Begin);
                                    StreamWriter Lector_Texto = new StreamWriter(Lector, Encoding.Unicode);
                                    foreach (string Nombre in Lista_Nombres)
                                    {
                                        try
                                        {
                                            Lector_Texto.WriteLine(Nombre);
                                            Lector_Texto.Flush();
                                        }
                                        catch (Exception Excepción)
                                        {
                                            //Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                                            continue;
                                        }
                                    }
                                    Lector_Texto.Close();
                                    Lector_Texto.Dispose();
                                    Lector_Texto = null;
                                    Lector.Close();
                                    Lector.Dispose();
                                    Lector        = null;
                                    Lista_Nombres = null;
                                    Program.Eliminar_Archivo_Carpeta(Ruta); // Delete the copied XNB resource.
                                    continue;                               // Go to the next XNB resource file.
                                }
                            }
                        }
                        catch (Exception Excepción)
                        {
                            Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null);
                            continue;
                        }
                    }
                    Lista_Caracteres_Inválidos = null;
                }
                Depurador.Detener_Depurador();
                this.Exit();
            }
            catch (Exception Excepción) { Depurador.Escribir_Excepción(Excepción != null ? Excepción.ToString() : null); }
        }
Example #12
0
        public static void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            ContentManagerName = contentManagerName;
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = contentManagerName;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            bool registerUnload = false;
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("BoatStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
                if (!FlatRedBall.FlatRedBallServices.IsLoaded <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/sprites/boatsprite.png", ContentManagerName))
                {
                    registerUnload = true;
                }
                BoatSprite = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/sprites/boatsprite.png", ContentManagerName);
                if (!FlatRedBall.FlatRedBallServices.IsLoaded <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/boat/anchorsprite.png", ContentManagerName))
                {
                    registerUnload = true;
                }
                AnchorSprite = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/boat/anchorsprite.png", ContentManagerName);
                fire         = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/boat/fire", ContentManagerName);
            }
            if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("BoatStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
            }
            CustomLoadStaticContent(contentManagerName);
        }
        public override void Destroy()
        {
            base.Destroy();
            Factories.BombardingTowerFactory.Destroy();
            Factories.ChemicalTowerFactory.Destroy();
            Factories.ElectricTowerFactory.Destroy();
            Factories.FireTowerFactory.Destroy();
            Factories.FrostTowerFactory.Destroy();
            Factories.PiercingTowerFactory.Destroy();
            Factories.CannonProjectileFactory.Destroy();
            Factories.ChemicalProjectileFactory.Destroy();
            Factories.ElectricProjectileFactory.Destroy();
            Factories.FireProjectileFactory.Destroy();
            Factories.FrostProjectileFactory.Destroy();
            Factories.PiercingProjectileFactory.Destroy();
            worldmap = null;
            FlatRedBall.SpriteManager.RemoveDrawableBatch(MapScreenGum); FlatRedBall.FlatRedBallServices.GraphicsOptions.SizeOrOrientationChanged -= MapScreenGum.HandleResolutionChanged;
            MapScreenGum       = null;
            Messages           = null;
            StructureSelection = null;

            StructureList.MakeOneWay();
            ProjectileList.MakeOneWay();
            if (MapScreenGumInstance != null)
            {
                MapScreenGumInstance.RemoveFromManagers();
            }
            if (MenuWindowInstance != null)
            {
                MenuWindowInstance.RemoveFromManagers();
            }
            if (ChatHistoryInstance != null)
            {
                ChatHistoryInstance.RemoveFromManagers();
            }
            if (TowerSelectionBoxInstance != null)
            {
                TowerSelectionBoxInstance.RemoveFromManagers();
            }
            for (int i = StructureList.Count - 1; i > -1; i--)
            {
                StructureList[i].Destroy();
            }
            if (StructureLayer != null)
            {
                FlatRedBall.SpriteManager.RemoveLayer(StructureLayer);
            }
            for (int i = ProjectileList.Count - 1; i > -1; i--)
            {
                ProjectileList[i].Destroy();
            }
            if (OkMessageInstance != null)
            {
                OkMessageInstance.RemoveFromManagers();
            }
            if (ConfirmationWindowInstance != null)
            {
                ConfirmationWindowInstance.RemoveFromManagers();
            }
            if (HUDLayer != null)
            {
                FlatRedBall.SpriteManager.RemoveLayer(HUDLayer);
            }
            if (CurrentMusicDisplayInstance != null)
            {
                CurrentMusicDisplayInstance.RemoveFromManagers();
            }
            StructureList.MakeTwoWay();
            ProjectileList.MakeTwoWay();
            FlatRedBall.Math.Collision.CollisionManager.Self.Relationships.Clear();
            CustomDestroy();
        }
 public MonoGameSoundEffect(Microsoft.Xna.Framework.Audio.SoundEffect soundEffect, int id)
     : base(id, soundEffect.Name)
 {
 }
Example #15
0
 public GameSoundEffect(XNASoundEffect xnaSoundEffect)
 {
     _xnaSoundEffect = xnaSoundEffect;
 }
Example #16
0
 public override void LoadContent(ContentManager Content, Texture2D image, string text, Microsoft.Xna.Framework.Audio.SoundEffect sound, Vector2 position)
 {
     base.LoadContent(Content, image, text, sound, position);
     frameCounter = 0;
     switchFrame  = 100;
     frames       = new Vector2(1, 1);
     currentFrame = new Vector2(0, 0);
     //sourceRect = new Rectangle((int)currentFrame.X, (int)currentFrame.Y, FrameHeight, FrameWidth);
     sourceRect = new Rectangle((int)currentFrame.X * FrameWidth,
                                (int)currentFrame.Y * FrameHeight, FrameWidth, FrameHeight);
 }
Example #17
0
 /// <summary>
 /// Lataa ääniefektin Jypelin sisäisistä resursseista.
 /// </summary>
 /// <param name="name">Äänen nimi päätteineen</param>
 /// <returns>SoundEffect-olio</returns>
 public static SoundEffect LoadSoundEffectFromResources(string name)
 {
     name = internalResourcePath + "Sounds." + name;
     return(new SoundEffect(XnaSoundEffect.FromStream(ResourceContent.StreamInternalResource(name))));
 }