Ejemplo n.º 1
0
        private void Move(World world)
        {
            positionDelta = Mat4D.Rotation(Rotation.Y, new Double3(0.0f, 1.0f, 0.0f)).Transform(speed, 0.0).Key;
            var originalDelta = positionDelta;
            var hitboxes      = world.GetHitboxes(Hitbox.Expand(positionDelta));

            foreach (var curr in hitboxes)
            {
                positionDelta.X = Hitbox.MaxMoveOnXclip(curr, positionDelta.X);
            }
            MoveHitbox(new Double3(positionDelta.X, 0.0, 0.0));
            if (positionDelta.X != originalDelta.X)
            {
                speed.X = 0.0;
            }

            foreach (var curr in hitboxes)
            {
                positionDelta.Z = Hitbox.MaxMoveOnZclip(curr, positionDelta.Z);
            }
            MoveHitbox(new Double3(0.0, 0.0, positionDelta.Z));
            if (positionDelta.Z != originalDelta.Z)
            {
                speed.Z = 0.0;
            }

            foreach (var curr in hitboxes)
            {
                positionDelta.Y = Hitbox.MaxMoveOnYclip(curr, positionDelta.Y);
            }
            MoveHitbox(new Double3(0.0, positionDelta.Y, 0.0));
            if (positionDelta.Y != originalDelta.Y)
            {
                speed.Y = 0.0;
            }

            Position += positionDelta;
        }