Exemplo n.º 1
0
 public override void Update(TimeSpan elapsedTime)
 {
     foreach (var component in Components)
     {
         component.Update(elapsedTime);
     }
 }
Exemplo n.º 2
0
        public override void Update(TimeSpan t)
        {
            this.game.CollisionHandler.HandleCollision(this);

            if (this.Deleted)
            {
                return;
            }

            var acceleration = Vector2.Zero;

            foreach (var body in this.game.Bodies)
            {
                var shape = body.Shape;

                var difference = shape.Center - this.position;

                var distanceSquared = difference.LengthSquared;

                var a = Constants.G * body.Mass / distanceSquared.NumericValue;

                var dirNormal = difference.Direction.Vector;

                acceleration += dirNormal * a;
            }

            this.velocity += new Velocity2(acceleration * (float)t.NumericValue);

            this.position += this.velocity * t;
        }
Exemplo n.º 3
0
        public void Update(TimeSpan elapsedTime, ControlState controlState)
        {
            var leftRight = this.helpSteer(controlState).Clamped(-1, 1);

            this.updateMovement(elapsedTime, controlState.Acceleration, leftRight);

            this.update();
        }
Exemplo n.º 4
0
        public override void Update(TimeSpan elapsedTime)
        {
            this.goalPoint = this.controller.Control();

            updateMovement(elapsedTime);

            this.eventListenerTileManager.Update();
        }
Exemplo n.º 5
0
        public override void Update(TimeSpan elapsedTime)
        {
            this.goalPoint = this.controller.Control();

            updateMovement(elapsedTime);

            this.eventListenerTileManager.Update();
        }
Exemplo n.º 6
0
        public void Update(TimeSpan elapsedTime, ControlState controlState)
        {
            var leftRight = this.helpSteer(controlState).Clamped(-1, 1);

            this.updateMovement(elapsedTime, controlState.Acceleration, leftRight);

            this.update();
        }
Exemplo n.º 7
0
 public override void Update(TimeSpan elapsedTime)
 {
     while (spawnQueue.Count > 0 && spawnQueue.First.Value.Item1 <= Game.Time)
     {
         spawnEnemy(spawnQueue.First.Value.Item2);
         spawnQueue.RemoveFirst();
     }
 }
Exemplo n.º 8
0
        public void Advance(TimeSpan elapsedTime)
        {
            Time += elapsedTime;

            foreach (var obj in gameObjects)
            {
                obj.Update(elapsedTime);
            }
        }
Exemplo n.º 9
0
        private void update(TimeSpan t)
        {
            this.time += t;

            foreach (var gameObject in this.gameObjects)
            {
                gameObject.Update(t);
            }
        }
Exemplo n.º 10
0
        public void Update(TimeSpan elapsedTimeInS)
        {
            if (InitialLifetime == TimeSpan.Zero)
            {
                firstRun();
            }

            Position += elapsedTimeInS * Velocity;
            Lifetime -= elapsedTimeInS;
        }
Exemplo n.º 11
0
        public void Update(UpdateEventArgs args)
        {
            var elapsedTime = new TimeSpan(args.ElapsedTimeInS);

            this.Time += elapsedTime;


            foreach (var gameObject in this.gameObjects)
            {
                gameObject.Update(elapsedTime);
            }
        }
Exemplo n.º 12
0
        private void updateZoom(TimeSpan t)
        {
            float zoomDelta = InputManager.DeltaScroll;

            zoomDelta += (float)t.NumericValue * 15
                         * (this.controls.ZoomOut.AnalogAmount - this.controls.ZoomIn.AnalogAmount)
                         + (this.controls.ZoomOut.Hit ? 1 : 0)
                         + (this.controls.ZoomIn.Hit ? -1 : 0);

            if (zoomDelta != 0)
            {
                var zoomFactor = GameMath.Pow(1 / 1.4f, zoomDelta);
                this.view.Zoom *= zoomFactor;
            }
        }
Exemplo n.º 13
0
        public override void Update(TimeSpan elapsedTime)
        {
            var interiorAlphaGoal = this.RevealInside ? 1 : 0;

            var fade = (float)elapsedTime.NumericValue * 2;

            if (interiorAlphaGoal > this.interiorAlpha)
            {
                this.interiorAlpha = Math.Min(interiorAlphaGoal, this.interiorAlpha + fade);
            }
            else
            {
                this.interiorAlpha = Math.Max(interiorAlphaGoal, this.interiorAlpha - fade);
            }
        }
Exemplo n.º 14
0
        private void updateMovement(TimeSpan elapsedTime)
        {
            var maxMoveThisFrame = new Speed(2) * elapsedTime;

            var differenceToGoal = this.goalPoint - this.Position;
            var distanceToGoal   = differenceToGoal.Length;

            if (distanceToGoal < maxMoveThisFrame)
            {
                this.Position = this.goalPoint;
            }
            else
            {
                this.Position += differenceToGoal / distanceToGoal * maxMoveThisFrame;
            }
        }
Exemplo n.º 15
0
        private void updateMovement(TimeSpan elapsedTime, float acceleration, float leftRight)
        {
            var t = (float)elapsedTime.NumericValue;

            this.speed += new Acceleration(acceleration * 50) * elapsedTime;
            this.speed *= Mathf.Pow(1e-3f, t);

            this.turnSpeed += AngularAcceleration.FromRadians(leftRight * 5) * elapsedTime;
            this.turnSpeed *= Mathf.Pow(1e-7f, t);

            this.Direction += this.turnSpeed * (elapsedTime * this.speed.NumericValue);

            this.Position += this.Direction * this.speed * elapsedTime;

            this.distanceTraveled += this.speed * elapsedTime;
        }
Exemplo n.º 16
0
        public override void Update(TimeSpan elapsedTime)
        {
            var movementLeft = elapsedTime * Blueprint.Speed;

            while (movementLeft > Unit.Zero)
            {
                if (currentMovementDir == Direction.Unknown)
                {
                    currentMovementDir = GetNextDirection();
                    if (currentMovementDir == Direction.Unknown)
                    {
                        break;
                    }
                }

                movementLeft = updateMovement(movementLeft);
            }
            Position = Game.Level.GetPosition(anchorTile)
                       + movementProgress * currentMovementDir.SpaceTimeDirection();
        }
Exemplo n.º 17
0
        public override void Update(TimeSpan t)
        {
            var rotation = this.controls.RotateCounterClockwise.AnalogAmount
                           - this.controls.RotateClockwise.AnalogAmount;

            this.aimDirection += 2f.Radians() * rotation * (float)t.NumericValue;

#if DEBUG
            if (this.controls.ShootDebug.Hit)
            {
                var request = ShootDebugParticleFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                this.game.RequestHandler.TryDo(request);
            }
#endif

            if (this.controls.Shoot.Active)
            {
                var fireInterval = new TimeSpan(1 / this.economy[EcoValue.FireRate].Value);

                var timeSinceLastShot = this.game.Time - this.lastShot;

                if (timeSinceLastShot > fireInterval)
                {
                    if (this.economy[EcoValue.Projectiles].Value >= 1)
                    {
                        var request = ShootProjectileFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                        this.game.RequestHandler.TryDo(request);
                        this.lastShot = this.game.Time;
                    }
                }
            }

            this.updateZoom(t);

            foreach (var stat in this.stats)
            {
                stat.Update(t);
            }
        }
Exemplo n.º 18
0
        public override void Update(TimeSpan elapsedTime)
        {
            var interiorAlphaGoal = this.RevealInside ? 1 : 0;

            var fade = (float)elapsedTime.NumericValue * 2;

            if (interiorAlphaGoal > this.interiorAlpha)
            {
                this.interiorAlpha = Math.Min(interiorAlphaGoal, this.interiorAlpha + fade);
            }
            else
            {
                this.interiorAlpha = Math.Max(interiorAlphaGoal, this.interiorAlpha - fade);
            }
        }
        public override void Update(TimeSpan t)
        {
            var rotation = this.controls.RotateCounterClockwise.AnalogAmount
                - this.controls.RotateClockwise.AnalogAmount;

            this.aimDirection += 2f.Radians() * rotation * (float)t.NumericValue;

            #if DEBUG
            if (this.controls.ShootDebug.Hit)
            {
                var request = ShootDebugParticleFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                this.game.RequestHandler.TryDo(request);
            }
            #endif

            if (this.controls.Shoot.Active)
            {
                var fireInterval = new TimeSpan(1 / this.economy[EcoValue.FireRate].Value);

                var timeSinceLastShot = this.game.Time - this.lastShot;

                if (timeSinceLastShot > fireInterval)
                {
                    if (this.economy[EcoValue.Projectiles].Value >= 1)
                    {
                        var request = ShootProjectileFromPlanet.Request(this.game, this, this.body, this.aimDirection);
                        this.game.RequestHandler.TryDo(request);
                        this.lastShot = this.game.Time;
                    }
                }
            }

            this.updateZoom(t);

            foreach (var stat in this.stats)
            {
                stat.Update(t);
            }
        }
        private void updateZoom(TimeSpan t)
        {
            float zoomDelta = InputManager.DeltaScroll;
            zoomDelta += (float)t.NumericValue * 15
                * (this.controls.ZoomOut.AnalogAmount - this.controls.ZoomIn.AnalogAmount)
                + (this.controls.ZoomOut.Hit ? 1 : 0)
                + (this.controls.ZoomIn.Hit ? -1 : 0);

            if (zoomDelta != 0)
            {
                var zoomFactor = GameMath.Pow(1 / 1.4f, zoomDelta);
                this.view.Zoom *= zoomFactor;
            }
        }
Exemplo n.º 21
0
        private void updateMovement(TimeSpan elapsedTime, float acceleration, float leftRight)
        {
            var t = (float)elapsedTime.NumericValue;

            this.speed += new Acceleration(acceleration * 50) * elapsedTime;
            this.speed *= Mathf.Pow(1e-3f, t);

            this.turnSpeed += AngularAcceleration.FromRadians(leftRight * 5) * elapsedTime;
            this.turnSpeed *= Mathf.Pow(1e-7f, t);

            this.Direction += this.turnSpeed * (elapsedTime * this.speed.NumericValue);

            this.Position += this.Direction * this.speed * elapsedTime;

            this.distanceTraveled += this.speed * elapsedTime;
        }
Exemplo n.º 22
0
 public override void Update(TimeSpan t)
 {
     this.orbitDirection = Direction2.Zero + this.angularVelocity * (float)this.game.Time.NumericValue;
     this.center         = this.calculatePosition();
 }
Exemplo n.º 23
0
        private void updateMovement(TimeSpan elapsedTime)
        {
            var maxMoveThisFrame = new Speed(2) * elapsedTime;

            var differenceToGoal = this.goalPoint - this.Position;
            var distanceToGoal = differenceToGoal.Length;

            if (distanceToGoal < maxMoveThisFrame)
            {
                this.Position = this.goalPoint;
            }
            else
            {
                this.Position += differenceToGoal / distanceToGoal * maxMoveThisFrame;
            }
        }
Exemplo n.º 24
0
        public void Update(UpdateEventArgs e)
        {
            var elapsed = new TimeSpan(e.ElapsedTimeInS);

            this.update(elapsed);
        }
Exemplo n.º 25
0
 public override void Update(TimeSpan elapsedTime)
 {
 }
Exemplo n.º 26
0
 public override void Update(TimeSpan elapsedTime)
 {
 }