示例#1
0
        private void Draw(EngineTime time)
        {
            var text = this.logs.Aggregate(new StringBuilder(), (sb, x) => sb.AppendLine(x.Value)).ToString();

            this.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            this.spriteBatch.DrawString(this.font, text, Vector2.One, Color.Black);
            this.spriteBatch.DrawString(this.font, text, Vector2.Zero, Color.White);
            this.spriteBatch.End();
        }
示例#2
0
        private void Draw(EngineTime time)
        {
            var width = this.Engine.Game.GraphicsDevice.PresentationParameters.BackBufferWidth;
            var height = this.Engine.Game.GraphicsDevice.PresentationParameters.BackBufferHeight;
            var offset = this.splashBackground.Size() / 2;

            var position = new Vector2(width, height) / 2 - offset;

            this.Engine.UISpriteBatch.Draw(this.splashBackground, position, Color.White);
        }
示例#3
0
        private void Draw(EngineTime time)
        {
            var width = this.Engine.Game.GraphicsDevice.PresentationParameters.BackBufferWidth;
            var height = this.Engine.Game.GraphicsDevice.PresentationParameters.BackBufferHeight;
            var offset = this.buttonTexture.Size() / 2;

            var screenSize = new Vector2(width, height);

            var textSize = font.MeasureString(this.Text);
            var textPosition = this.Position - textSize / 2;

            this.Engine.UISpriteBatch.Draw(this.buttonTexture, this.Position - offset + screenSize / 2, Color.White);
            this.Engine.UISpriteBatch.DrawString(this.font, this.Text,
                                                 Vector2.UnitY * 2 + textPosition + screenSize / 2, this.Color);
        }
        /// <summary>
        /// Takes input for the camera
        /// </summary>
        /// <param name="time"></param>
        private void UpdateInput(EngineTime time)
        {
            Vector2 linearVelocity = Vector2.Zero;

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.Up))
            {
                linearVelocity += Vector2.UnitY;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.Down))
            {
                linearVelocity -= Vector2.UnitY;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.Left))
            {
                linearVelocity -= Vector2.UnitX;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.Right))
            {
                linearVelocity += Vector2.UnitX;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.Z))
            {
                this.camera.Zoom += this.ZoomSpeed*time.Elapsed;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.X))
            {
                this.camera.Zoom -= this.ZoomSpeed*time.Elapsed;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.C))
            {
                this.Dispose();
            }

            this.camera.Position += linearVelocity*this.MoveSpeed*this.camera.ZoomFactor*time.Elapsed;
        }
示例#5
0
 private void Update(EngineTime time)
 {
     this.camera.Position = Vector2.Lerp(this.camera.Position,
                                         this.robot.Position + this.robot.LinearVelocity / 10, 0.5f);
 }
示例#6
0
 private void Update(EngineTime time)
 {
     var direction = this.Engine.Mouse.KnownWorldPosition - this.Position;
     this.body.Rotation = (float)Math.Atan2(direction.Y, direction.X);
 }
示例#7
0
 private void LinkPhysics(EngineTime time)
 {
     this.body.Position = this.owner.Position;
 }
示例#8
0
        public void Update(GameTime gt)
        {
            var now = DateTime.Now;
            var time = new EngineTime(gt, 1);

            this.updates.OnNext(time);

            this.Keyboard.Update();
            this.Mouse.Update();

            this.InputScheduler.AdvanceTo(now);

            this.UpdateScheduler.AdvanceTo(now);

            this.PrePhysicsScheduler.AdvanceTo(now);

            this.World.Step((float) gt.ElapsedGameTime.TotalSeconds);

            this.PostPhysicsScheduler.AdvanceTo(now);
        }
示例#9
0
        public void Draw(GameTime gt)
        {
            var now = DateTime.Now;
            var time = new EngineTime(gt, 1);

            this.UISpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null);
            this.draws.OnNext(time);
            this.UISpriteBatch.End();

            var oldViewport = this.Game.GraphicsDevice.Viewport;

            using (Disposable.Create(() => { this.Game.GraphicsDevice.Viewport = oldViewport; }))
            {
                foreach (var perspective in this.PerspectiveManager)
                {
                    this.Game.GraphicsDevice.Viewport = perspective.Viewport;
                    this.PerspectiveManager.CurrentPerspective = perspective;

                    this.UISpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null);
                    this.perspectiveDraws.OnNext(time);
                    this.UISpriteBatch.End();

                    var matrix = perspective.GetMatrix();
                    this.worldView.RenderDebugData(ref matrix);
                }
            }

            this.Game.GraphicsDevice.Viewport = oldViewport;

            this.UISpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null);

            this.PostDrawScheduler.AdvanceTo(now);

            this.UISpriteBatch.End();
        }
示例#10
0
文件: Flame.cs 项目: HaKDMoDz/shooter
        private void CheckLifetime(EngineTime time)
        {
            var now = DateTime.UtcNow;

            if (now > this.timeToDelete)
            {
                this.Dispose();
            }
        }
示例#11
0
文件: Robot.cs 项目: HaKDMoDz/shooter
        private void UpdateInput(EngineTime time)
        {
            var direction = Vector2.Zero;

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.A))
            {
                direction -= Vector2.UnitX;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.D))
            {
                direction += Vector2.UnitX;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.W))
            {
                direction += Vector2.UnitY;
            }

            if (this.Engine.Keyboard.State.IsKeyDown(Keys.S))
            {
                direction -= Vector2.UnitY;
            }

            if (direction != Vector2.Zero)
            {
                direction.Normalize();
            }

            var attributes = new RobotTraits();

            powerups.RemoveAll((x) => x.ShouldRemove);

            foreach (var powerup in powerups)
            {
                powerup.Process(attributes);
            }

            direction *= attributes.AccelerationRate;

            this.body.LinearVelocity += direction * MaxLinearAcceleration * time.Elapsed;
        }
示例#12
0
文件: Robot.cs 项目: HaKDMoDz/shooter
 private void LinkPhysics(EngineTime time)
 {
     if (this.body.LinearVelocity.LengthSquared() > 0.5)
     {
         this.Rotation = (float) Math.Atan2(this.body.LinearVelocity.Y, this.body.LinearVelocity.X);
     }
 }
示例#13
0
文件: Robot.cs 项目: HaKDMoDz/shooter
 private void Fire(EngineTime time)
 {
     this.weapon.FireRequests.OnNext(Unit.Default);
 }
示例#14
0
 private void Update(EngineTime time)
 {
     this.logs.RemoveAll((x) => DateTime.UtcNow > x.DeletionDate);
 }