Пример #1
0
        public Level(GameLoop game, ArrayList _textures, ArrayList _fonts, ArrayList _sounds, MusicManager _musicPlayer, PlotScreen _plotScreen, LevelLoader loader, InputHandler _inputHandler)
            : base(game)
        {
            int screenWidth = Game.GraphicsDevice.Viewport.Width;
            int screenHeight = Game.GraphicsDevice.Viewport.Height;

            bolts = new List<Bolt>();
            torches = new List<Torch>();
            guards = new List<IGuard>();
            levers = new List<Lever>();
            gates = new List<Gate>();
            boxBolts = new List<BoxOfBolts>();
            buttons = new List<Button>();
            spouts = new List<Spout>();

            playerRange = new Rectangle((screenWidth * 2) / 5, 0, screenWidth / 5, screenHeight);

            levelLoader = loader;
            textures = _textures;
            sounds = _sounds;
            fonts = _fonts;

            musicPlayer = _musicPlayer;
            plotScreen = _plotScreen;
            guardFactory = new GuardFactory((Texture2D)textures[wizardIndex], (Texture2D)textures[soldierIndex], (Texture2D)textures[LOSIndex]);

            currentLevel = 0;
            deathCounter = 0;

            screenWidth = Game.GraphicsDevice.Viewport.Width;
            screenHeight = Game.GraphicsDevice.Viewport.Height;

            this.game = game;
            inputHandler = _inputHandler;
            levelLoader.LoadLevel(currentLevel);
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            gameState = GameState.titleScreen;
            prevGameState = gameState;
            inputHandler = new InputHandler();

            plotScreen = new PlotScreen(this, musicPlayer, textures, fonts);
            level = new Level(this, textures, fonts, sounds, musicPlayer, plotScreen, new LevelLoader(config.LevelFiles), inputHandler);
            tutorial = new Level(this, textures, fonts, sounds, musicPlayer, null, new LevelLoader(config.TutorialFiles), inputHandler);
            gameOver = new GameOver(this, (Texture2D)textures[3], (SpriteFont)fonts[2], inputHandler);
            titleScreen = new TitleScreen(this, (Texture2D)textures[7], (Texture2D)textures[16], (SpriteFont)fonts[2], musicPlayer, inputHandler);
            titleMenu = new TitleMenu(this, (Texture2D)textures[7], (SpriteFont)fonts[2], inputHandler);
            levelIntroScreen = new LevelIntroScreen(this, (SpriteFont)fonts[1]);
            levelIntroScreen.InitLevelScreen(level.LevelName);

            credits = new Credits(this, (Texture2D)textures[creditsIndex], musicPlayer, fonts);

            playerAnimation = new PlayerAnimation(this, new Player(this, (Texture2D)textures[0], sounds, -100, 400));
            animatePlayer = false;
        }
Пример #3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            gameState = GameState.titleScreen;
            prevGameState = gameState;
            inputHandler = new InputHandler();

            plotScreen = new PlotScreen(this, musicPlayer, textures, fonts);
            level = new Level(this, textures, fonts, sounds, musicPlayer, plotScreen, new LevelLoader(config.LevelFiles), inputHandler);
            tutorial = new Level(this, textures, fonts, sounds, musicPlayer, null, new LevelLoader(config.TutorialFiles), inputHandler);
            gameOver = new GameOver(this, (Texture2D)textures[3], (SpriteFont)fonts[2], inputHandler);
            titleScreen = new TitleScreen(this, (Texture2D)textures[7], (Texture2D)textures[16], (SpriteFont)fonts[2], musicPlayer, inputHandler);
            titleMenu = new TitleMenu(this, (Texture2D)textures[7], (SpriteFont)fonts[2], inputHandler);
            levelIntroScreen = new LevelIntroScreen(this, (SpriteFont)fonts[1]);
            levelIntroScreen.InitLevelScreen(level.LevelName);

            credits = new Credits(this, (Texture2D)textures[creditsIndex], musicPlayer, fonts);

            playerAnimation = new PlayerAnimation(this, new Player(this, (Texture2D)textures[0], sounds, -100, 400));
            animatePlayer = false;

            int screenWidth = graphics.GraphicsDevice.Viewport.Width;
            int screenHeight = graphics.GraphicsDevice.Viewport.Height;

            //initializing virtual screen resolution to be mapped to the actual screen
            Resolution.Init(ref graphics);
            Resolution.SetVirtualResolution(screenWidth, screenHeight);
            Resolution.SetResolution(800, 600, true);
        }