private KulaLevel InsertLevel(ResourceInfo rInfo) { string logdir = rInfo.LogicDirectory; string resname = rInfo.ResourceName; string filename = rInfo.RealFilePath; if (!root.ContainsDirectory(logdir)) { root.NewDirectory(logdir); } if (!root.ContainsFile(logdir, resname)) { root.InsertFile(logdir, resname, new LevelResourceItem(filename)); } if (root.GetFile(logdir, resname) != null) { return(((LevelResourceItem)root.GetFile(logdir, resname)).Content); } else { Console.Clear(); Console.WriteLine("WARNING! A level was loaded but it still is not found!"); } return(null); }
private void GameScreenLoading() { ResourceDirectory root = this.container.getResourceDirectory; string itsPath = GameApp.CurDir() + GameConstraints.GameScreen.Path; string itsName = GameConstraints.GameScreen.LogicDir; root.NewDirectory(itsName); loadMediaFiles(itsName, itsPath + @"\"); game = new GameScreen(container); container.addScene(GameConstraints.GameScreen.ID, game); }
private void LoadingScreenSetup() { ResourceDirectory root = this.container.getResourceDirectory; root.NewDirectory(GameConstraints.OtherPaths.CachedLevelsDir); root.NewDirectory(GameConstraints.OtherPaths.BonusLevelsDir); root.NewDirectory(GameConstraints.OtherPaths.PermanentLevelsDir); root.NewDirectory(GameConstraints.OtherPaths.MetadataLogicDir); root.InsertFile( GameConstraints.OtherPaths.MetadataLogicDir, GameConstraints.OtherPaths.LoaderResourceName, new LoadResourceItem(root) ); root.InsertFile( GameConstraints.OtherPaths.MetadataLogicDir, FileNames.HighscoresFileName, new HighScoresResourceItem() ); container.addScene(GameConstraints.LoadingScreen.ID, new LoadingScreen(container)); }
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; }
/// <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(); }