Exemplo n.º 1
0
        private void SetNewPlayerPosition()
        {
            Vector2 oldPosition = GetLevelProgression().CurrentPlayerPosition;

            Vector2 newPosition = gamePhysics.DoPlayerPhysics(oldPosition);

            if (!LevelAnalysis.IsVectorOnGround(levelAttempt.Level, newPosition))
            {
                bool isPlayerStanding = GetLevelProgression().IsPlayerStanding;

                Ground groundCollidedWith = collisions.GetPlayerGroundCollision(newPosition, isPlayerStanding);

                if (groundCollidedWith != null)
                {
                    Vector2 rightFoot = PhysicsValues.GetRightFootPosition(newPosition);

                    float deltaX = Math.Abs(rightFoot.X - groundCollidedWith.LeftX);
                    float deltaY = Math.Abs(groundCollidedWith.TopY - rightFoot.Y);

                    if (deltaY > deltaX)
                    {
                        AddPlayerFail();
                    }

                    newPosition = new Vector2(newPosition.X, groundCollidedWith.TopY);

                    gamePhysics.ResetVerticalVelocity();
                }
            }

            GetLevelProgression().CurrentPlayerPosition = newPosition;
        }