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 void Draw(GameCamera camera) { result.X = (int)(position.X); // / (Space394Game.GameInstance.DefaultViewPort.Width / camera.getViewPort().Width)); result.Y = (int)(position.Y); // / (Space394Game.GameInstance.DefaultViewPort.Height / camera.getViewPort().Height)); result.Width = texture.Width / (Space394Game.GameInstance.DefaultViewPort.Width / camera.ViewPort.Width); result.Height = texture.Height / (Space394Game.GameInstance.DefaultViewPort.Height / camera.ViewPort.Height); Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; SpriteBatch spriteBatch = Space394Game.GameInstance.SpriteBatch; spriteBatch.Begin(); spriteBatch.Draw(texture, result, Color.White); spriteBatch.End(); constructStrip(); /* foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Apply(); Space394Game.GameInstance.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.TriangleStrip, points, 0, // vertex buffer offset to add to each element of the index buffer CORNERS, // number of vertices in pointList triangleStripIndices, // the index buffer 0, // first index element to read EDGES - 1 // number of primitives to draw ); break; } */ Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; // Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort; }
public void Draw(GameCamera camera) { result.X = (int)(position.X / (Space394Game.GameInstance.DefaultViewPort.Width / camera.ViewPort.Width)); result.Y = (int)(position.Y / (Space394Game.GameInstance.DefaultViewPort.Height / camera.ViewPort.Height)); result.Width = (int)(texture.Width / (Space394Game.GameInstance.DefaultViewPort.Width / camera.ViewPort.Width) * width); result.Height = (int)(texture.Height / (Space394Game.GameInstance.DefaultViewPort.Height / camera.ViewPort.Height) * height); Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; SpriteBatch spriteBatch = Space394Game.GameInstance.SpriteBatch; spriteBatch.Begin(); spriteBatch.Draw(texture, result, color); spriteBatch.End(); Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort; }
public void DrawAlreadyBegunMaintainRatio(GameCamera camera) { int divisor = (Space394Game.GameInstance.DefaultViewPort.Height / camera.ViewPort.Height); result.X = (int)((position.X / (Space394Game.GameInstance.DefaultViewPort.Width / camera.ViewPort.Width)) * widthConversion); result.Y = (int)((position.Y / (Space394Game.GameInstance.DefaultViewPort.Height / camera.ViewPort.Height)) * heightConversion); result.Width = (int)((texture.Width / divisor * width) * widthConversion); result.Height = (int)((texture.Height / divisor * height) * heightConversion); SpriteBatch spriteBatch = Space394Game.GameInstance.SpriteBatch; spriteBatch.Draw(texture, result, color); Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; }
public void DrawTray(GameCamera camera) { Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; SpriteBatch batch = Space394Game.GameInstance.SpriteBatch; batch.Begin(); esxolusLogo.DrawAlreadyBegunMaintainRatio(camera); halkLogo.DrawAlreadyBegunMaintainRatio(camera); timerBox.DrawAlreadyBegunMaintainRatio(camera); if (player.ObjectivesDrawActive && !(player.CurrentState is TeamSelectPlayerState || player.CurrentState is SpectatorPlayerState)) { objectives.DrawAlreadyBegunMaintainRatio(camera); } else { } for (int i = 0; i < initialShipsEsx; i++) { esxolusCapitalShip.Position = esxolusShipPositions[i]; SpawnShip ship = ((GameScene)Space394Game.GameInstance.CurrentScene).getSpawnShip(Ship.Team.Esxolus, i); float ratio = ship.Health / ship.MaxHealth; #region Decide color Color color = new Color(50, 50, 50); if (ratio == 1.0f) { color = new Color(0, 167, 58); } else if (ratio >= .9f) { color = new Color(15, 179, 0); } else if (ratio >= .8f) { color = new Color(54, 179, 0); } else if (ratio >= .7f) { color = new Color(92, 179, 0); } else if (ratio >= .6f) { color = new Color(131, 179, 0); } else if (ratio >= .5f) { color = new Color(173, 179, 0); } else if (ratio >= .4f) { color = new Color(179, 145, 0); } else if (ratio >= .3f) { color = new Color(179, 101, 0); } else if (ratio >= .2f) { color = new Color(179, 65, 0); } else if (ratio >= .1f) { color = new Color(179, 27, 0); } else { /* Dark gray */ } #endregion esxolusCapitalShip.Color = color; esxolusCapitalShip.DrawAlreadyBegunMaintainRatio(camera); } for (int i = 0; i < initialShipsHalk; i++) { halkCapitalShip.Position = halkShipPositions[i]; SpawnShip ship = ((GameScene)Space394Game.GameInstance.CurrentScene).getSpawnShip(Ship.Team.Halk, i); float ratio = ship.Health / ship.MaxHealth; #region Decide color Color color = new Color(50, 50, 50); if (ratio == 1.0f) { color = new Color(0, 167, 58); } else if (ratio >= .9f) { color = new Color(15, 179, 0); } else if (ratio >= .8f) { color = new Color(54, 179, 0); } else if (ratio >= .7f) { color = new Color(92, 179, 0); } else if (ratio >= .6f) { color = new Color(131, 179, 0); } else if (ratio >= .5f) { color = new Color(173, 179, 0); } else if (ratio >= .4f) { color = new Color(179, 145, 0); } else if (ratio >= .3f) { color = new Color(179, 101, 0); } else if (ratio >= .2f) { color = new Color(179, 65, 0); } else if (ratio >= .1f) { color = new Color(179, 27, 0); } else { /* Dark gray */ } #endregion halkCapitalShip.Color = color; halkCapitalShip.DrawAlreadyBegunMaintainRatio(camera); } int index = 0; float timer = ((GameScene)Space394Game.GameInstance.CurrentScene).WaveTimer; int timerInt = (int)(timer * 10000); timerInt -= (timerInt / 1000000); batch.DrawString(font, "" + ((timerInt % 1000000) / 100000), numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); timerInt -= (timerInt / 100000); batch.DrawString(font, "" + ((timerInt % 100000) / 10000), numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); timerInt -= (timerInt / 10000); batch.DrawString(font, ":", numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); batch.DrawString(font, "" + ((timerInt % 10000) / 1000), numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); timerInt -= (timerInt / 1000); batch.DrawString(font, "" + ((timerInt % 1000) / 100), numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); timerInt -= (timerInt / 100); batch.DrawString(font, ":", numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); batch.DrawString(font, "" + ((timerInt % 100) / 10), numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); timerInt -= (timerInt / 10); batch.DrawString(font, "" + (((timerInt % 10)) / 1), numbers[index++], Color.Lime, 0, Vector2.Zero, fontScale, SpriteEffects.None, 0); // timerInt -= (timerInt / 1); batch.End(); Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort; }
public void DrawShipHUD(GameCamera camera) { Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; SpriteBatch spriteBatch = Space394Game.GameInstance.SpriteBatch; spriteBatch.Begin(); if (takingHit) { takingHitSplash.setAlpha((byte)hitAlpha); takingHitSplash.DrawAlreadyBegunMaintainRatio(camera); } else { } hudBase.DrawAlreadyBegunMaintainRatio(camera); if (player.PlayerShip is EsxolusAssaultFighter) { esxolusMissileIcon.DrawAlreadyBegunMaintainRatio(camera); } else if (player.PlayerShip is EsxolusBomber) { esxolusBombIcon.DrawAlreadyBegunMaintainRatio(camera); } else if (player.PlayerShip is EsxolusInterceptor) { esxolusHexIcon.DrawAlreadyBegunMaintainRatio(camera); } else if (player.PlayerShip is HalkAssaultFighter) { halkMissileIcon.DrawAlreadyBegunMaintainRatio(camera); } else if (player.PlayerShip is HalkBomber) { halkBombIcon.DrawAlreadyBegunMaintainRatio(camera); } else if (player.PlayerShip is HalkInterceptor) { halkInterceptorMissileIcon.DrawAlreadyBegunMaintainRatio(camera); } else { } int numHealth = (int)(player.PlayerShip.Health / player.PlayerShip.MaxHealth * HEALTH); byte alphaHealth = (byte)(((player.PlayerShip.Health / player.PlayerShip.MaxHealth) % HEALTH) * 255); int i; for (i = 0; i < numHealth; i++) { healthBar[i].setAlpha(255); healthBar[i].DrawAlreadyBegunMaintainRatio(camera); } if (i < HEALTH && i > 0) { //healthBar[i].setAlpha(alphaHealth); healthBar[i].DrawAlreadyBegunMaintainRatio(camera); } else { } int numShields = (int)(player.PlayerShip.Shields / player.PlayerShip.MaxShields * SHIELDS); byte alphaShields = (byte)(((player.PlayerShip.Shields / player.PlayerShip.MaxShields) % SHIELDS) * 255); for (i = 0; i < numShields; i++) { shieldBar[i].setAlpha(255); shieldBar[i].DrawAlreadyBegunMaintainRatio(camera); } if (i < SHIELDS && i > 0) { //shieldBar[i].setAlpha(alphaShields); shieldBar[i].DrawAlreadyBegunMaintainRatio(camera); } else { } int numHeat = (int)(player.PlayerShip.Heat / player.PlayerShip.getOverheatHeat() * HEAT); byte alphaHeat = (byte)(((player.PlayerShip.Heat / player.PlayerShip.getOverheatHeat()) % HEAT) * 255); for (i = 0; i < numHeat; i++) { heatBar[i].setAlpha(255); heatBar[i].DrawAlreadyBegunMaintainRatio(camera); } if (i < HEAT && i > 0) { //heatBar[i].setAlpha(alphaHeat); heatBar[i].DrawAlreadyBegunMaintainRatio(camera); } else { } if (player.PlayerShip.Heat >= (player.PlayerShip.HeatWarningThreshold)) { warning.DrawAlreadyBegunMaintainRatio(camera); if (player.PlayerShip.Heat >= (player.PlayerShip.HeatDamageThreshold)) { overheating.DrawAlreadyBegunMaintainRatio(camera); } else { } } else { } int index = 0; int num; int secondaries = player.PlayerShip.SecondaryAmmo; int secondariesTotal = secondaries; secondaries -= (secondaries / 1000) * 1000; if (secondariesTotal > 99) { num = ((secondaries % 1000) / 100); secondaryNumbersTextures[num].Position = secondaryNumbers[index]; secondaryNumbersTextures[num].DrawAlreadyBegunMaintainRatio(camera); // spriteBatch.DrawString(font, "" + ((secondaries % 1000) / 100), secondaryNumbers[index++], Color.White); secondaries -= (secondaries / 100) * 100; } else { } index++; if (secondariesTotal > 9) { num = ((secondaries % 100) / 10); secondaryNumbersTextures[num].Position = secondaryNumbers[index]; secondaryNumbersTextures[num].DrawAlreadyBegunMaintainRatio(camera); // spriteBatch.DrawString(font, "" + ((secondaries % 100) / 10), secondaryNumbers[index++], Color.White); secondaries -= (secondaries / 10) * 10; } else { } index++; num = (((secondaries % 10)) / 1); secondaryNumbersTextures[num].Position = secondaryNumbers[index]; secondaryNumbersTextures[num].DrawAlreadyBegunMaintainRatio(camera); // spriteBatch.DrawString(font, "" + (((secondaries % 10)) / 1), secondaryNumbers[index++], Color.White); reticule.DrawAlreadyBegunMaintainRatio(camera); if (drawConfirmed) { hitConfirmedReticule.DrawAlreadyBegunMaintainRatio(camera); } else { } spriteBatch.End(); Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort; }
public void Draw(GameCamera camera) { if (player.PlayerShip != null && player.PlayerShip.PlayerControlled) { foreach (SceneObject item in Space394Game.GameInstance.CurrentScene.SceneObjects.Values) { if (item is Ship && item.Health > 0) { if (((PlayerCamera)camera).PlayerShip != null) { ((Ship)item).DrawReticule(camera); } else { } } else { } } } else { } }
public float getScaleByDistance(GameCamera _camera) { float newScale = RETICLE_RESIZE; // Furtheset if (modelLevel == 2) { newScale *= 1.25f; } // Close else if (modelLevel == 1) { newScale *= 0.25f; } // Not Drawn Anyways //else if (modelLevel == 0) //{ } else { } return newScale; }
public Texture2D getMarkerTex(GameCamera camera) { Texture2D rTexture; if (((PlayerCamera)camera).PlayerShip.ShipTeam == this.ship.ShipTeam) { rTexture = friendlyMarkerTex; } else { if (((PlayerCamera)camera).PlayerShip.MyPlayer != null) { if (ship is SpawnShipPiece && ((PlayerCamera)camera).PlayerShip.MyPlayer.ObjectivesDrawActive) { rTexture = objectiveMarkerTex; } else { rTexture = enemyMarkerTex; } } else { rTexture = enemyMarkerTex; } } return rTexture; }
public void DrawReticleOnly(GameCamera camera, Quaternion playerShipRotation) { if (ship.Active && ship != ((PlayerCamera)camera).PlayerShip) { float scaleSize = getScaleByDistance(camera); Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.None; barGraphics.basicEffect.World = Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position); barGraphics.basicEffect.View = camera.ViewMatrix; barGraphics.basicEffect.Projection = camera.ProjectionMatrix; foreach (EffectPass pass in barGraphics.basicEffect.CurrentTechnique.Passes) { pass.Apply(); barGraphics.basicEffect.World = Matrix.CreateScale(scaleSize) * Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position + offsetFromShip(2, playerShipRotation)); DrawQuad(getMarkerTex(camera), barGraphics.basicEffect.World, barGraphics.basicEffect.View, barGraphics.basicEffect.Projection, 1); break; } Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort; Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; } }
public void DrawRescaling(GameCamera camera, Quaternion playerShipRotation) { if (ship.Active && ship != ((PlayerCamera)camera).PlayerShip) { Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.None; float scale = Math.Max(MIN_SCALE, Math.Min(Vector3.Distance(ship.Position, camera.Position) * SCALE_FACTOR, MAX_SCALE)); barGraphics.basicEffect.View = camera.ViewMatrix; barGraphics.basicEffect.Projection = camera.ProjectionMatrix; foreach (EffectPass pass in barGraphics.basicEffect.CurrentTechnique.Passes) { pass.Apply(); barGraphics.basicEffect.World = Matrix.CreateScale(scale) * Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position + offsetFromShip(2, playerShipRotation)); DrawQuad(getMarkerTex(camera), barGraphics.basicEffect.World, barGraphics.basicEffect.View, barGraphics.basicEffect.Projection, 1); } Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort; Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; } }
public void Draw(GameCamera camera, Quaternion playerShipRotation) { if (ship.Active && ship != ((PlayerCamera)camera).PlayerShip) { Space394Game.GameInstance.GraphicsDevice.Viewport = camera.ViewPort; Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.None; barGraphics.basicEffect.World = Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position); // + offsetFromShip(0,playerShipRotation)); barGraphics.basicEffect.View = camera.ViewMatrix; barGraphics.basicEffect.Projection = camera.ProjectionMatrix; foreach (EffectPass pass in barGraphics.basicEffect.CurrentTechnique.Passes) { pass.Apply(); #region old Code, just in case /* Space394Game.GameInstance.GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>( PrimitiveType.LineStrip, points, 0, // vertex buffer offset to add to each element of the index buffer CORNERS, // number of vertices in pointList lineListIndices, // the index buffer 0, // first index element to read EDGES - 1 // number of primitives to draw ); */ /* Space394Game.GameInstance.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalTexture>( PrimitiveType.TriangleList, quad.Vertices, 0, 4, quad.Indexes, 0, 2); */ // shieldBarTex.setPosition(new Vector2((getPosition() + offsetFromShip()).X, (getPosition() + offsetFromShip()).Y)); // SpriteBatch spriteBatch = Space394Game.GameInstance.SpriteBatch; // spriteBatch.Begin(); // shieldBarTex.DrawAlreadyBegunMaintainRatio(camera); /* barGraphics.basicEffect.World = Matrix.CreateBillboard(position, camera.getPosition(), camera.getUpVect(), camera.getRotation()); /* Matrix.CreateFromQuaternion(rotation) * // Matrix.CreateTranslation(position + offsetFromShip(0,playerShipRotation)); //getRotation())); */ #endregion /* Other-> Typically Objective Marker currently */ barGraphics.basicEffect.World = Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position + offsetFromShip(2, playerShipRotation)); DrawQuad(getMarkerTex(camera), barGraphics.basicEffect.World, barGraphics.basicEffect.View, barGraphics.basicEffect.Projection, 1); // Shield Bar barGraphics.basicEffect.World = Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position + offsetFromShip(0, playerShipRotation)); DrawQuad(shieldBarTex, barGraphics.basicEffect.World, barGraphics.basicEffect.View, barGraphics.basicEffect.Projection, 1); // Health Bar barGraphics.basicEffect.World = Matrix.CreateFromQuaternion(rotation) * Matrix.CreateTranslation(position + offsetFromShip(1, playerShipRotation)); DrawQuad(healthBarTex, barGraphics.basicEffect.World, barGraphics.basicEffect.View, barGraphics.basicEffect.Projection, 1); break; } Space394Game.GameInstance.GraphicsDevice.Viewport = Space394Game.GameInstance.DefaultViewPort; Space394Game.GameInstance.GraphicsDevice.DepthStencilState = DepthStencilState.Default; } }