- Main Page
- Classes
- Files

- File List

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

    00001 #region File Description
    00002 //-----------------------------------------------------------------------------
    00003 // PendulumMainMenuScreen.cs
    00004 //-----------------------------------------------------------------------------
    00005 #endregion
    00006
    00007 namespace PendulumGame
    00008 {
    00009     using System;
    00010     using Microsoft.Xna.Framework;
    00011     using NewGamePhysics.StateManager;
    00012
    00016     class PendulumMainMenuScreen : MenuScreen
    00017     {
    00018         #region Initialization
    00019
    00023         public PendulumMainMenuScreen()
    00024             : base("Main Menu")
    00025         {
    00026             TransitionOnTime = TimeSpan.FromSeconds(1.0);
    00027             TransitionOffTime = TimeSpan.FromSeconds(1.0);
    00028
    00029             // Create our menu entries.
    00030             MenuEntry playGameMenuEntry = new MenuEntry("Start Game");
    00031             MenuEntry helpMenuEntry = new MenuEntry("Game Controls Help");
    00032             MenuEntry infoMenuEntry = new MenuEntry("Game Information");
    00033             MenuEntry videoMenuEntry = new MenuEntry("View Pendulum Video");
    00034             MenuEntry exitMenuEntry = new MenuEntry("Exit Game");
    00035
    00036             // Hook up menu event handlers.
    00037             playGameMenuEntry.Selected += PlayGameMenuEntrySelected;
    00038             helpMenuEntry.Selected += HelpMenuEntrySelected;
    00039             infoMenuEntry.Selected += InfoMenuEntrySelected;
    00040             videoMenuEntry.Selected += VideoMenuEntrySelected;
    00041             exitMenuEntry.Selected += OnCancel;
    00042
    00043             // Add entries to the menu.
    00044             MenuEntries.Add(playGameMenuEntry);
    00045             MenuEntries.Add(helpMenuEntry);
    00046             MenuEntries.Add(infoMenuEntry);
    00047             MenuEntries.Add(videoMenuEntry);
    00048             MenuEntries.Add(exitMenuEntry);
    00049         }
    00050
    00051         #endregion
    00052
    00053         #region Handle Input
    00054
    00058         void PlayGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
    00059         {
    00060             ScreenManager.AddScreen(new PendulumOptionsMenuScreen(), null);
    00061         }
    00062
    00066         protected override void OnCancel(PlayerIndex playerIndex)
    00067         {
    00068             const string message = "Are you sure you want to exit the program?";
    00069
    00070             PendulumMessageBoxScreen confirmExitMessageBox = new PendulumMessageBoxScreen(message);
    00071
    00072             confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;
    00073
    00074             ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
    00075         }
    00076
    00081         void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
    00082         {
    00083             ScreenManager.Game.Exit();
    00084         }
    00085
    00090         void InfoMenuEntrySelected(object sender, PlayerIndexEventArgs e)
    00091         {
    00092             // Text to display
    00093             string[] messages = {
    00094             "Information on The Pendulum Game",
    00095             "",
    00096             "The Pendulum Game is a simple dynamics simulation of double",
    00097             "regular + square pendulums (hence the name). The goal is to",
    00098             "touch the 'targets' at the top of the screen for points.",
    00099             "",
    00100             "A player needs to control the friction actuators in the hinges of",
    00101             "the pendulums to inject energy into the system and make the",
    00102             "pendulum arms swing high enough to reach the 'targets'.",
    00103             "",
    00104             "Options include various gravity environments and friction models.",
    00105             "",
    00106             "The oscillatory systems together with the player interactions ",
    00107             "are used to extract physical entropy (randomness) during gameplay.",
    00108             };
    00109
    00110             ScreenManager.AddScreen(new PendulumHelpScreen(messages), null);
    00111
    00112             // Reset back to play entry
    00113             this.SelectedEntry = 0;
    00114
    00115             // Set flag to update text when we return
    00116             WaitForUncover = true;
    00117         }
    00118
    00124         void HelpMenuEntrySelected(object sender, PlayerIndexEventArgs e)
    00125         {
    00126             // Text to display
    00127             string[] messages = {
    00128             "Controls for The Pendulum Game",
    00129             "",
    00130             "--- Player A ---",
    00131             "   [Q]/[A] or (A)/(B)- select actuator hinge",
    00132             "   [Z]/[X] or [Left Stick] - inject energy at hinge",
    00133             "   [Left Shift] or [Left Trigger] - switch data display",
    00134             "--- Player B ---",
    00135             "   [Up]/[Down] or (X)/(Y) - select actuator hinge",
    00136             "   [Left]/[Right] or [Right Stick] - inject energy at hinge",
    00137             "   [Right Shift] or [Right Trigger] - switch data display",
    00138             " [Space] or (A)",
    00139             "    continue in menu, game or help screens",
    00140             " [Escape] or (Back)",
    00141             "    pause game or quit to main menu",
    00142             };
    00143
    00144             ScreenManager.AddScreen(new PendulumHelpScreen(messages), null);
    00145
    00146             // Reset back to play entry
    00147             this.SelectedEntry = 0;
    00148
    00149             // Set flag to update text when we return
    00150             WaitForUncover = true;
    00151         }
    00152
    00158         void VideoMenuEntrySelected(object sender, PlayerIndexEventArgs e)
    00159         {
    00160
    00161             PendulumLoadingScreen.Load(
    00162                 ScreenManager, true, e.PlayerIndex,
    00163                 new PendulumVideoScreen());
    00164         }
    00165         #endregion
    00166     }
    00167 }