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);
            segoeFont = Content.Load<SpriteFont>("Fonts/Segoe");

            gameClock = new Clock(Content.Load<Texture2D>("Textures/sprite0_0"), Content.Load<Texture2D>("Textures/Triangle"));
            gameClock.Position = new Vector3(30, 30, -1);
            gameClock.Parent = states[GameState.Play];
            gameClock.TimeUpEvent += GameOver;

            #region Sound Intialization

            // play background music (using the system SoundPlayer which only plays waves...)
            player.SoundLocation = Content.RootDirectory + "\\Sounds\\Acid_Swamps.wav";
            player.PlayLooping();

            click = Content.Load<SoundEffect>("Sounds/click_tiny");
            cannonShot = Content.Load<SoundEffect>("Sounds/cannon");
            woodHit = Content.Load<SoundEffect>("Sounds/wood2");
            rockHit = Content.Load<SoundEffect>("Sounds/crunchy");
            glassHit = Content.Load<SoundEffect>("Sounds/breaking");

            #endregion

            #region Camera Initialization
            cameras = new Camera[3];
            cameras[0] = new Camera();
            cameras[0].Position = new Vector3(0, 0, 10);
            cameras[0].AspectRatio = GraphicsDevice.Viewport.AspectRatio;
            cameras[1] = new Camera();
            cameras[1].RotateX = -MathHelper.PiOver2; // to look down
            cameras[1].Position = new Vector3(0,10,0);
            cameras[1].AspectRatio = GraphicsDevice.Viewport.AspectRatio;
            cameras[2] = new Camera();
            cameras[2].Position = new Vector3(0, 0, 5);
            cameras[2].AspectRatio = GraphicsDevice.Viewport.AspectRatio;

            curCamera = 0; // 0 = behind the cannon
            // 1 = top-down view
            // 2 = first person
            #endregion

            #region Game Objects Initialization
            generator = new TextureGenerator(GraphicsDevice, 256, 256);

            // load ground
            ground = new ModelObject(Content.Load<Model>("Models/Plane"), Vector3.Zero);
            ground.Position = new Vector3(0, -1, 0);
            ground.Scale *= 10.0f;
            ground.Parent = states[GameState.Play];
            ground.Texture = generator.makeGroundTexture();

            // load cannon
            cannon = new Cannon(Content.Load<Model>("Models/Torus"), Content.Load<Texture2D>("Textures/Stripes"), generator.makeBlank(), new Vector3(0,0,5));
            cannon.Parent = states[GameState.Play];
            cannon.FireEvent += FireCannon;
            ball = Content.Load<Model>("Models/Sphere");

            // create the blocks
            cube = Content.Load<Model>("Models/Cube");

            //SkyBox stuff
            skyCube = Content.Load<Model>("Models/Cube");
            skyboxTexture = Content.Load<TextureCube>("Skyboxes/SunnySkybox");
            skyboxEffect = Content.Load<Effect>("Skyboxes/Skybox");
            skybox = new Skybox(skyCube,skyboxTexture,skyboxEffect);
            #endregion

            #region GUI Intialization

            pausePanel = new GUIElement(Content.Load<Texture2D>("Textures/Square"), 200, 200);
            pausePanel.Position = new Vector3(0,20,-1);
            pausePanel.Parent = states[GameState.Pause];

            infoPanel = new GUIElement(Content.Load<Texture2D>("Textures/Square"), 200, 200);
            infoPanel.Position = new Vector3(0, 0, -2);
            infoPanel.Parent = states[GameState.Info];

            mainMenuPanel = new GUIElement(Content.Load<Texture2D>("Textures/Square"), 200, 120);
            mainMenuPanel.Position = new Vector3(0, 0, -2);
            mainMenuPanel.Parent = states[GameState.Menu];

            howToPanel = new GUIElement(Content.Load<Texture2D>("Textures/Square"), 500, 200);
            howToPanel.Position = new Vector3(200, 60, -1);
            howToPanel.eleColor = Color.Yellow;
            howToPanel.Parent = states[GameState.Info];

            playPanel = new GUIElement(Content.Load<Texture2D>("Textures/Square"), 270, 70);
            playPanel.Position = new Vector3(180, 0, -1);
            playPanel.eleColor = Color.SeaShell;
            playPanel.Parent = states[GameState.Play];

            playButton = new Button(40, 50, 50, 25, Content.Load<Texture2D>("Textures/Square"), segoeFont);
            playButton.MouseDown += PlayGame;
            playButton.TextColor = Color.Black;
            playButton.HoverColor = Color.YellowGreen;
            playButton.Text = "Play";

            infoButton = new Button(40, 75, 50, 25, Content.Load<Texture2D>("Textures/Square"), segoeFont);
            infoButton.MouseDown += InfoMenu;
            infoButton.TextColor = Color.Black;
            infoButton.HoverColor = Color.YellowGreen;
            infoButton.Text = "Info";

            quitButton = new Button(40, 75, 50, 25, Content.Load<Texture2D>("Textures/Square"), segoeFont);
            quitButton.MouseDown += QuitGame;
            quitButton.TextColor = Color.Black;
            quitButton.HoverColor = Color.YellowGreen;
            quitButton.Text = "Quit";

            menuButton = new Button(40, 100, 50, 25, Content.Load<Texture2D>("Textures/Square"), segoeFont);
            menuButton.MouseDown += ToMenu;
            menuButton.TextColor = Color.Black;
            menuButton.HoverColor = Color.YellowGreen;
            menuButton.Text = "Main Menu";

            mainMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            mainMenuButtons.addButton(playButton);
            mainMenuButtons.addButton(quitButton);
            mainMenuButtons.Parent = states[GameState.Menu];

            pauseMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            pauseMenuButtons.addButton(playButton);
            pauseMenuButtons.addButton(infoButton);
            pauseMenuButtons.addButton(menuButton);
            pauseMenuButtons.Parent = states[GameState.Pause];

            infoMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            infoMenuButtons.addButton(playButton);
            infoMenuButtons.addButton(menuButton);
            infoMenuButtons.Parent = states[GameState.Info];

            gameOverMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            gameOverMenuButtons.addButton(menuButton);
            gameOverMenuButtons.addButton(quitButton);
            gameOverMenuButtons.Parent = states[GameState.End];
            #endregion GUI Intialization
        }
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);
            segoeFont   = Content.Load <SpriteFont>("Fonts/Segoe");

            gameClock              = new Clock(Content.Load <Texture2D>("Textures/sprite0_0"), Content.Load <Texture2D>("Textures/Triangle"));
            gameClock.Position     = new Vector3(30, 30, -1);
            gameClock.Parent       = states[GameState.Play];
            gameClock.TimeUpEvent += GameOver;

            #region Sound Intialization

            // play background music (using the system SoundPlayer which only plays waves...)
            player.SoundLocation = Content.RootDirectory + "\\Sounds\\Acid_Swamps.wav";
            player.PlayLooping();

            click      = Content.Load <SoundEffect>("Sounds/click_tiny");
            cannonShot = Content.Load <SoundEffect>("Sounds/cannon");
            woodHit    = Content.Load <SoundEffect>("Sounds/wood2");
            rockHit    = Content.Load <SoundEffect>("Sounds/crunchy");
            glassHit   = Content.Load <SoundEffect>("Sounds/breaking");

            #endregion

            #region Camera Initialization
            cameras                = new Camera[3];
            cameras[0]             = new Camera();
            cameras[0].Position    = new Vector3(0, 0, 10);
            cameras[0].AspectRatio = GraphicsDevice.Viewport.AspectRatio;
            cameras[1]             = new Camera();
            cameras[1].RotateX     = -MathHelper.PiOver2; // to look down
            cameras[1].Position    = new Vector3(0, 10, 0);
            cameras[1].AspectRatio = GraphicsDevice.Viewport.AspectRatio;
            cameras[2]             = new Camera();
            cameras[2].Position    = new Vector3(0, 0, 5);
            cameras[2].AspectRatio = GraphicsDevice.Viewport.AspectRatio;

            curCamera = 0; // 0 = behind the cannon
            // 1 = top-down view
            // 2 = first person
            #endregion

            #region Game Objects Initialization
            generator = new TextureGenerator(GraphicsDevice, 256, 256);

            // load ground
            ground          = new ModelObject(Content.Load <Model>("Models/Plane"), Vector3.Zero);
            ground.Position = new Vector3(0, -1, 0);
            ground.Scale   *= 10.0f;
            ground.Parent   = states[GameState.Play];
            ground.Texture  = generator.makeGroundTexture();

            // load cannon
            cannon            = new Cannon(Content.Load <Model>("Models/Torus"), Content.Load <Texture2D>("Textures/Stripes"), generator.makeBlank(), new Vector3(0, 0, 5));
            cannon.Parent     = states[GameState.Play];
            cannon.FireEvent += FireCannon;
            ball              = Content.Load <Model>("Models/Sphere");

            // create the blocks
            cube = Content.Load <Model>("Models/Cube");

            //SkyBox stuff
            skyCube       = Content.Load <Model>("Models/Cube");
            skyboxTexture = Content.Load <TextureCube>("Skyboxes/SunnySkybox");
            skyboxEffect  = Content.Load <Effect>("Skyboxes/Skybox");
            skybox        = new Skybox(skyCube, skyboxTexture, skyboxEffect);
            #endregion

            #region GUI Intialization

            pausePanel          = new GUIElement(Content.Load <Texture2D>("Textures/Square"), 200, 200);
            pausePanel.Position = new Vector3(0, 20, -1);
            pausePanel.Parent   = states[GameState.Pause];

            infoPanel          = new GUIElement(Content.Load <Texture2D>("Textures/Square"), 200, 200);
            infoPanel.Position = new Vector3(0, 0, -2);
            infoPanel.Parent   = states[GameState.Info];

            mainMenuPanel          = new GUIElement(Content.Load <Texture2D>("Textures/Square"), 200, 120);
            mainMenuPanel.Position = new Vector3(0, 0, -2);
            mainMenuPanel.Parent   = states[GameState.Menu];

            howToPanel          = new GUIElement(Content.Load <Texture2D>("Textures/Square"), 500, 200);
            howToPanel.Position = new Vector3(200, 60, -1);
            howToPanel.eleColor = Color.Yellow;
            howToPanel.Parent   = states[GameState.Info];

            playPanel          = new GUIElement(Content.Load <Texture2D>("Textures/Square"), 270, 70);
            playPanel.Position = new Vector3(180, 0, -1);
            playPanel.eleColor = Color.SeaShell;
            playPanel.Parent   = states[GameState.Play];

            playButton            = new Button(40, 50, 50, 25, Content.Load <Texture2D>("Textures/Square"), segoeFont);
            playButton.MouseDown += PlayGame;
            playButton.TextColor  = Color.Black;
            playButton.HoverColor = Color.YellowGreen;
            playButton.Text       = "Play";

            infoButton            = new Button(40, 75, 50, 25, Content.Load <Texture2D>("Textures/Square"), segoeFont);
            infoButton.MouseDown += InfoMenu;
            infoButton.TextColor  = Color.Black;
            infoButton.HoverColor = Color.YellowGreen;
            infoButton.Text       = "Info";

            quitButton            = new Button(40, 75, 50, 25, Content.Load <Texture2D>("Textures/Square"), segoeFont);
            quitButton.MouseDown += QuitGame;
            quitButton.TextColor  = Color.Black;
            quitButton.HoverColor = Color.YellowGreen;
            quitButton.Text       = "Quit";

            menuButton            = new Button(40, 100, 50, 25, Content.Load <Texture2D>("Textures/Square"), segoeFont);
            menuButton.MouseDown += ToMenu;
            menuButton.TextColor  = Color.Black;
            menuButton.HoverColor = Color.YellowGreen;
            menuButton.Text       = "Main Menu";

            mainMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            mainMenuButtons.addButton(playButton);
            mainMenuButtons.addButton(quitButton);
            mainMenuButtons.Parent = states[GameState.Menu];

            pauseMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            pauseMenuButtons.addButton(playButton);
            pauseMenuButtons.addButton(infoButton);
            pauseMenuButtons.addButton(menuButton);
            pauseMenuButtons.Parent = states[GameState.Pause];

            infoMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            infoMenuButtons.addButton(playButton);
            infoMenuButtons.addButton(menuButton);
            infoMenuButtons.Parent = states[GameState.Info];

            gameOverMenuButtons = new ButtonGroup(Color.YellowGreen, click);
            gameOverMenuButtons.addButton(menuButton);
            gameOverMenuButtons.addButton(quitButton);
            gameOverMenuButtons.Parent = states[GameState.End];
            #endregion GUI Intialization
        }