private void Draw_TopLeftUI(SpriteBatch spriteBatch) { //Draw the win progress bar Vector2 barPos = characterDrawPos + new Vector2(uiScale * turnPlayer.CharacterSprite.Width / 2, 0f); PercentageBar.Draw(spriteBatch, emptyRect, barPos, winBarDimensions, turnPlayer.Colour, Color.Gray, turnPlayer.WinThreshold, turnPlayer.WinProgress); string text = $"{turnPlayer.WinProgress}/{turnPlayer.WinThreshold} Wins"; spriteBatch.DrawString(bebasSmall, text, barPos + (winBarDimensions - 0.6f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0f); //Draw the unit cap bar. Vector2 unitBarPos = barPos + new Vector2(0, winBarDimensions.Y); int unitCount = grid.CountPlayerUnitsOnGrid(turnPlayer.Id); PercentageBar.Draw(spriteBatch, emptyRect, unitBarPos, unitBarDimensions, Color.DarkRed, Color.YellowGreen, turnPlayer.UnitCap, unitCount); text = $"{unitCount}/{turnPlayer.UnitCap} Units"; spriteBatch.DrawString(bebasSmall, text, unitBarPos + (unitBarDimensions - 0.5f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f); //Draw the players money amount. moneyBox.Draw(spriteBatch); string moneyText = $"{turnPlayer.Money}"; Vector2 textSize = bebasSmall.MeasureString(moneyText); Vector2 basePos = moneyBox.GetPos() + moneyBoxDimensions / 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: characterDrawPos - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: turnPlayer.Colour); spriteBatch.Draw(texture: turnPlayer.CharacterSprite, position: characterDrawPos, scale: uiScaleVector); //draw end turn button if (endTurnButton.IsHovered) { spriteBatch.Draw(texture: endTurnButton.HoverTexture, position: endTurnButton.Position, scale: uiScaleVector); } else { spriteBatch.Draw(texture: endTurnButton.ButtonTexture, position: endTurnButton.Position, scale: uiScaleVector); } spriteBatch.DrawString(bebasSmall, "End Turn", endTurnButton.MidPoint - 0.6f * bebasSmall.MeasureString("End Turn") / 2 + new Vector2(0, 1), Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0); //draw the level up unit cap button. levelUnitCapButton.Draw(spriteBatch, turnPlayer, moneyIcon, WindowTools.GetUpscaledValue(2f), bebasSmall, 0.6f); //and the ability button useAbilityButton.Draw(spriteBatch, turnPlayer, bebasSmall, 0.6f); divisorLine.Draw(spriteBatch); stageInfo.Draw(spriteBatch, vsAiIcon, vsPlayerIcon); //help button helpButton.Draw(spriteBatch, bebasSmall, 1f); }
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); }
private void Draw_Buttons(SpriteBatch spriteBatch) { //due to nature of layering and draw orders, it is more simple // to handle all calls within the game states draw call // instead of through methods in each object. spriteBatch.Begin(samplerState: SamplerState.PointClamp); //CHOOSE YOUR CHARACTER Vector2 titleSize = 0.66f * largeFont.MeasureString(titleString); spriteBatch.DrawString(largeFont, titleString, WindowTools.PaddingToPixelCoordinate(0.5f, 0f, 0, 0) - new Vector2(titleSize.X / 2, 0), Color.White, 0f, Vector2.Zero, 0.66f, SpriteEffects.None, 0f ); //draw help button helpButton.Draw(spriteBatch, font, 1f); //display roster of characters (this will be 3 or so) //draw character buttons for (int i = 0; i < uiButtons.Length; i++) { if (uiButtons[i] == p2SelectedButton && uiButtons[i] == p1SelectedButton) { spriteBatch.Draw(uiButtons[i].ButtonTexture, position: uiButtons[i].Position, scale: buttonScaleVector, color: Color.Purple); } else if (uiButtons[i] == p1SelectedButton) { spriteBatch.Draw(uiButtons[i].ButtonTexture, position: uiButtons[i].Position, scale: buttonScaleVector, color: pColors[0]); } else if (uiButtons[i] == p2SelectedButton) { spriteBatch.Draw(uiButtons[i].ButtonTexture, position: uiButtons[i].Position, scale: buttonScaleVector, color: pColors[1]); } else { spriteBatch.Draw(uiButtons[i].ButtonTexture, position: uiButtons[i].Position, scale: buttonScaleVector); } } //draw confirmation button + corresponding text string text = "start"; Vector2 textSize = font.MeasureString(text); if (p1SelectedButton != null && p2SelectedButton != null) { if (confirmButton.IsHovered) { spriteBatch.Draw(confirmButton.HoverTexture, position: confirmButton.Position, scale: buttonScaleVector * 2); spriteBatch.DrawString(font, text, confirmButton.MidPoint - textSize / 2, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); } else { spriteBatch.Draw(confirmButton.ButtonTexture, position: confirmButton.Position, scale: buttonScaleVector * 2); spriteBatch.DrawString(font, text, confirmButton.MidPoint - textSize / 2, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); } } else { spriteBatch.Draw(confirmButton.ButtonTexture, position: confirmButton.Position, scale: buttonScaleVector * 2, color: Color.Gray); spriteBatch.DrawString(font, text, confirmButton.MidPoint - textSize / 2, Color.Gray, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); } //outlines for (int i = 0; i < uiButtons.Length; i++) { if (uiButtons[i].IsHovered) { spriteBatch.Draw(uiButtons[i].HoverTexture, position: uiButtons[i].Position - buttonScaleVector, scale: buttonScaleVector); } } //display character info on left or right of screen depending on which player has it selected. spriteBatch.End(); }