Exemple #1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //scrolling background
            background = new Background(Content.Load<Texture2D>(@"backgrounds\bg"), graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            background.setScroll("DOWNLEFT");

            //Level backgrounds
            Texture2D level1BgTexture = Content.Load<Texture2D>(@"backgrounds\level1bg");
            level1bg = new Background(level1BgTexture, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, true);
            level1bg.setViewport(new Rectangle(0, level1BgTexture.Height - 768, 1024, 768));

            Texture2D level2BgTexture = Content.Load<Texture2D>(@"backgrounds\level2bg");
            level2bg = new Background(level2BgTexture, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, true);
            level2bg.setViewport(new Rectangle(0, level2BgTexture.Height - 768, 1024, 768));

            Texture2D level3BgTexture = Content.Load<Texture2D>(@"backgrounds\level1bg");
            level3bg = new Background(level3BgTexture, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, true);
            level3bg.setViewport(new Rectangle(0, level3BgTexture.Height - 768, 1024, 768));

            //Load logo
            logo = Content.Load<Texture2D>(@"sprites\reallybadlogo");

            //Create engine
            Engine = new ShootanEngine(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, Content);

            /* ---------
             * UI Stuff
               --------*/
            //Main Menu
            mainMenu = new SGButtonContainer();

            startButton = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth/2 - 200, -320, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            startButton.setText("New Game");

            loadButton = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth / 2 - 200, -240, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            loadButton.setText("Load level");

            DLCButton = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth / 2 - 200, -160, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            DLCButton.setText("DLC");

            quitButton = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth / 2 - 200, -80, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            quitButton.setText("Quit");

            //Add MainMenu buttons to MainMenu container
            mainMenu.add(startButton);
            mainMenu.add(loadButton);
            mainMenu.add(DLCButton);
            mainMenu.add(quitButton);

            //Set the stopping position for sliding animation and slide it
            mainMenu.setSlideGoal(graphics.PreferredBackBufferWidth / 2 - 200, 400);
            mainMenu.slideDown();

            //Level selection menu
            levelMenu = new SGButtonContainer();

            //Create level selection buttons
            level1 = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth + 400, 400, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            level1.setText("Level One");

            level2 = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth + 400, 480, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            level2.setText("Level Two");

            level3 = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth + 400, 560, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            level3.setText("Level Three");

            backButton = new SGButton(Content.Load<Texture2D>(@"menu\button"), Content.Load<Texture2D>(@"menu\button_down"), new Rectangle(graphics.PreferredBackBufferWidth + 400, 560, 400, 70), Content.Load<SpriteFont>("MenuFont"));
            backButton.setText("Back");

            //Add level selection buttons to container
            levelMenu.add(level1);
            levelMenu.add(level2);
            levelMenu.add(level3);
            levelMenu.add(backButton);

            //Mode selection buttons
            mode1 = new SGButton(Content.Load<Texture2D>(@"menu\mode1up"), Content.Load<Texture2D>(@"menu\mode1down"), new Rectangle(340, 300, 100, 100), Content.Load<SpriteFont>("MenuFont"));
            mode1.setText("");

            mode2 = new SGButton(Content.Load<Texture2D>(@"menu\mode2up"), Content.Load<Texture2D>(@"menu\mode2down"), new Rectangle(450, 300, 100, 100), Content.Load<SpriteFont>("MenuFont"));
            mode2.setText("");

            mode3 = new SGButton(Content.Load<Texture2D>(@"menu\mode3up"), Content.Load<Texture2D>(@"menu\mode3down"), new Rectangle(560, 300, 100, 100), Content.Load<SpriteFont>("MenuFont"));
            mode3.setText("");
        }
 public void add(SGButton sg)
 {
     buttons.Add(sg);
 }