Esempio n. 1
0
        protected float PlatformCollisionRaycast(Fixture fixture, Microsoft.Xna.Framework.Vector2 point, Microsoft.Xna.Framework.Vector2 normal, float fraction)
        {
            // TODO: Have these values be not hard-coded
            lock(Program.MainUpdateLock)
            {
                if(fixture == FixtureUpper || fixture == FixtureLower)
                    return 1.0f;
                //if(JumpTimer.Elapsed.TotalMilliseconds > 50 && GoneDown)
                {
                    if(Jumping && Body.LinearVelocity.Y < 0.01)
                    {
                        PlayAnimation(AnimationEndJump);
                        _AnimationNext = new Lazy<SpriteAnimation>(() => { return AnimationStationary; });

                        // TODO: See the other comment regarding disabling the
                        // lower body fixture; this is for collision rather than
                        // separation

                        // TODO: Hack apart Farseer Physics to make it suck less
                        //var manifold = new Manifold();
                        //manifold.LocalPoint = point;
                        //manifold.LocalNormal = normal;

                        AABB fixture_upper_aabb, fixture_lower_aabb;

                        FixtureLower.CollisionCategories = Category.Cat1;

                        FixtureUpper.GetAABB(out fixture_upper_aabb, 0);
                        FixtureLower.GetAABB(out fixture_lower_aabb, 0);

                        if(FixtureLower.OnCollision != null)
                            FixtureLower.OnCollision(FixtureLower, fixture, null);
                        if(fixture.OnCollision != null)
                            fixture.OnCollision(fixture, FixtureLower, null);

                        PositionWorldY += fixture_upper_aabb.LowerBound.Y - fixture_lower_aabb.LowerBound.Y;
                    }
                }
            }
            return 0;
        }