Esempio n. 1
0
 /// <summary>
 /// Ripone tutte le risorse dalla scena corrente
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     this.layers.ElementAt <Bitmap>(0).Dispose();
     this.layers.Clear();
     this.loopingAudio.Stop();
     this.loopingAudio.Dispose();
     this.loopingAudio = null;
     GC.Collect();
 }
Esempio n. 2
0
 private void unload()
 {
     if (sound != null)
     {
         sound.Stop();
         sound.Dispose();
     }
     sound = null;
     GC.Collect();
 }
Esempio n. 3
0
        private void ConstructorsMutualPart(SceneContainer sc)
        {
            Container = sc;
            ResourceDirectory root    = sc.getResourceDirectory;
            string            itsPath = GameApp.CurDir() + GameConstraints.LoadingScreen.Path;
            string            itsName = GameConstraints.LoadingScreen.LogicDir;

            root.NewDirectory(itsName);
            loadMediaFiles(itsName, itsPath + @"\");

            remainingLoadingLevels = 10;
            timer    = new Stopwatch();
            layers   = new List <Bitmap>();
            loader   = new BackgroundWorker();
            isActive = false;

            loader.DoWork             += loader_DoWork;
            loader.RunWorkerCompleted += loader_RunWorkerCompleted;
            ImageResourceItem a = (ImageResourceItem)Container.getResourceDirectory.GetFile(GameConstraints.LoadingScreen.LogicDir, "Background.bmp");

            if (a != null)
            {
                Bitmap img = a.Content;
                layers.Add(GameApp.ResizeImg(img, 800, 600));
            }

            SoundResourceItem s = (SoundResourceItem)Container.getResourceDirectory.GetFile(GameConstraints.LoadingScreen.LogicDir, "loop.mp3");

            bgMusic = s.Content;

            table =
                (LoadResourceItem)sc.getResourceDirectory.GetFile
                (
                    GameConstraints.OtherPaths.MetadataLogicDir,
                    GameConstraints.OtherPaths.LoaderResourceName
                );
            table.IsBatchLoading = true;
            table.IsCaching      = false;
            table.SetNextNormalLevelToLoad(FileNames.FirstLevelFilename);

            foreach (string bonLvl in FileNames.AllBonusLevelsFileName)
            {
                table.SetNextBonusLevelToLoad(bonLvl);
                table.ProcessBonusLevel();
            }

            loader_DoWork(null, null);
            table.IsCaching = true;
            progress        = 0;
        }
Esempio n. 4
0
 private void loadAudio(string Path)
 {
     try
     {
         this.loopingAudio = new SoundMediaPlayer(Path);
         this.loopingAudio.Load();
         this.audioReady = true;
     }
     catch (Exception e)
     {
         Console.WriteLine("Minchia! Non è stato caricato l'audio " + Path + "! \n" + e.ToString());
         Console.WriteLine();
         this.audioReady = false;
     }
 }
Esempio n. 5
0
 private void load(string Path)
 {
     sound = new SoundMediaPlayer();
     try
     {
         sound.SoundLocation = Path;
         sound.Load();
     }
     catch (Exception e)
     {
         Console.WriteLine("Minchia! Non è stato possibile caricare l'audio " + Path + " !\n" + e.ToString());
         Console.WriteLine();
         MessageBox.Show("Minchia! Non è stato possibile caricare l'audio " + Path + " !\n" + e.ToString());
         sound.Dispose();
         sound = null;
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Procura le risorse necessarie a disegnare le scene.
        /// </summary>
        protected void LoadAndGatherResources()
        {
            if (curName == null || curPath == null || container == null)
            {
                return;
            }

            ResourceDirectory root = container.getResourceDirectory;

            root.NewDirectory(curName);
            this.loadMediaFiles(curName, curPath + @"\");
            Bitmap a;

            try
            {
                a = ((ImageResourceItem)(root.GetFile(curName, "Background.bmp"))).Content;
                this.background = GameApp.ResizeImg(a, 500, 375);
                a.Dispose();
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Errore nel caricamento dello sfondo di un menù! \n " + e.ToString() + "\n");
            }


            try
            {
                a           = ((ImageResourceItem)(root.GetFile(curName, "Cursor.png"))).Content;
                this.cursor = GameApp.ResizeImg(a, 32, 32);
                a.Dispose();
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Errore nel caricamento di uno del cursore di un menù! \n " + e.ToString() + "\n");
            }


            try
            {
                a           = ((ImageResourceItem)(root.GetFile(curName, "Header.png"))).Content;
                this.header = GameApp.ResizeImg(a, 500, 125);
                a.Dispose();
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Errore nel caricamento dell'intestazione di un menù! \n " + e.ToString() + "\n");
            }


            try
            {
                this.BackgroundMusic = ((SoundResourceItem)(root.GetFile(curName, "BackgroundMusic.mp3"))).Content;
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Errore nel caricamento della musica di sottofondo di un menù! \n " + e.ToString() + "\n");
            }


            try
            {
                this.selectSound = ((SoundResourceItem)(root.GetFile(curName, "Sound.wav"))).Content;
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Errore nel caricamento del suono di selezione di un menù! \n " + e.ToString() + "\n");
            }

            GC.Collect();
        }
Esempio n. 7
0
 /// <summary>
 /// Inizializza una risorsa di suono a partire dal file path.
 /// </summary>
 /// <param name="Path">Path del file</param>
 public SoundResourceItem(string Path)
 {
     sound = null;
     Load(Path);
 }