Пример #1
0
        private void Draw_UI(SpriteBatch spriteBatch)
        {
            helpButton.Draw(spriteBatch, bebasSmall, 1f);

            //draw the players character and money if vs an AI.
            if (useAiOpponent)
            {
                moneyUiBox.Draw(spriteBatch);
                string  moneyText = $"{playerToCheckWinCondition.Money}";
                Vector2 textSize  = bebasSmall.MeasureString(moneyText);
                Vector2 basePos   = moneyUiBox.GetPos() + new Vector2(moneyBoxDimensions.X / 2f, moneyBoxDimensions.Y / 2);
                spriteBatch.DrawString(bebasSmall, moneyText, basePos - new Vector2(0, textSize.Y / 2), Color.White);
                spriteBatch.Draw(moneyIcon,
                                 position: basePos + new Vector2(textSize.X + moneyBoxDimensions.X / 35, 0) - uiScale / 2 * new Vector2(0, moneyIcon.Height),
                                 scale: uiScaleVector
                                 );

                //Draw the player's character.
                spriteBatch.Draw(texture: characterBoundary, position: characterPos[0] - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: playerToCheckWinCondition.Colour);
                spriteBatch.Draw(texture: playerToCheckWinCondition.CharacterSprite, position: characterPos[0], scale: uiScaleVector);
            }
            //otherwise, draw each players character and their win progress.
            else
            {
                //Draw each players win % bars.
                Vector2 barPos = characterPos[0] + new Vector2(uiScale * otherPlayer.CharacterSprite.Width / 2, 0f);
                PercentageBar.Draw(spriteBatch, emptyRect, barPos, winBarDimensions, otherPlayer.Colour, Color.Gray, otherPlayer.WinThreshold, otherPlayer.WinProgress);
                string text = $"{otherPlayer.WinProgress}/{otherPlayer.WinThreshold} Wins";
                spriteBatch.DrawString(bebasSmall, text, barPos + (winBarDimensions - 0.6f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0f);

                Vector2 lowerBarPos = characterPos[1] + new Vector2(uiScale * playerToCheckWinCondition.CharacterSprite.Width / 2, -winBarDimensions.Y);
                PercentageBar.Draw(spriteBatch, emptyRect, lowerBarPos, winBarDimensions, playerToCheckWinCondition.Colour, Color.Gray, playerToCheckWinCondition.WinThreshold, playerToCheckWinCondition.WinProgress);
                text = $"{playerToCheckWinCondition.WinProgress}/{playerToCheckWinCondition.WinThreshold} Wins";
                spriteBatch.DrawString(bebasSmall, text, lowerBarPos + (winBarDimensions - 0.6f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0f);

                //Draw each players character with their boundary (their respective colour)
                spriteBatch.Draw(texture: characterBoundary, position: characterPos[0] - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: otherPlayer.Colour);
                spriteBatch.Draw(texture: otherPlayer.CharacterSprite, position: characterPos[0], scale: uiScaleVector);

                Vector2 lowerDrawPos = characterPos[1] - new Vector2(0, playerToCheckWinCondition.CharacterSprite.Height * uiScale);
                spriteBatch.Draw(texture: characterBoundary, position: lowerDrawPos - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: playerToCheckWinCondition.Colour);
                spriteBatch.Draw(texture: playerToCheckWinCondition.CharacterSprite, position: lowerDrawPos, scale: uiScaleVector);
            }

            logDisplay.Draw(spriteBatch, actionLog.GetActionsInOrder(), players, actionLogTextures);
        }