/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public void Update(GameTime gameTime) { // Read input. Vector2 screenDim = _spriteBatch.GetScreenDimensions(); _input = Input.GetState(screenDim, _renderer.RenderState.ScreenToWorldCoordinates); _renderer.RenderState.UpdateAspectRatio(screenDim); _tickTime = gameTime.ElapsedGameTime.TotalMilliseconds; if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.Q)) { IsRunning = false; return; } if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.S) && !_startServer) { _startServer = true; _trollServer = new Network.Server(6667); _trollServer.start(); } if (_input.IsActive(Keys.LeftShift) && _input.IsActive(Keys.S) && _startServer) { _trollServer.stop(); _startServer = false; } if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.C) && !_startClient) { _startClient = true; _trollClient= new Network.Client("192.168.0.3",6667); _trollClient.start(); } if (_input.IsActive(Keys.LeftShift) && _input.IsActive(Keys.C) && _startClient) { _trollClient.stop(); _startClient = false; } // It is important that _worldDate is updated first of all, // since the other components depend on it being in sync. _worldDate.Update(gameTime); // We update the views in reverse order, // because if the input state gets updated by an entity, // enties behind (meaning draw before, meaning having a higher index in _views) it // should get notified, but not entities in front of it. foreach (IView view in _views.Reverse()) { view.Update(_input); } foreach (IModel entity in _models) { entity.Update(_worldDate); } UpdateCamera(); Debug.WriteToScreen("Slow" , gameTime.IsRunningSlowly ? "Yes" : "No"); Debug.WriteToScreen("Zoom" , _renderer.RenderState.Camera.Zoom); Debug.WriteToScreen("Mouse" , _input.ScreenMouse); Debug.WriteToScreen("Mouse rel", _input.MouseRelativeToCenter); }