/// <summary> /// Unload graphics content used by the game. /// </summary> public override void Unload() { content.Unload(); content = null; _hero = null; _world.Clear(); //_world = null; _camera = null; _currentLevel = null; _debugView = null; #if WINDOWS_PHONE Microsoft.Phone.Shell.PhoneApplicationService.Current.State.Remove("PlayerPosition"); Microsoft.Phone.Shell.PhoneApplicationService.Current.State.Remove("EnemyPosition"); #endif }
public void loadNextLevel() { GameplayScreen g = GameplayScreen.getInstance(); _hero = null; _world = null; _camera = null; _currentLevel = null; g._debugView = null; loadLevel((++currentLevelNum) % _levels.Length); }
public void reload() { GameplayScreen g = GameplayScreen.getInstance(); _hero = null; _world = null; _camera = null; _currentLevel = null; g._debugView = null; completedLevel = false; g.clearTimers(); g.loadLevel(g.currentLevelNum); }
public void loadLevel(int levelNumber) { if (levelNumber >= 0 && levelNumber < _levels.Length) { String contentdir = content.RootDirectory; contentdir += "/Levels/" + _levels[levelNumber]; initializeLevel(); _currentLevel = Level.FromFile(contentdir, content); } }
public void loadLevel(string filename) { if (!filename.Contains(".xml")) filename += ".xml"; Console.WriteLine("Filename: " + filename); // TODO: check if file exists in current directory //String contentdir = content.RootDirectory; //contentdir = filename; initializeLevel(); try { _currentLevel = Level.FromFile(filename, content); } catch (System.IO.FileNotFoundException e) { System.Windows.Forms.MessageBox.Show(e.Message, "File Not Found"); this.ExitScreen(); System.Environment.Exit(-1); } }
public void initializeLevel() { ConvertUnits.SetDisplayUnitToSimUnitRatio(64); if (_currentLevel == null) _currentLevel = new Level(); if (_world == null) { _world = new World(new Vector2(0f, 12f)); } if (_hero == null) _hero = new Player(_world); if (_camera == null) { _camera = new Camera2D(ScreenManager.GraphicsDevice); _camera.EnablePositionTracking = true; _camera.TrackingBody = _hero._body; } if (gameTimers == null) { gameTimers = new TimerManager(ref _world); } if (_debugView == null) { _debugView = new DebugViewXNA(_world); _debugView.AppendFlags(DebugViewFlags.DebugPanel); _debugView.DefaultShapeColor = Color.White; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(ScreenManager.GraphicsDevice, content); } completedLevel = false; }
public void setLevel(Level l) { level = l; }
public void init() { this.player = new Player(); this.camera = new Camera(player); this.level = new Level(0,camera,model,model2,model_zombie); player.setLevel(level); level.SetUpBoundingBoxes(); hud2 = new HUD2(player, gameFont, heart,ScreenManager.SpriteBatch); }
private void LoadNextLevel() { levelIndex = (levelIndex + 1) % NumberOfLevels; if (level != null) level.Dispose(); string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex); using (Stream fileStream = TitleContainer.OpenStream(levelPath)) { level = new Level(ScreenManager.Game.Services, fileStream, levelIndex); level.Name = levelNames[levelIndex]; } }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { if (content == null) content = new ContentManager(ScreenManager.Game.Services, "Content"); // A real game would probably have more content than this sample, so // it would take longer to load. We simulate that by delaying for a // while, giving you a chance to admire the beautiful loading screen. //Thread.Sleep(1000); // once the load has finished, we use ResetElapsedTime to tell the game's // timing mechanism that we have just finished a very long frame, and that // it should not try to catch up. ScreenManager.Game.ResetElapsedTime(); spriteBatch = ScreenManager.SpriteBatch; arial = content.Load<SpriteFont>("Arial"); infoFont = content.Load<SpriteFont>("Info"); level = content.Load<Level>("cool"); cursor = content.Load<Texture2D>("cursor"); bullet = content.Load<Texture2D>("bullet"); enemy = content.Load<Texture2D>("enemy"); gui = content.Load<Texture2D>("gui"); waveButton = content.Load<Texture2D>("wave button"); waveButtonPressed = content.Load<Texture2D>("wave button hover"); window = content.Load<Texture2D>("window"); LoadTowerTextures(); SetUpWaves(); SetUpGui(); audioEngine = new AudioEngine("Content/xactProject3.xgs"); waveBank = new WaveBank(audioEngine, "Content/myWaveBank.xwb"); soundBank = new SoundBank(audioEngine, "Content/mySoundBank.xsb"); }