Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //Start music
            musicControl.Initialize(Content);
            musicControl.Play();

            //Added

            networkSession = null;

            // Set a fixed time span of 1/60th of a second.

            targetTimeSpan    = new TimeSpan(166666); // In 100 nanosecond units = 16 666 600 nanoseconds
            IsFixedTimeStep   = true;
            TargetElapsedTime = targetTimeSpan;

            // Reset the game - indicate that player #1 (player 0) owns this instance of the game.

            deterministicGame.ResetGame(playerIdentifiers, playerIdentifiers[0]);

            // For debugging - reset the mouse position to the center of the window.

            Mouse.SetPosition(400, 300);

            // Allow the base class to initialize.

            base.Initialize();
        }
Exemple #2
0
        void restart()
        {
            youLoseSound.Play();
            deterministicGame.currentLevel.gameRestart = false;

            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth  = 800;
            graphics.ApplyChanges();


            musicControl.Restart();


            // Make the game object.  The game is currently called 'DuckSlaughterGame'
            deterministicGame = new DuckSlaughterGame();
            deterministicGame.ResetGame(playerIdentifiers, playerIdentifiers[0]);
            deterministicGame.LoadContent(Content);
            deterministicGame.Initialize();

            // Debugging setup
            lastPressedKeys = new List <Keys>();
            activePlayer    = playerIdentifiers[0];
            paused          = false;
            gameStarted     = false;


            //Added
            isHost   = false;
            chatText = "";

            reader.Close();
            writer.Close();

            networkSession.Dispose();

            networkSession = null;

            reader        = new PacketReader();
            writer        = new PacketWriter();
            chatlines     = 0;
            isChatting    = false;
            mouseChange   = false;
            buttonPressed = false;
            others        = new player[4];
            update        = true;
            gameStarted   = false;

            inMenu = true;
            startS.Show();
            helpS.Hide();
            activeS      = startS;
            releasedKeys = new List <Keys>();
        }