public void DrawCallsGameSessionViewGenerateCorrectlyOnClient()
        {
            var stubGSV = MockRepository.GenerateStub<IView>();
            GameplayScreen gpScreen = new GameplayScreen(new GameSessionControllerAndView(null, null, stubGSV), null, null);

            gpScreen.Draw(new Microsoft.Xna.Framework.GameTime());

            stubGSV.AssertWasCalled(x => x.Generate(Arg<float>.Is.Anything));
        }
        public void UpdateCallsGameSessionControllerProcessCorrectlyOnClient()
        {
            var stubGSC = MockRepository.GenerateStub<IController>();
            GameplayScreen gpScreen = new GameplayScreen(new GameSessionControllerAndView(null, stubGSC, null), null, null);

            gpScreen.Update(new Microsoft.Xna.Framework.GameTime(), false, false);

            stubGSC.AssertWasCalled(x => x.Process(Arg<long>.Is.Anything));
        }
Exemple #3
0
        /// <summary>
        /// Updates the screen. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
            bool coveredByOtherScreen)
        {
            State = MainMenuState.Network;

            if (_gameplayScreen != null)
            {
                if (_gameplayScreen.ScreenState == ScreenState.Dead)
                {
                    _gameSessionFactory.Dispose();
                    _gameplayScreen = null;
                }
            }

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
Exemple #4
0
        public void JoinSession(string address, int port)
        {
            var clientGameSesssionCandV = _gameSessionFactory.MakeClientGameSession(address, port);

            _gameplayScreen = _screenFactory.MakeGameplayScreen(clientGameSesssionCandV, null);
        }
Exemple #5
0
        /// <summary>
        /// Start creating a session of the given type.
        /// </summary>
        /// <param name="sessionType">The type of session to create.</param>
        void CreateSession()
        {
            var serverGameSessionCandV = _gameSessionFactory.MakeServerGameSession();
            var clientGameSessionCandV = _gameSessionFactory.MakeClientGameSession("", 14242);

            _gameplayScreen = _screenFactory.MakeGameplayScreen(clientGameSessionCandV, serverGameSessionCandV);


            #region Old Network Code
            /*
            try
            {
                IAsyncResult asyncResult = NetworkSession.BeginCreate(sessionType, 1,
                    WorldManager.MaximumPlayers, null, null);

                // create the busy screen
                NetworkBusyScreen busyScreen = new NetworkBusyScreen(
                    "Creating a session...", asyncResult);
                busyScreen.OperationCompleted += SessionCreated;
                ScreenManager.AddScreen(busyScreen);
            }
            catch (NetworkException ne)
            {
                const string message = "Failed creating the session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine("Failed to create session:  " +
                    ne.Message);
            }
            catch (GamerPrivilegeException gpe)
            {
                const string message =
                    "You do not have permission to create a session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine(
                    "Insufficient privilege to create session:  " + gpe.Message);
            }
             * 
             * 
             * 
             * 
             * 
             * 
             * 
        /// <summary>
        /// Callback when a session is created.
        /// </summary>
        void SessionCreated(object sender, OperationCompletedEventArgs e)
        {
            NetworkSession networkSession = null;
            try
            {
                networkSession = NetworkSession.EndCreate(e.AsyncResult);
            }
            catch (NetworkException ne)
            {
                const string message = "Failed creating the session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine("Failed to create session:  " +
                    ne.Message);
            }
            catch (GamerPrivilegeException gpe)
            {
                const string message =
                    "You do not have permission to create a session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine(
                    "Insufficient privilege to create session:  " + gpe.Message);
            }
            if (networkSession != null)
            {
                networkSession.AllowHostMigration = true;
                networkSession.AllowJoinInProgress = false;
                LoadGameplayScreen(networkSession);
            }
        }
             * 
             * 
            */
            #endregion
        }
Exemple #6
0
 public GameplayScreen MakeGameplayScreen(GameSessionControllerAndView clientGameSessionCandV, GameSessionControllerAndView serverGameSessionCandV)
 {
     GameplayScreen gameplayScreen = new GameplayScreen(clientGameSessionCandV, serverGameSessionCandV, this);
     _screenManager.AddScreen(gameplayScreen);
     return gameplayScreen;
 }