Exemplo n.º 1
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            ICollection <IGameObject> renderedObjects = GameObjects.Where(e => _camera.IsRendered(e)).ToList();

            spriteBatch.Begin(sortMode: SpriteSortMode.BackToFront, samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetViewMatrix());
            foreach (IVisibleObject gameObject in InterfaceListUtil.GameObjectListToVisibleObjectList(renderedObjects))
            {
                gameObject.Draw(spriteBatch);
            }
            if (Player1Character.Health > 0)
            {
                _energyMarker = new EnergyMarker(new Vector2(_camera.CameraPosition.X + 8, _camera.CameraPosition.Y + 8));
                _energyMarker.Draw(spriteBatch);
                spriteBatch.DrawString(_defaultFont, "" + Player1Character.Health + "", new Vector2(_camera.CameraPosition.X + 58, _camera.CameraPosition.Y + 3), Color.White);
                if (Player1Character.HasMissileUpgrade && Player1Character.Missiles > 0)
                {
                    _missileMarker = new MissileMarker(new Vector2(_camera.CameraPosition.X + 8, _camera.CameraPosition.Y + 24));
                    _missileMarker.Draw(spriteBatch);
                    spriteBatch.DrawString(_defaultFont, "" + Player1Character.Missiles + "", new Vector2(_camera.CameraPosition.X + 58, _camera.CameraPosition.Y + 19), Color.White);
                }
            }
            if (Player2Character.Health > 0)
            {
                _energyMarker = new EnergyMarker(new Vector2(_camera.CameraPosition.X + _camera.Viewport.Width * (1 / _camera.Zoom) - 86, _camera.CameraPosition.Y + 8));
                _energyMarker.Draw(spriteBatch);
                spriteBatch.DrawString(_defaultFont, "" + Player2Character.Health + "", new Vector2(_camera.CameraPosition.X + _camera.Viewport.Width * (1 / _camera.Zoom) - 36, _camera.CameraPosition.Y + 3), Color.White);
                if (Player2Character.HasMissileUpgrade && Player2Character.Missiles > 0)
                {
                    _missileMarker = new MissileMarker(new Vector2(_camera.CameraPosition.X + _camera.Viewport.Width * (1 / _camera.Zoom) - 86, _camera.CameraPosition.Y + 24));
                    _missileMarker.Draw(spriteBatch);
                    spriteBatch.DrawString(_defaultFont, "" + Player2Character.Missiles + "", new Vector2(_camera.CameraPosition.X + _camera.Viewport.Width * (1 / _camera.Zoom) - 36, _camera.CameraPosition.Y + 19), Color.White);
                }
            }
            spriteBatch.End();
        }
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            ICollection <IGameObject> renderedObjects = GameObjects.Where(e => _camera.IsRendered(e)).ToList();

            spriteBatch.Begin(sortMode: SpriteSortMode.BackToFront, samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetViewMatrix());
            foreach (IVisibleObject gameObject in InterfaceListUtil.GameObjectListToVisibleObjectList(renderedObjects))
            {
                gameObject.Draw(spriteBatch);
            }
            for (int i = 0; i < Players.Length; i++)
            {
                IPlayer player = Players[i];
                if (player.Health > 0)
                {
                    _energyMarker = new EnergyMarker(new Vector2(_camera.CameraPosition.X + 8 + (100 * i), _camera.CameraPosition.Y + 8));
                    _energyMarker.Draw(spriteBatch);
                    spriteBatch.DrawString(_defaultFont, "" + player.Health + "", new Vector2(_camera.CameraPosition.X + 58 + (100 * i), _camera.CameraPosition.Y + 3), Color.White);
                    if (player.HasMissileUpgrade && player.Missiles > 0)
                    {
                        _missileMarker = new MissileMarker(new Vector2(_camera.CameraPosition.X + 8 + (100 * i), _camera.CameraPosition.Y + 24));
                        _missileMarker.Draw(spriteBatch);
                        spriteBatch.DrawString(_defaultFont, "" + player.Missiles + "", new Vector2(_camera.CameraPosition.X + 58 + (100 * i), _camera.CameraPosition.Y + 19), Color.White);
                    }
                }
            }
            spriteBatch.End();
        }