Beispiel #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

            // Assigning the black screen and background that is used during gameplay.
            titleBackgroundTexture = Content.Load<Texture2D>("background_title");
            highScoresBackgroundTexture = Content.Load<Texture2D>("background_highScores");
            gameplayBackgroundTexture = Content.Load<Texture2D>("background_game");
            blackTexture = Content.Load<Texture2D>("background_black");
            waterDropUITexture = Content.Load<Texture2D>("water_0");

            // Temporary texture arrays for loading batches of textures or textures that are animated.
            Texture2D[] tempTextureArray;
            Texture2D[] tempTextureArray2;

            // Same as tempTexture, but this one is used for the tank.
            Texture2D[,] tempTexture2DArray;

            // Load all music
            titleMusic = Content.Load<Song>("titleMusic");
            gameplayMusic = Content.Load<Song>("gameplayMusic");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(titleMusic);

            // Load all video
            startingVideo = Content.Load<Video>("video_startingAnimation");
            endingVideo = Content.Load<Video>("video_endingAnimation");

            // Load title textures
            tempTextureArray = new Texture2D[4];
            tempTextureArray[0] = titleBackgroundTexture;
            tempTextureArray[1] = Content.Load<Texture2D>("title");
            tempTextureArray[2] = Content.Load<Texture2D>("button_start");
            tempTextureArray[3] = Content.Load<Texture2D>("button_mute");

            tempTextureArray2 = new Texture2D[3];
            tempTextureArray2[0] = Content.Load<Texture2D>("title_tank_0");
            tempTextureArray2[1] = Content.Load<Texture2D>("title_tank_1");
            title = new Title(tempTextureArray, tempTextureArray2, windowAreaRectangle);

            // Load starting and ending animation objects
            startingAnimation = new VideoAnimation(windowAreaRectangle, startingVideo);
            endingAnimation = new VideoAnimation(windowAreaRectangle, endingVideo);

            // Load the nozzle texture
            tempTextureArray = new Texture2D[3];
            tempTextureArray[0] = Content.Load<Texture2D>("nozzle_0");
            tempTextureArray[1] = Content.Load<Texture2D>("nozzle_1");
            tempTextureArray[2] = Content.Load<Texture2D>("nozzle_2");
            nozzle = new Nozzle(tempTextureArray, playAreaRectangle);

            // Load the funnel texture
            tempTextureArray = new Texture2D[3];
            tempTextureArray[0] = Content.Load<Texture2D>("funnel_0");
            tempTextureArray[1] = Content.Load<Texture2D>("funnel_1");
            tempTextureArray[2] = Content.Load<Texture2D>("funnel_2");
            funnel = new Funnel(tempTextureArray, playAreaRectangle);

            // Load the water texture
            tempTextureArray = new Texture2D[3];
            tempTextureArray[0] = Content.Load<Texture2D>("water_0");
            tempTextureArray[1] = Content.Load<Texture2D>("water_1");
            tempTextureArray[2] = Content.Load<Texture2D>("water_2");
            water = new Water(tempTextureArray, playAreaRectangle);

            // Load Tank (3x the sprites)
            tempTexture2DArray = new Texture2D[4, 2];
            tempTexture2DArray[0, 0] = Content.Load<Texture2D>("tank_0_0");
            tempTexture2DArray[0, 1] = Content.Load<Texture2D>("tank_0_1");

            tempTexture2DArray[1, 0] = Content.Load<Texture2D>("tank_1_0");
            tempTexture2DArray[1, 1] = Content.Load<Texture2D>("tank_1_1");

            tempTexture2DArray[2, 0] = Content.Load<Texture2D>("tank_2_0");
            tempTexture2DArray[2, 1] = Content.Load<Texture2D>("tank_2_1");

            tempTexture2DArray[3, 0] = Content.Load<Texture2D>("leak_0");
            tempTexture2DArray[3, 1] = Content.Load<Texture2D>("leak_1");

            tank = new Tank(tempTexture2DArray, tankAreaRectangle);

            // Load fonts
            dropsCaughtFont = Content.Load<SpriteFont>("dropsCaughtFont");
            highScoresFont = Content.Load<SpriteFont>("highScoresFont");
            levelFont = Content.Load<SpriteFont>("levelFont");

            // Load Border
            tempTextureArray = new Texture2D[5];
            tempTextureArray[0] = Content.Load<Texture2D>("divider_0");
            tempTextureArray[1] = Content.Load<Texture2D>("divider_1");
            tempTextureArray[2] = Content.Load<Texture2D>("divider_2");
            tempTextureArray[3] = Content.Load<Texture2D>("divider_3");
            tempTextureArray[4] = Content.Load<Texture2D>("hoseEnd_0");
            border = new Border(tempTextureArray, playAreaRectangle);

            // Load High Scores title
            highScoresTitle = Content.Load<Texture2D>("title_highScores");

            //Load retry button
            retryButtonTexture = Content.Load<Texture2D>("button_retry");
            retryButton = new Rectangle(
                100,
                400,
                retryButtonTexture.Width,
                retryButtonTexture.Height);

            StartGame();
        }
Beispiel #2
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

            // Assigning the black screen and background that is used during gameplay.
            titleBackgroundTexture      = Content.Load <Texture2D>("background_title");
            highScoresBackgroundTexture = Content.Load <Texture2D>("background_highScores");
            gameplayBackgroundTexture   = Content.Load <Texture2D>("background_game");
            blackTexture       = Content.Load <Texture2D>("background_black");
            waterDropUITexture = Content.Load <Texture2D>("water_0");


            // Temporary texture arrays for loading batches of textures or textures that are animated.
            Texture2D[] tempTextureArray;
            Texture2D[] tempTextureArray2;

            // Same as tempTexture, but this one is used for the tank.
            Texture2D[,] tempTexture2DArray;

            // Load all music
            titleMusic              = Content.Load <Song>("titleMusic");
            gameplayMusic           = Content.Load <Song>("gameplayMusic");
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(titleMusic);

            // Load all video
            startingVideo = Content.Load <Video>("video_startingAnimation");
            endingVideo   = Content.Load <Video>("video_endingAnimation");

            // Load title textures
            tempTextureArray    = new Texture2D[4];
            tempTextureArray[0] = titleBackgroundTexture;
            tempTextureArray[1] = Content.Load <Texture2D>("title");
            tempTextureArray[2] = Content.Load <Texture2D>("button_start");
            tempTextureArray[3] = Content.Load <Texture2D>("button_mute");

            tempTextureArray2    = new Texture2D[3];
            tempTextureArray2[0] = Content.Load <Texture2D>("title_tank_0");
            tempTextureArray2[1] = Content.Load <Texture2D>("title_tank_1");
            title = new Title(tempTextureArray, tempTextureArray2, windowAreaRectangle);

            // Load starting and ending animation objects
            startingAnimation = new VideoAnimation(windowAreaRectangle, startingVideo);
            endingAnimation   = new VideoAnimation(windowAreaRectangle, endingVideo);

            // Load the nozzle texture
            tempTextureArray    = new Texture2D[3];
            tempTextureArray[0] = Content.Load <Texture2D>("nozzle_0");
            tempTextureArray[1] = Content.Load <Texture2D>("nozzle_1");
            tempTextureArray[2] = Content.Load <Texture2D>("nozzle_2");
            nozzle = new Nozzle(tempTextureArray, playAreaRectangle);

            // Load the funnel texture
            tempTextureArray    = new Texture2D[3];
            tempTextureArray[0] = Content.Load <Texture2D>("funnel_0");
            tempTextureArray[1] = Content.Load <Texture2D>("funnel_1");
            tempTextureArray[2] = Content.Load <Texture2D>("funnel_2");
            funnel = new Funnel(tempTextureArray, playAreaRectangle);

            // Load the water texture
            tempTextureArray    = new Texture2D[3];
            tempTextureArray[0] = Content.Load <Texture2D>("water_0");
            tempTextureArray[1] = Content.Load <Texture2D>("water_1");
            tempTextureArray[2] = Content.Load <Texture2D>("water_2");
            water = new Water(tempTextureArray, playAreaRectangle);

            // Load Tank (3x the sprites)
            tempTexture2DArray       = new Texture2D[4, 2];
            tempTexture2DArray[0, 0] = Content.Load <Texture2D>("tank_0_0");
            tempTexture2DArray[0, 1] = Content.Load <Texture2D>("tank_0_1");

            tempTexture2DArray[1, 0] = Content.Load <Texture2D>("tank_1_0");
            tempTexture2DArray[1, 1] = Content.Load <Texture2D>("tank_1_1");

            tempTexture2DArray[2, 0] = Content.Load <Texture2D>("tank_2_0");
            tempTexture2DArray[2, 1] = Content.Load <Texture2D>("tank_2_1");

            tempTexture2DArray[3, 0] = Content.Load <Texture2D>("leak_0");
            tempTexture2DArray[3, 1] = Content.Load <Texture2D>("leak_1");

            tank = new Tank(tempTexture2DArray, tankAreaRectangle);

            // Load fonts
            dropsCaughtFont = Content.Load <SpriteFont>("dropsCaughtFont");
            highScoresFont  = Content.Load <SpriteFont>("highScoresFont");
            levelFont       = Content.Load <SpriteFont>("levelFont");

            // Load Border
            tempTextureArray    = new Texture2D[5];
            tempTextureArray[0] = Content.Load <Texture2D>("divider_0");
            tempTextureArray[1] = Content.Load <Texture2D>("divider_1");
            tempTextureArray[2] = Content.Load <Texture2D>("divider_2");
            tempTextureArray[3] = Content.Load <Texture2D>("divider_3");
            tempTextureArray[4] = Content.Load <Texture2D>("hoseEnd_0");
            border = new Border(tempTextureArray, playAreaRectangle);

            // Load High Scores title
            highScoresTitle = Content.Load <Texture2D>("title_highScores");

            //Load retry button
            retryButtonTexture = Content.Load <Texture2D>("button_retry");
            retryButton        = new Rectangle(
                100,
                400,
                retryButtonTexture.Width,
                retryButtonTexture.Height);

            StartGame();
        }