Ejemplo n.º 1
0
        /// <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
        }
Ejemplo n.º 2
0
        public void loadNextLevel()
        {
            GameplayScreen g = GameplayScreen.getInstance();
            _hero = null;
            _world = null;
            _camera = null;
            _currentLevel = null;
            g._debugView = null;

            loadLevel((++currentLevelNum) % _levels.Length);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
 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);
        }
Ejemplo n.º 9
0
        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];
            }
        }
Ejemplo n.º 10
0
        /// <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");
        }