Exemple #1
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()
        {
            timer = 0;
            this.IsMouseVisible = true;

            //TileMap
            TileMap[] lvl1 = new TileMap[3];
            lvl1[0] = new TileMap(1,1);
            lvl1[1] = new TileMap(1,2);
            lvl1[2] = new TileMap(1, 3);
            //Level
            Point[] goal = new Point[3];
            goal[0].X = 27;
            goal[0].Y = 4;
            goal[1].X = 25;
            goal[1].Y = 4;
            goal[2].X = 40;
            goal[2].Y = 4;
            Point[] starts = new Point[3];
            starts[0].X = 19;
            starts[0].Y = 30;
            starts[1].X = 11;
            starts[1].Y = 21;
            starts[2].X = 10;
            starts[2].Y = 13;
            currentLevel = new Level(lvl1 , goal, starts, 0,3);

            pauseFont = Content.Load<SpriteFont>("SpriteFont2");

            //Audio
            sound.normalMusic = Content.Load<Song>("hero");
            sound.Alert = Content.Load<Song>("emergence");
            sound.coinSound = Content.Load<SoundEffect>("coinbag");
            sound.fallSound = Content.Load<SoundEffect>("fall");
            sound.weakScreamSound = Content.Load<SoundEffect>("weakScream");

            SpriteFont font = Content.Load<SpriteFont>("SpriteFont1");
            blackTexture = new Texture2D(GraphicsDevice, 1, 1);
            blackTexture.SetData(new[] { Color.White });
            credits = new Credits(this);
            credits.initialize(font, blackTexture);

            Texture2D torchTexture = Content.Load<Texture2D> ("torch");
            gameOverFont = Content.Load<SpriteFont>("GameOver");
            Texture2D timerTexture = Content.Load<Texture2D>("hud");
            Texture2D viewTexture = Content.Load<Texture2D>("view");
            //Menu
            arrow = Content.Load<Texture2D>("arrow");
            menu = new Menu(this);
            menu.initialize(blackTexture, arrow, font, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            // +2 to compensate for tiles off screen
            squaresAcross = 13 ;
            squaresDown = 9 ;

            //hud
            hud = new hud(this);
            hud.initializeTimer(timerTexture, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, GraphicsDevice.Viewport.Width - 50, GraphicsDevice.Viewport.Height - 50,font);
            hud.initializeView(viewTexture, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);

            drawnRectangles = new Rectangle[squaresAcross, squaresDown];
            dot = Content.Load<Texture2D>("whitedot");
            minimap = Content.Load<Texture2D>("minimap");

            //Load guards
            loadGuards("lvl1map" + (currentLevel.currentMapIndex + 1)  + "guards.csv");

            //Load Gold
            loadGold("lvl1map" + (currentLevel.currentMapIndex + 1) + "gold.csv");

            MediaPlayer.Volume = 0.25f;
            start = new Vector2(GraphicsDevice.Viewport.Width/2, GraphicsDevice.Viewport.Height/2);
            timTexture = Content.Load<Texture2D>("sprite");
            player = new Player(this);
            player.initialize(start, (float)Math.PI, timTexture,currentLevel.start[0].X,currentLevel.start[0].Y, "Player", currentLevel.currentMap);

            base.Initialize ();
        }
Exemple #2
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()
        {
            // +2 to compensate for tiles off screen
            squaresAcross = GraphicsDevice.Viewport.Width / 64 + 2;
            squaresDown = GraphicsDevice.Viewport.Height / 64 + 2;

            SpriteFont font = Content.Load<SpriteFont>("SpriteFont1");

            Texture2D torchTexture = Content.Load<Texture2D> ("torch");
            Texture2D gameOverTexture = Content.Load<Texture2D>("GameOver");
            Texture2D hudTexture = Content.Load<Texture2D>("hud");
            hud = new hud(this);
            hud.initialize(hudTexture, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, GraphicsDevice.Viewport.Width - 50, GraphicsDevice.Viewport.Height - 50,font);
            gameOver = new GameOverScreen(this);
            gameOver.initialize(gameOverTexture, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
            gameState = GameState.Game;

            //Load guards
            loadGuards();

            Vector2 start = new Vector2(GraphicsDevice.Viewport.Width/2, GraphicsDevice.Viewport.Height/2);
            Texture2D texture = Content.Load<Texture2D>("sprite");
            player = new Player(this);
            player.initialize(start, 0, texture, 10, 10, "Player", myMap);
            testObject = new torch(this);
            testObject.initialize(myMap, 1, 1, 0, 0, torchTexture, "torch");
            base.Initialize ();
        }