예제 #1
0
        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        private void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Are you sure you want to quit this game?";

            var confirmQuitMessageBox = new MessageBoxScreen(message);

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
예제 #2
0
 /// <summary>
 /// Helper overload makes it easy to use OnCancel as a MenuEntry event handler.
 /// </summary>
 protected void OnCancel(object sender, PlayerIndexEventArgs e)
 {
     OnCancel(e.PlayerIndex);
     Environment.Exit(1);
 }
예제 #3
0
 /// <summary>
 /// Event handler for when the Play Game menu entry is selected.
 /// </summary>
 private void PlayMultiplayerGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     EndSounds();
     ScreenManager.AddScreen(new ConfigMultiplayerScreen(), e.PlayerIndex);
     //LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, new ConnectServerLoader(),new ConfigMultiplayerScreen());
 }
예제 #4
0
 /// <summary>
 /// Event handler for when the Play Game menu entry is selected.
 /// </summary>
 private void PlayLocalGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     //Console.Console.GetInstance().WriteString("Loading Local Game");
     EndSounds();
     LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, new LocalLoader(),
                        new SingleplayerScreen());
 }
예제 #5
0
 /// <summary>
 /// Event handler for when the Options menu entry is selected.
 /// </summary>
 private void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.AddScreen(new OptionsMenuScreen("Options"), e.PlayerIndex);
 }
예제 #6
0
 /// <summary>
 /// Event handler for when the user selects the credts entry
 /// </summary>
 private void CreditsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     //ScreenManager.AddScreen(new CreditsScreen(), e.PlayerIndex);
 }
예제 #7
0
 /// <summary>
 /// Event handler for when the user selects ok on the "are you sure
 /// you want to exit" message box.
 /// </summary>
 private void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.Game.Exit();
 }
        /// <summary>
        /// Gets fired when the user wants to select a different screen resolution
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The playerindexargs</param>
        private void ResolutionMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            selectedScreenSize++;
            if(selectedScreenSize == resolutions.Count)
            {
                selectedScreenSize = 0;
            }

            SetMenuEntryText();
        }
        /// <summary>
        /// Gets fired when the fullscren option is seleced on the screen
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The playerindexargs</param>
        private void FullScreenMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            isFullScreen = (isFullScreen == false) ? true : false;

            SetMenuEntryText();
        }
        /// <summary>
        /// Gets fired as soon as the user wants to apply his changes
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The playerindexargs</param>
        private void ApplyMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            PresentationParameters parameters = ScreenManager.GraphicsDevice.PresentationParameters.Clone();

            parameters.IsFullScreen = isFullScreen;
            parameters.BackBufferHeight = (int)resolutions[selectedScreenSize].Y;
            parameters.BackBufferWidth = (int)resolutions[selectedScreenSize].X;

            #if !DEBUG

            ScreenManager.GraphicsDevice.Reset(parameters);

            #endif
        }
예제 #11
0
 /// <summary>
 /// Event handler for when the user selects ok on the "are you sure
 /// you want to quit" message box. This uses the loading screen to
 /// transition from the game back to the main menu screen.
 /// </summary>
 private void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
                        new MainMenuScreen());
 }
예제 #12
0
 /// <summary>
 /// Gets fires when the server wants to select a different MovObjType
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void figureMenuSelected(object sender, PlayerIndexEventArgs e)
 {
     currentFigure = (currentFigure + 1) % (figures.Length/2);
     SetMenuEntryText();
 }
예제 #13
0
        /// <summary>
        /// Gets fired when the user wants to connect to a server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void serverMenuSelected(object sender, PlayerIndexEventArgs e)
        {
            if (client != null)
            {
                if (client.ServerConnection == null)
                {
                    waitServerConnect = true;

                    // Contact Server
                    //client.DiscoverKnownPeer("147.87.243.50", 666);
                    client.DiscoverLocalPeers(666);

                    //Stopwatch to see if the server times out.
                    stopwatch.Start();
                }
                else
                {
                    // Connection to server already exists, just request a time synchronisation
                    waitTimeSync = true;
                    networkManager.sendMessage("syncTime");
                    sendTime = gameTime.TotalGameTime;
                    stopwatch.Start(); // start the stopwatch for timeout check
                    count = 0;
                }

            }
        }
예제 #14
0
 /// <summary>
 /// Starts the game
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void StartGame(object sender, PlayerIndexEventArgs e)
 {
     if(networkManager != null)
     {
         // send the server the startGame message to tell him this client is ready
         NetOutgoingMessage msg = networkManager.createMessage();
         msg.Write("startGame");
         msg.Write(Convert.ToInt32(figures[currentFigure, 1]));
         if (networkManager.sendMessage(msg) == NetSendResult.Sent)
         {
             LoadingScreen.Load(ScreenManager, true, e.PlayerIndex, new MultiplayerLoader(this.networkManager, timeOffset),
                                new MultiplayerScreen(this.networkManager));
         }
     } else
     {
         ScreenManager.AddScreen(new MessageBoxScreen("No connection to a server has been found"), e.PlayerIndex);
     }
 }
예제 #15
0
 /// <summary>
 /// If the user cancels, the main menuscreen will be brought up again
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void OnCancel(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.AddScreen(new MainMenuScreen(), e.PlayerIndex);
 }