예제 #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()
        {
            this.IsMouseVisible = true;

            response = "";

            // Initialize the GoblinXNA framework
            State.InitGoblin(graphics, Content, "");

            // Initialize the scene graph
            scene = new Scene(this);

            State.EnableNetworking = true;
            State.IsServer = false;

            // Set up the lights used in the scene
            CreateLights();

            // Set up the camera, which defines the eye location and viewing frustum
            CreateCamera();

            // Create 3D objects
            CreateObject();

            // Use per pixel lighting for better quality (If you using non NVidia graphics card,
            // setting this to true may reduce the performance significantly)
            scene.PreferPerPixelLighting = true;

            // Create a network object that contains mouse press information to be
            // transmitted over network
            networkObj = new MessageNetworkObject();

            // When a mouse press event is sent from the other side, then call "ShootBox"
            // function
            networkObj.CallbackFunc = UpdateMessage;

            // Create a network handler for handling the network transfers
            NetworkHandler networkHandler = new NetworkHandler();

            if (3==4)
                networkHandler.NetworkServer = new LidgrenServer("InfoOverload", 14242);
            else
            {
                // Create a client that connects to the local machine assuming that both
                // the server and client will be running on the same machine. In order to
                // connect to a remote machine, you need to either pass the host name or
                // the IP address of the remote machine in the 3rd parameter.
                client = new LidgrenClient("InfoOverload", 14242, "Localhost");

                // If the server is not running when client is started, then wait for the
                // server to start up.
                client.WaitForServer = true;

                networkHandler.NetworkClient = client;
            }

            scene.BackgroundColor = Color.Black;

            // Assign the network handler used for this scene
            scene.NetworkHandler = networkHandler;

            // Add the mouse network object to the scene graph, so it'll be sent over network
            // whenever ReadyToSend is set to true.
            scene.NetworkHandler.AddNetworkObject(networkObj);

            //scene.PhysicsEngine = new NewtonPhysics();
            //Set to false for window
            graphics.IsFullScreen = fullScreen;
            graphics.ApplyChanges();

            // Add a keyboard press handler for user input
            KeyboardInput.Instance.KeyPressEvent += new HandleKeyPress(KeyPressHandler);

            State.ShowNotifications = false;
            base.Initialize();
        }
예제 #2
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()
        {
            this.IsMouseVisible = true;

            response = "";

            // Initialize the GoblinXNA framework
            State.InitGoblin(graphics, Content, "");

            // Initialize the scene graph
            scene = new Scene(this);

            State.EnableNetworking = true;
            State.IsServer         = false;

            // Set up the lights used in the scene
            CreateLights();

            // Set up the camera, which defines the eye location and viewing frustum
            CreateCamera();

            // Create 3D objects
            CreateObject();

            // Use per pixel lighting for better quality (If you using non NVidia graphics card,
            // setting this to true may reduce the performance significantly)
            scene.PreferPerPixelLighting = true;

            // Create a network object that contains mouse press information to be
            // transmitted over network
            networkObj = new MessageNetworkObject();

            // When a mouse press event is sent from the other side, then call "ShootBox"
            // function
            networkObj.CallbackFunc = UpdateMessage;


            // Create a network handler for handling the network transfers
            NetworkHandler networkHandler = new NetworkHandler();

            if (3 == 4)
            {
                networkHandler.NetworkServer = new LidgrenServer("InfoOverload", 14242);
            }
            else
            {
                // Create a client that connects to the local machine assuming that both
                // the server and client will be running on the same machine. In order to
                // connect to a remote machine, you need to either pass the host name or
                // the IP address of the remote machine in the 3rd parameter.
                client = new LidgrenClient("InfoOverload", 14242, "Localhost");

                // If the server is not running when client is started, then wait for the
                // server to start up.
                client.WaitForServer = true;

                networkHandler.NetworkClient = client;
            }

            scene.BackgroundColor = Color.Black;

            // Assign the network handler used for this scene
            scene.NetworkHandler = networkHandler;

            // Add the mouse network object to the scene graph, so it'll be sent over network
            // whenever ReadyToSend is set to true.
            scene.NetworkHandler.AddNetworkObject(networkObj);

            //scene.PhysicsEngine = new NewtonPhysics();
            //Set to false for window
            graphics.IsFullScreen = fullScreen;
            graphics.ApplyChanges();

            // Add a keyboard press handler for user input
            KeyboardInput.Instance.KeyPressEvent += new HandleKeyPress(KeyPressHandler);

            State.ShowNotifications = false;
            base.Initialize();
        }