Beispiel #1
0
        public void DrawBloom(Camera2D camera, BloomComponent bloom, bool isBloom)
        {
            _background.Draw(false, Camera.Pos);

            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend,
                               null,
                               null,
                               null,
                               null,
                               Camera.GetTransformation(_spriteBatch.GraphicsDevice));

            _spaceManager.Draw(_spriteBatch, Camera.Pos, Camera.Zoom);


            _spriteBatch.End();

            // Draw particles in different spritebatch. Otherwise they look absolutely awful.
            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Additive,
                               null,
                               null,
                               null,
                               null,
                               Camera.GetTransformation(_spriteBatch.GraphicsDevice));

            _particleManager.Draw(camera);

            _spriteBatch.End();

            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend,
                               null,
                               null,
                               null,
                               null,
                               Camera.GetTransformation(_spriteBatch.GraphicsDevice));

            foreach (var s in _spaceViewModel.Structures)
            {
                switch (s.StructureType)
                {
                default:
                    s.Draw(camera);
                    break;
                }
            }

            _floatyAreaObjectManager.Draw(_spriteBatch, camera);
            _projectileManager.Draw(camera);
            _clientShipManager.Draw(camera);
            _drawShipNames();

            _spriteBatch.End();
        }
        public void Draw(Camera2D camera)
        {
            //if (SettingsManager.isBloom)
            //_bloom.CheckBackbufferSize(_spriteBatch);
            //_bloom.BeginDraw(_spriteBatch);
            ////_planetStateManager.Draw(camera);
            //_bloom.Draw(_spriteBatch);
            //_selectionManager.Draw(camera);

            // Draw the tiles efficiently, with the camera viewport.
            _spriteBatch.Begin(
                SpriteSortMode.Deferred,
                BlendState.AlphaBlend,
                SamplerState.PointClamp,
                null,
                null,
                null,
                Camera.GetTransformation(_spriteBatch.GraphicsDevice));

            ViewModel.Level.DrawTiles(Camera);

            _spriteBatch.End();

            // Draw everything else, with the camera viewport.
            _spriteBatch.Begin(
                SpriteSortMode.BackToFront, BlendState.Additive,
                null,
                null,
                null,
                null,
                Camera.GetTransformation(_spriteBatch.GraphicsDevice));

            _particleManager.Draw(camera);

            _spriteBatch.End();

            _spriteBatch.Begin(
                SpriteSortMode.FrontToBack, BlendState.AlphaBlend,
                SamplerState.AnisotropicClamp,
                null,
                null,
                null,
                Camera.GetTransformation(_spriteBatch.GraphicsDevice));

            foreach (var s in ViewModel.Structures)
            {
                switch (s.StructureType)
                {
                case StructureTypes.LaserTurret:
                    ((Turret)s).Draw(camera);
                    break;

                default:
                    s.Draw(camera);
                    break;
                }
            }

            Debugging.textDrawingService.DrawTextToScreenRight(25, "Projectiles: " + _projectileManager.GetProjectileCount());
            Debugging.textDrawingService.DrawTextToScreenRight(26, "Structures: " + ViewModel.Structures.Count());
            Debugging.textDrawingService.DrawTextToScreenRight(27, "Latency: " + (MainNetworkingManager.LastLatency * 1000) + "ms");
            Debugging.textDrawingService.DrawTextToScreenRight(28, "Player Speed: " + Debugging.playerShipManager.PlayerShip.LinearVelocity.Length());
            Debugging.textDrawingService.DrawTextToScreenRight(29, "Player Location: " + Debugging.playerShipManager.PlayerShip.Position.ToString());

            _projectileManager.Draw(camera);

            _clientShipManager.Draw(camera);
            _drawShipNames();
            _floatyAreaObjectManager.Draw(camera);

            // Temporary
            if (ViewModel.ColonizeMode)
            {
                var mousePosition = _uiConversionService.PlanetMousePositionToDisplayUnits(
                    _textureManager.Ground.Width,
                    _textureManager.Ground.Height);

                _spriteBatch.Draw(_textureManager.Penguin, mousePosition, Color.White);
            }

            _spriteBatch.End();

            // Draw some debug text, relative to the screen's pixels.
            _spriteBatch.Begin();

#if ADMIN
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 8, "Bullets: " + GetProjectileCount());
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 9, "FPS: " + Debugging.textDrawingService.getFPS());
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 25, "Bullets: " + _projectileManager.GetProjectileCount());
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 26, "Structures: " + _structures.Count);
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 27, "Latency: " + (MainNetworkingManager.LastLatency * 1000) + "ms");
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 28, "NPCs: " + Debugging.SimulationManager.GetSimulatedShips().Count);
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 29, "Player Speed: " + LegacyStatics.playerShipManager.PlayerShip.LinearVelocity.Length());
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 30, "Player Location: " + LegacyStatics.playerShipManager.PlayerShip.Position.ToString());
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 31, "Mouse Location: " + MousePosToSimUnits(_clientShipManager.PlayerShip, _spriteBatch));
            Debugging.textDrawingService.DrawTextToScreenRight(_spriteBatch, 32, "Bodies: " + _physicsManager.World.BodyList.Count);
#endif

            _spriteBatch.End();
        }