예제 #1
0
        public override void Update(List <BaseActor> loadedactors)
        {
            // Gravity.
            base.Update(loadedactors);

            // Drawable
            if (this.timer.ElapsedMilliseconds > 500)
            {
                // Swap drawables.
                this.drawableCurrent = this.drawableCurrent == this.drawableLeft ? this.drawableRight : this.drawableLeft;

                this.timer.Reset();
                this.timer.Start();
            }

            // Walk
            this.Position += this.WalkingVelocity;

            // If bump into Left or Right, Turn around.
            if (Physics.Physics.IsActorPushingAnotherFromLeft(this, loadedactors) ||
                Physics.Physics.IsActorPushingAnotherFromRight(this, loadedactors))
            {
                this.Velocity        = new VectorClass.Vector2D_Dbl(this.WalkingVelocity.X * -1, Velocity.Y);
                this.WalkingVelocity = new VectorClass.Vector2D_Dbl(this.WalkingVelocity.X * -1, this.WalkingVelocity.Y);
            }

            // If we got stomped on, we'll need to die.
            if (Physics.Physics.IsActorPushingAnotherFromBottom(this, loadedactors))
            {
                // Queue the removal.
                Environment.ActorsToRemove.Add(this);
            }

            // Normalize Velocities to only allow maximum speeds.
            Physics.Physics.NormalizeVelocity(this);

            Physics.Physics.BlockAllCollisions(this, loadedactors);
        }
예제 #2
0
        public override void Update(List<BaseActor> loadedactors)
        {
            // Gravity.
            base.Update(loadedactors);

            // Drawable
            if (this.timer.ElapsedMilliseconds > 500)
            {
                // Swap drawables.
                this.drawableCurrent = this.drawableCurrent == this.drawableLeft ? this.drawableRight : this.drawableLeft;

                this.timer.Reset();
                this.timer.Start();
            }

            // Walk
            this.Position += this.WalkingVelocity;

            // If bump into Left or Right, Turn around.
            if (Physics.Physics.IsActorPushingAnotherFromLeft(this, loadedactors)
                || Physics.Physics.IsActorPushingAnotherFromRight(this, loadedactors))
            {
                this.Velocity = new VectorClass.Vector2D_Dbl(this.WalkingVelocity.X * -1, Velocity.Y);
                this.WalkingVelocity = new VectorClass.Vector2D_Dbl(this.WalkingVelocity.X * -1, this.WalkingVelocity.Y);
            }

            // If we got stomped on, we'll need to die.
            if (Physics.Physics.IsActorPushingAnotherFromBottom(this, loadedactors))
            {
                // Queue the removal.
                Environment.ActorsToRemove.Add(this);
            }

            // Normalize Velocities to only allow maximum speeds.
            Physics.Physics.NormalizeVelocity(this);

            Physics.Physics.BlockAllCollisions(this, loadedactors);
        }