示例#1
0
        private void DrawPlayer(LevelProgression levelProgression)
        {
            Texture playerTexture;

            if (levelProgression.IsPlayerInGodmode())
            {
                playerTexture = playerGhostTexture;
            }
            else if (levelProgression.IsPlayerDefending)
            {
                playerTexture = playerDefendingTexture;
            }
            else
            {
                playerTexture = playerStandardTexture;
            }

            Vector2 playerPosition = levelProgression.CurrentPlayerPosition;

            float x1 = playerPosition.X - (VisualValues.PlayerWidth / 2.0f);
            float x2 = playerPosition.X + (VisualValues.PlayerWidth / 2.0f);
            float y1 = playerPosition.Y + VisualValues.PlayerHeight;

            if (!levelProgression.IsPlayerStanding)
            {
                x1 = playerPosition.X - (VisualValues.PlayerHeight / 2.0f);
                x2 = playerPosition.X + (VisualValues.PlayerHeight / 2.0f);
                y1 = playerPosition.Y + VisualValues.PlayerWidth;
            }

            Vector2 v1 = new Vector2(x1, y1);
            Vector2 v2 = new Vector2(x2, playerPosition.Y);

            if (levelProgression.IsPlayerStanding)
            {
                DrawAdjustedTexture(playerTexture, v1, v2);
            }
            else
            {
                DrawAdjustedTextureVertically(playerTexture, v1, v2);
            }
        }