- Main Page
- Classes
- Files

- File List

# C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/PendulumGame/Screens/PendulumHelpScreen.cs

    00001 ﻿//-----------------------------------------------------------------------------
    00002 // PendulumHelpScreen.cs
    00003 //-----------------------------------------------------------------------------
    00004
    00005 namespace PendulumGame
    00006 {
    00007     using System;
    00008     using System.Threading;
    00009     using System.Collections.Generic;
    00010
    00011     using Microsoft.Xna.Framework;
    00012     using Microsoft.Xna.Framework.Content;
    00013     using Microsoft.Xna.Framework.Graphics;
    00014     using Microsoft.Xna.Framework.Input;
    00015
    00016     using NewGamePhysics.StateManager;
    00017     using NewGamePhysics.Utilities;
    00018     using NewGamePhysics.GraphicalElements;
    00019     using NewGamePhysics.PhysicalElements;
    00020
    00024     class PendulumHelpScreen : GameScreen
    00025     {
    00029         private List<string> messages = new List<string>();
    00030
    00034         private InfoMessages infoMessages;
    00035
    00039         private Texture2D paneTexture;
    00040
    00041         #region Initialization
    00042
    00047         public PendulumHelpScreen(string[] screenMessage)
    00048         {
    00049             // Store screen message
    00050             this.messages.AddRange(screenMessage);
    00051
    00052             // Add exit message
    00053             string[] exitMessage = { "", "", "[Key] or (Button) to return to Main Menu" };
    00054             this.messages.AddRange(exitMessage);
    00055
    00056             TransitionOnTime = TimeSpan.FromSeconds(0.5);
    00057             TransitionOffTime = TimeSpan.FromSeconds(0.5);
    00058         }
    00059
    00063         public override void LoadContent()
    00064         {
    00065             // Create message display object
    00066             Vector2 messagesOrigin = new Vector2(
    00067                 ScreenManager.GraphicsDevice.Viewport.Width * 0.05f,
    00068                 ScreenManager.GraphicsDevice.Viewport.Height * 0.05f);
    00069             this.infoMessages = new InfoMessages(
    00070                 this.ScreenManager,
    00071                 this.messages,
    00072                 messagesOrigin);
    00073             this.infoMessages.Scale = 0.5f;
    00074
    00075             // Reset game time
    00076             ScreenManager.Game.ResetElapsedTime();
    00077
    00078             // Create translucent pane rectangle
    00079             if (this.paneTexture == null)
    00080             {
    00081                 // New background texture
    00082                 this.paneTexture = TextureHelpers.Create(ScreenManager.GraphicsDevice, new Color(64, 64, 64));
    00083             }
    00084         }
    00085
    00089         public override void UnloadContent()
    00090         {
    00091         }
    00092
    00093         #endregion
    00094
    00095         #region Update and Draw
    00096
    00100         public override void Update(GameTime gameTime, bool otherScreenHasFocus,
    00101                                                        bool coveredByOtherScreen)
    00102         {
    00103             base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
    00104
    00105             if (IsActive)
    00106             {
    00107                 this.infoMessages.Update(gameTime);
    00108             }
    00109         }
    00110
    00115         public override void HandleInput(InputState input)
    00116         {
    00117             if (input == null)
    00118             {
    00119                 throw new ArgumentNullException("input");
    00120             }
    00121
    00122             if (input.IsInputCancel(null) || input.IsDisconnected(null))
    00123             {
    00124                 ScreenManager.AddScreen(new PendulumPauseMenuScreen(), null);
    00125             }
    00126             else
    00127             {
    00128                 PlayerIndex playerIndex;
    00129
    00130                 // Back to main menu
    00131                 if (input.IsMenuSelect(null, out playerIndex))
    00132                 {
    00133                     ScreenManager.RemoveScreen(this);
    00134                     ScreenManager.AddScreen(new PendulumMainMenuScreen(), null);
    00135                 }
    00136             }
    00137         }
    00138
    00142         public override void Draw(GameTime gameTime)
    00143         {
    00144             Color paneColor = new Color(4, 4, 4);
    00145             Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
    00146             Rectangle backgroundPane =
    00147                 new Rectangle(
    00148                     10, 10, viewport.Width - 20, viewport.Height - 20);
    00149             ScreenManager.SpriteBatch.Begin();
    00150             ScreenManager.SpriteBatch.Draw(this.paneTexture, backgroundPane, new Color(paneColor, 128));
    00151             ScreenManager.SpriteBatch.End();
    00152
    00153             // Draw messages
    00154             this.infoMessages.Draw(gameTime);
    00155
    00156             // If the game is transitioning on or off, fade it out to black.
    00157             if (TransitionPosition > 0)
    00158             {
    00159                 ScreenManager.FadeBackBufferToBlack(255 - TransitionAlpha);
    00160             }
    00161
    00162             base.Draw(gameTime);
    00163         }
    00164
    00165         #endregion
    00166     }
    00167 }
    00168