コード例 #1
0
ファイル: Game06.cs プロジェクト: fvertk/DuckSlaughterZ
        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>();
        }
コード例 #2
0
ファイル: Game06.cs プロジェクト: fvertk/DuckSlaughterZ
        /*
         * Called when game should begin
         */
        void beginGame()
        {
            graphics.PreferredBackBufferHeight = 800;
            graphics.PreferredBackBufferWidth  = 600;
            graphics.ApplyChanges();

            deterministicGame.Initialize();
            latency     = 1;
            lrFrame     = 1;
            previousLRF = 0;
            secondLRF   = 0;
            frames      = new Dictionary <int, frame>();

            frameNumber  = 0;
            stallCounter = 0;
            gameStarted  = true;
            if (isHost)
            {
                networkSession.StartGame();
            }

            players      = networkSession.AllGamers;
            pid          = new int[4];
            myIdentifier = getIdentifier(networkSession.LocalGamers[0].Id);

            others = new player[players.Count];

            for (int i = 0; i < players.Count; i++)
            {
                pid[i] = (int)players[i].Id;

                others[i] = new player(players[i], getIdentifier(players[i].Id), deterministicGame);
            }

            Array.Sort(pid);

            myPlayer = null;
            for (int i = 0; i < others.Length; i++)
            {
                if (others[i].me == myIdentifier)
                {
                    myPlayer = others[i];
                }
            }
        }