private MeterBar Create1DMeter(EPointF ptLoc, string prop, float max) { MeterBar bar = new MeterBar(); bar.Rect = new ERectangleF(ptLoc.X, ptLoc.Y, 100, 8); bar.MaxValue = max; bar.SetAutoFetch(this._car, prop); return(bar); }
/// <summary> /// Creates the GameScene scene /// </summary> /// <param name="game">Current game reference</param> /// <param name="spriteBatch">spriteBatch to draw scene</param> public GameScene(Game game, SpriteBatch spriteBatch) : base(game) { this.spriteBatch = spriteBatch; inputNameString = new KbInputString(Game, spriteBatch, resources.MonoFont, new Vector2(GraphicsDevice.Viewport.Width / 2f, GraphicsDevice.Viewport.Height / 2f + resources.MonoFont.LineSpacing * 2), Color.Wheat, SimpleString.TextAlignH.Middle); // Add the infinite terrain (which also does gas cans) var tempTerrain = new Terrain(Game, spriteBatch, GraphicsDevice.Viewport.Bounds.Width / 3f, 50, 80, 1, 0, 4, ColourSchemes.brown, new Vector2(0, GraphicsDevice.Viewport.Bounds.Height * 0.75f)); Components.Add(terrain = new InfiniteTerrain(Game, spriteBatch, tempTerrain, 3, 3)); // Add our UFO this.Components.Add(ufo = new UFO(Game, spriteBatch, new Vector2(50, terrain.ExtremeHeightAt(25, 50, false)))); // Add distance string Components.Add( distance = new SimpleString(game, spriteBatch, resources.BoldFont, new Vector2(20, 20), "Distance: 0", ColourSchemes.pink)); // Create Speed meter & string Components.Add( meterSpeed = new MeterBar( new SimpleString(game, spriteBatch, resources.RegularFont, new Vector2(215, 70), "", Color.Black, SimpleString.TextAlignH.Right), new Rectangle(20, 70, 200, resources.RegularFont.LineSpacing), 0, ufo.MaxVelocity)); Components.Add(new SimpleString(game, spriteBatch, resources.RegularFont, new Vector2(25, 70), "Speed", Color.Black)); // Create Gas meter & string Components.Add( meterGas = new MeterBar( new SimpleString(game, spriteBatch, resources.RegularFont, new Vector2(215, 120), "", Color.Black, SimpleString.TextAlignH.Right), new Rectangle(20, 120, 200, resources.RegularFont.LineSpacing), 0, ufo.Gas)); Components.Add(new SimpleString(game, spriteBatch, resources.RegularFont, new Vector2(25, 120), "Gas: ", Color.Black)); // Create collision manager Components.Add(collisionManager = new CollisionManager(Game)); collisionManager.Add(ufo); // Create explosion explosion = new Explosion(game, spriteBatch, resources.Explosion, Vector2.Zero, 3); this.Components.Add(explosion); // Death sound deathSouthIns = resources.deathSound.CreateInstance(); deathSouthIns.Volume = .2f; }