public void Draw(GameCamera camera) { // DrawQuad(); quad = new TextureQuad(Vector3.Zero, Vector3.UnitZ, Vector3.Up, 2, 2); quadEffect = new BasicEffect(Space394Game.GameInstance.GraphicsDevice); quadEffect.AmbientLightColor = new Vector3(0.8f, 0.8f, 0.8f); quadEffect.LightingEnabled = true; quadEffect.World = Matrix.Identity; /* quadEffect.View = Space394Game.GameInstance.CurrentScene.getCamera().getTarget(0; quadEffect.Projection = this.Projection; quadEffect.TextureEnabled = true; quadEffect.Texture = someTexture; */ SpriteBatch spriteBatch = Space394Game.GameInstance.SpriteBatch; spriteBatch.Begin(); spriteBatch.Draw(barsBackground, Vector2.Zero, Color.White); // spriteBatch.Draw(healthTexture, GameWindow spriteBatch.Draw(barsBackground, Vector2.Zero, Color.White); spriteBatch.End(); Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; }
public HUDUnit(Ship _ship, int _width, int _height, int _depth) { if (!barGraphics.initialized) { barGraphics.rasterizerState = new RasterizerState(); barGraphics.rasterizerState.FillMode = FillMode.WireFrame; barGraphics.rasterizerState.CullMode = CullMode.None; barGraphics.vertexDeclaration = new VertexDeclaration(new VertexElement[] { new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement(12, VertexElementFormat.Color, VertexElementUsage.Color, 0) } ); barGraphics.basicEffect = new BasicEffect(Space394Game.GameInstance.GraphicsDevice); barGraphics.basicEffect.VertexColorEnabled = true; barGraphics.initialized = true; } else { } ship = _ship; width = _width; height = _height; depth = _depth; shieldBarTex = ContentLoadManager.loadTexture("Textures/ShieldBar"); healthBarTex = ContentLoadManager.loadTexture("Textures/HealthBar"); barBackgroundTex = ContentLoadManager.loadTexture("Textures/BackBar"); barMaxWidth = barBackgroundTex.Width; enemyMarkerTex = ContentLoadManager.loadTexture("Textures/enemy_marker"); friendlyMarkerTex = ContentLoadManager.loadTexture("Textures/friendly_marker"); objectiveMarkerTex = ContentLoadManager.loadTexture("Textures/objective_marker"); alphaEffect = new AlphaTestEffect(Space394Game.GameInstance.GraphicsDevice); alphaEffect.AlphaFunction = CompareFunction.Greater; alphaEffect.ReferenceAlpha = 128; // Preallocate an array of four vertices. vertices = new VertexPositionColorTexture[4]; double totalScale = 0.075; int hudScaleX = ((int)(20 * totalScale)); int hudScaleY = ((int)(4 * totalScale)); vertices[0].Position = new Vector3(hudScaleX, hudScaleY, 0); vertices[1].Position = new Vector3(-hudScaleX, hudScaleY, 0); vertices[2].Position = new Vector3(hudScaleX, -hudScaleY, 0); vertices[3].Position = new Vector3(-hudScaleX, -hudScaleY, 0); rotation = ship.Rotation * Quaternion.CreateFromYawPitchRoll(0, MathHelper.ToRadians(90f), 0); up = Vector3.Transform(Vector3.Up, rotation); quad = new TextureQuad(Vector3.Zero, Vector3.Backward, Vector3.Up, 1, 1); }