示例#1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            // create the buttons
            start    = new TempButton(Content.Load <Texture2D>("startButton"), Content.Load <Texture2D>("startButtonHover"), new Rectangle(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 8, GraphicsDevice.Viewport.Height / 2 - 100, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));
            options  = new TempButton(Content.Load <Texture2D>("optionsButton"), Content.Load <Texture2D>("optionsButtonHover"), new Rectangle(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 8, GraphicsDevice.Viewport.Height / 2, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));
            controls = new TempButton(Content.Load <Texture2D>("controlsButton"), Content.Load <Texture2D>("controlsButtonHover"), new Rectangle(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 8, GraphicsDevice.Viewport.Height / 2 + 100, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));
            quit     = new TempButton(Content.Load <Texture2D>("quitButton"), Content.Load <Texture2D>("quitButtonHover"), new Rectangle(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 8, GraphicsDevice.Viewport.Height / 2 + 200, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));
            back     = new TempButton(Content.Load <Texture2D>("backButton"), Content.Load <Texture2D>("backButtonHover"), new Rectangle(GraphicsDevice.Viewport.Width / 2 + 200, GraphicsDevice.Viewport.Height / 2 + 150, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));
            resume   = new TempButton(Content.Load <Texture2D>("resumeButton"), Content.Load <Texture2D>("resumeButtonHover"), new Rectangle(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 8, GraphicsDevice.Viewport.Height / 2 - 100, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));
            restart  = new TempButton(Content.Load <Texture2D>("restartButton"), Content.Load <Texture2D>("restartButtonHover"), new Rectangle(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 8, GraphicsDevice.Viewport.Height / 2, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));
            easy     = new TempButton(Content.Load <Texture2D>("easyIndicator"), Content.Load <Texture2D>("godMode"), new Rectangle(GraphicsDevice.Viewport.Width / 2 - GraphicsDevice.Viewport.Width / 8, GraphicsDevice.Viewport.Height / 2 - 100, GraphicsDevice.Viewport.Width / 4, GraphicsDevice.Viewport.Height / 8));

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


            // sprite loading
            platform      = Content.Load <Texture2D>("platform");
            player        = Content.Load <Texture2D>("Player");
            easyIndicator = Content.Load <Texture2D>("easyIndicator");
            flashlight    = Content.Load <Texture2D>("flashlight");
            closedDoor    = Content.Load <Texture2D>("closeDoor");
            openDoor      = Content.Load <Texture2D>("openDoor");
            leverBefore   = Content.Load <Texture2D>("leverBefore");
            leverAfter    = Content.Load <Texture2D>("leverAfter");
            buttonBefore  = Content.Load <Texture2D>("buttonBefore");
            buttonAfter   = Content.Load <Texture2D>("buttonAfter");
            godMode       = false;

            // Control loading
            Texture2D select      = Content.Load <Texture2D>("selectionBox");
            Texture2D check       = Content.Load <Texture2D>("selectionBoxChecked");
            Texture2D selectHover = Content.Load <Texture2D>("selectionBoxHover");

            jump           = new TempButton(select, selectHover, new Rectangle(250, 175, select.Width, select.Height));
            left           = new TempButton(select, selectHover, new Rectangle(250, 275, select.Width, select.Height));
            right          = new TempButton(select, selectHover, new Rectangle(250, 375, select.Width, select.Height));
            jumpTitle      = Content.Load <Texture2D>("jumpButton");
            leftTitle      = Content.Load <Texture2D>("leftButton");
            rightTitle     = Content.Load <Texture2D>("rightButton");
            godModeTitle   = Content.Load <Texture2D>("godMode");
            godModeSelect  = new TempButton(select, select, new Rectangle(350, 515, select.Width, select.Height));
            godModeChecked = new TempButton(check, check, new Rectangle(450, 515, select.Width, select.Height));
            reset          = new TempButton(select, selectHover, new Rectangle(850, 415, select.Width, select.Height));


            // loading levels
            // files must be in the debug folder to work
            test = new LevelReader(platform, player, openDoor, closedDoor, leverBefore, leverAfter, buttonBefore, buttonAfter, @"test.level");
            test.ReadFile();
            walls        = test.Interactable;
            inputObjects = test.InputObjects;
            clDoor       = test.DoorClose;
            oDoor        = test.DoorOpen;

            doorOpen       = false;
            leverPressable = false;
        }