private void LoadContent_Ui(ContentManager Content) { augmentIcon = Content.Load <Texture2D>("PreparationTurn/StatAugmentIcon"); moneyBox = new RectBox(graphicsDevice, characterDrawPos + new Vector2(uiScale * turnPlayer.CharacterSprite.Width / 2, winBarDimensions.Y + unitBarDimensions.Y), (int)moneyBoxDimensions.X, (int)moneyBoxDimensions.Y); emptyRect = UiTools.GeneratePixelTexture(graphicsDevice); characterBoundary = Content.Load <Texture2D>("CharacterSelect/Buttons/ButtonBoundaryLR"); vsAiIcon = Content.Load <Texture2D>("PreparationTurn/vsPlayerIcon"); vsPlayerIcon = Content.Load <Texture2D>("PreparationTurn/vsPlayerIcon"); moneyIcon = Content.Load <Texture2D>("PreparationTurn/MoneyIcon"); //information used by the stage box: stageInfo = new StageViewBox(graphicsDevice, currentStage, bebasSmall, stageNumber + 1, stageIndex + 1, WindowTools.PaddingToPixelCoordinate(0f, 0.25f, 10, 10) ); //Buttons Texture2D buttonTexture = Content.Load <Texture2D>("PreparationTurn/EndTurnButton"); Texture2D hoverTexture = Content.Load <Texture2D>("PreparationTurn/EndTurnButtonHovered"); bool[,] mask = UiTools.CreateBoolMask(buttonTexture); endTurnButton = new SinglePressSpriteButton(WindowTools.PaddingToPixelCoordinate(0f, 0.17f, 10, 10), buttonTexture, hoverTexture, mask, uiScale); //assign the end turn function to the button's event handler. endTurnButton.buttonPressed += HandleEndTurnButtonPress; levelUnitCapButton = new LevelUnitCapButton(graphicsDevice, moneyBox.GetPos() + new Vector2(moneyBoxDimensions.X, 0f), (int)WindowTools.GetUpscaledValue(225f), (int)moneyBoxDimensions.Y); //and so on with all used buttons levelUnitCapButton.buttonPressed += HandleLevelUpCapPress; useAbilityButton = new UseAbilityButton(graphicsDevice, WindowTools.PaddingToPixelCoordinate(0.1f, 0.17f, 10, 10), (int)WindowTools.GetUpscaledValue(225f), (int)(buttonTexture.Height * uiScale) ); useAbilityButton.buttonPressed += HandleAbilityButtonPress; //divisor line to distinguish between money box/level up button. divisorLine = new Line(graphicsDevice, levelUnitCapButton.GetPos(), levelUnitCapButton.GetPos() + new Vector2(0, levelUnitCapButton.GetHeight()), 5, Color.White); //help button helpButton = new TutorialButton(graphicsDevice, this, WindowTools.PaddingToPixelCoordinate(0.90f, 0f, 0, 10), (int)(20 * uiScale), (int)(10 * uiScale)); }
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); }