private void LoadContent_Ui(ContentManager Content) { //Load icons augmentIcon = Content.Load <Texture2D>("PreparationTurn/StatAugmentIcon"); characterBoundary = Content.Load <Texture2D>("CharacterSelect/Buttons/ButtonBoundaryLR"); emptyRect = UiTools.GeneratePixelTexture(graphicsDevice); //used to draw % bars moneyIcon = Content.Load <Texture2D>("PreparationTurn/MoneyIcon"); //load money ui if vs ai if (useAiOpponent) { moneyUiBox = new RectBox(graphicsDevice, characterPos[0] + new Vector2(uiScale * playerToCheckWinCondition.CharacterSprite.Width / 2, 0), (int)moneyBoxDimensions.X, (int)moneyBoxDimensions.Y ); } actionLogTextures = new ActionLogBox.DrawParams( unitSprites, Content.Load <Texture2D>("BattleTurn/AttackIcon"), Content.Load <Texture2D>("BattleTurn/DefenseIcon"), Content.Load <Texture2D>("BattleTurn/NoMoveIcon"), Content.Load <Texture2D>("BattleTurn/Footprints"), Content.Load <Texture2D>("BattleTurn/SkullIcon"), Content.Load <Texture2D>("BattleTurn/TargetIcon") ); logDisplay = new ActionLogBox(graphicsDevice, logCapacity, bebasSmall, WindowTools.PaddingToPixelCoordinate(1f, 0.5f, -10, 0)); logDisplay.SetAnchorPoint(1f, 0.5f); helpButton = new TutorialButton(graphicsDevice, this, WindowTools.PaddingToPixelCoordinate(0.9f, 0f, 0, 10), (int)(20 * uiScale), (int)(10 * uiScale)); }
public ActionLogBox(GraphicsDevice graphicsDevice, int capacity, SpriteFont textFont, Vector2 pos) { this.pos = pos; this.textFont = textFont; //generate a colourless pixel to draw colour blocks with. emptyRect = UiTools.GeneratePixelTexture(graphicsDevice); textBox = new RectBox(graphicsDevice, this.pos, width, textBoxHeight); divisorA = new Line(graphicsDevice, new Vector2(pos.X, textBox.GetBottom()), new Vector2(pos.X + width, textBox.GetBottom()), 5, Color.White); actionBoxes = new RectBox[capacity]; for (int i = 0; i < capacity; i++) { actionBoxes[i] = new RectBox(graphicsDevice, new Vector2( pos.X, (i == 0)? textBox.GetBottom() : actionBoxes[i - 1].GetBottom()), width, actionBoxHeight); } dimensions = new Vector2(width, textBox.GetHeight() + capacity * actionBoxHeight); }
public string GetTipsInCurLanguage(int tipsId) { TipsItem tCfg = TipsData.Get(tipsId); if (tCfg != null) { string language = Global.gApp.gSystemMgr.GetMiscMgr().Language; if (language == null || language.Equals(GameConstVal.EmepyStr)) { language = UiTools.GetLanguage(); } string lTxt = ReflectionUtil.GetValueByProperty <TipsItem, string>(language, tCfg); if (lTxt == null || lTxt.Equals(GameConstVal.EmepyStr)) { //Debug.Log("tipsId = " + tipsId + "don't have language = " + language); return(tCfg.txtcontent); } else { return(lTxt); } } else { //Debug.Log("tipsId = " + tipsId + "don't exist"); } return(GameConstVal.EmepyStr); }
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)); }
public void SetCharacterInformation(Texture2D sprite, Type characterType) { characterSprite = sprite; this.characterType = characterType; abilityDescription = (characterType == null)? null : (string)characterType.GetField("AbilityDescription").GetRawConstantValue(); //long string - wrap it using the text wrapper. descriptionLines = (characterType == null)? null : UiTools.WrapText(textFont, abilityDescription, width, textPadding, 1f); }
private void LoadContent_Grid(ContentManager Content) { isoTile = Content.Load <Texture2D>("Board/isoTile"); hoveredIsoTile = Content.Load <Texture2D>("Board/hoveredIsoTile"); isoGridMask = Content.Load <Texture2D>("Board/isoGridMask"); isoGridMaskPixelData = UiTools.CreateColorMask(isoGridMask); //pixelData; gridMaskOrigin = grid.GetMaskOrigin(); }
private void LoadContent_Bench(ContentManager Content) { benchMask = Content.Load <Texture2D>("Bench/benchGridMask"); benchMaskPixelData = UiTools.CreateColorMask(benchMask); //bench uses existing hexgrid class to attain same appearance - structure is handled within the player class. bench = new HexGrid(turnPlayer.GetBenchUnits().Length, 1, screenBoardOrigin - HexGrid.OddToEvenRowOffset * boardScaleVector + 5 * Vector2.One * boardScaleVector, boardScale); benchMaskOrigin = bench.GetMaskOrigin(); }
private void Draw_AugmentIcon(SpriteBatch spriteBatch, Unit unit, Vector2 unitPos, Texture2D unitTexture) { //draw an icon to show that the stats of the unit have been // augmented according to the player's chosen character's ability. if (unit.Augmented) { spriteBatch.Draw(augmentIcon, position: unitPos + boardScaleVector / 2 * UiTools.BoundsToVector(unitTexture.Bounds) - uiScale / 2 * UiTools.BoundsToVector(augmentIcon.Bounds), scale: uiScaleVector ); } }
private void LoadCustomConfigurations() { string siteContactMail = global :: TrucksReserve.Properties.Settings.Default.SiteContactMail; siteContactMail.ExcIfNullOrEmpty(); if (siteContactMail.IsValidEmailAddress() == false) { UiTools.NewUiException("invalid SiteContactMail"); } Mail.SiteContactMail = siteContactMail; Mail.SendMailViaSSL = global :: TrucksReserve.Properties.Settings.Default.SendMailsViaSSL; }
private void Draw_StepActionOverUnits(SpriteBatch spriteBatch, Unit unit, Vector2 unitDrawPos) { //Draw information about what action a unit is about to take - specifically textures drawn OVER units if (pendingAction != null) { if (pendingAction.IsAttack) { //draw attack information: sword slash over attacking unit, shield over defending unit. if (pendingAction.ActingUnit == unit) { spriteBatch.Draw(actionLogTextures.attackIcon, position: unitDrawPos + boardScale / 2 * (UiTools.BoundsToVector(unit.GetSprite(unitSprites).Bounds) - UiTools.BoundsToVector(actionLogTextures.attackIcon.Bounds)), scale: boardScaleVector ); } else if (pendingAction.TargetUnit == unit) { spriteBatch.Draw(actionLogTextures.defenseIcon, position: unitDrawPos + boardScale / 2 * (UiTools.BoundsToVector(unit.GetSprite(unitSprites).Bounds) - UiTools.BoundsToVector(actionLogTextures.defenseIcon.Bounds)), scale: boardScaleVector ); } } else if (pendingAction.IsMove) { //draw move information: target over the unit the moving unit is going towards. if (pendingAction.ActingUnit == unit) { } else if (pendingAction.TargetUnit == unit) { spriteBatch.Draw(actionLogTextures.targetIcon, position: unitDrawPos + boardScale / 2 * (UiTools.BoundsToVector(unit.GetSprite(unitSprites).Bounds) - UiTools.BoundsToVector(actionLogTextures.targetIcon.Bounds)), scale: boardScaleVector ); } } else if (pendingAction.IsNone) { //draw a big red cross! This unit can't perform an action in its current position. if (pendingAction.ActingUnit == unit) { spriteBatch.Draw(actionLogTextures.noMoveIcon, position: unitDrawPos + boardScale / 2 * (UiTools.BoundsToVector(unit.GetSprite(unitSprites).Bounds) - UiTools.BoundsToVector(actionLogTextures.noMoveIcon.Bounds)), scale: boardScaleVector ); } } } }
private void OK_Click(object sender, EventArgs e) { bool failed = false; Target.Az = UiTools.ParseAndValidateDouble(AzText, Target.Az, ref failed); Target.Alt = UiTools.ParseAndValidateDouble(AltText, Target.Alt, ref failed); Target.Weight = UiTools.ParseAndValidateDouble(WeightText, Target.Az, ref failed); if (!failed) { DialogResult = DialogResult.OK; this.Close(); } }
private void LoadContent_Buttons(ContentManager Content) { //generating button for each available character. Vector2 prevDrawCoordinate = buttonGridOrigin; Vector2 translation; for (int i = 0; i < uiButtons.Length; i++) { //get the directory of respective button textures for characters from the ID; Type characterReference = CharacterLinker.GetCharacterReference(i); string directory = (string)characterReference.GetField("SpriteReference").GetRawConstantValue(); //load the button texture(s) Texture2D tex = Content.Load <Texture2D>(directory); Texture2D outline = Content.Load <Texture2D>("CharacterSelect/Buttons/Outline"); //create mask bool[,] mask = UiTools.CreateBoolMask(tex); //generate draw position if ((i & 1) == 1) //if odd number { translation = buttonTesselateVector; } else { translation = new Vector2(buttonTesselateVector.X, -buttonTesselateVector.Y); } //instantiate button uiButtons[i] = new CharSelectButton(i, prevDrawCoordinate + (buttonScale * translation), tex, outline, mask, buttonScale); //update the draw coordinate for tesselation. prevDrawCoordinate = prevDrawCoordinate + (buttonScale * translation); //attach event handler to button uiButtons[i].buttonPressed += HandleButtonPress; } //generate help button helpButton = new TutorialButton(graphicsDevice, this, WindowTools.PaddingToPixelCoordinate(0, 0, 10, 10), (int)(20 * buttonScale), (int)(10 * buttonScale)); //generating confirm button Texture2D confirmButtonTexture = Content.Load <Texture2D>("PreparationTurn/EndTurnButton"); Texture2D confirmButtonOutline = Content.Load <Texture2D>("PreparationTurn/EndTurnButtonHovered"); confirmButton = new CharSelectConfirmButton(WindowTools.PaddingToPixelCoordinate(0.45f, 0.6f, 0, 0) - buttonScale / 2 * new Vector2(confirmButtonTexture.Width, 0), confirmButtonTexture, confirmButtonOutline, UiTools.CreateBoolMask(confirmButtonTexture), buttonScale * 2); confirmButton.buttonPressed += HandleButtonPress; }
/// <param name="StrSelectedTextID">Parameter name must be equal to the one in AdminModel</param> public ActionResult Index(string StrSelectedTextID) { //Fill in the texts, which can be modified int?selectedTextID = null; if (StrSelectedTextID.GetTrimmed().IsEmpty() == false) { int id = 0; if (int.TryParse(StrSelectedTextID.GetTrimmed(), out id) == false) { UiTools.NewUiException(string.Format("Не можа да парсне SelectedTextID (string : '{0}') към инт.", StrSelectedTextID.GetTrimmed())); } else { selectedTextID = id; } } return(View(GetModel(selectedTextID))); }
public void AfterInit() { //Debug.Log("AfterInit = " + DateTime.Now.ToString()); double nowMills = DateTimeUtil.GetMills(DateTime.Now); if (m_Data.lastOffline > 0 && m_Data.lastOffline < m_Data.lastLoginTime) { m_Data.lastOffline = m_Data.lastLoginTime; } m_Data.lastLoginTime = nowMills; DateTime curDate = GetLastLoginDay(); DateTime now = DateTime.Today; int addDayNum = (now - curDate).Days; if (addDayNum > 0) { m_Data.lastLoginDay = DateTimeUtil.GetMills(now); m_Data.sumLoginDay = m_Data.sumLoginDay + 1; if (addDayNum == 1) { m_Data.continuousLoginDay += 1; } else { m_Data.continuousLoginDay = 1; } DateTime createDate = GetCreateDate(); m_Data.retainDays = DateTimeUtil.SubDays(now, createDate); m_Data.AdEnegyTimes = 0; m_Data.AdBoxTimes = 0; m_Data.EveryDayFP = 0; m_Data.VideoMDTDatatTimes = 0; int mTodayKey = DateTime.Now.Year * 1000 + DateTime.Now.DayOfYear; m_Data.VideoMDTData = mTodayKey; m_Data.startTimesToday = 0; m_Data.showTimeGiftToday = 0; SaveData(); //if (m_Data.retainDays == 1) //{ // //SDKDSAnalyticsManager.trackEvent(AFInAppEvents.af_mz_login_2nd); //} else if(m_Data.retainDays == 6) //{ // //SDKDSAnalyticsManager.trackEvent(AFInAppEvents.af_mz_login_7th); //} } StartTimesToday++; if (TimeGiftEndTime == null || !TimeGiftEndTime.Equals(Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.TIME_GIFT_END_TIME).content)) { TimeGiftEndTime = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.TIME_GIFT_END_TIME).content; TimeGiftStartTime = DateTimeUtil.GetMills(DateTime.Now); } if (Convert.ToDateTime(TimeGiftEndTime) < DateTimeUtil.GetDate(TimeGiftStartTime)) { TimeGiftStartTime = 0d; } //进行任务检测 Global.gApp.gSystemMgr.GetQuestMgr().QuestChange(FilterTypeConstVal.SUM_LOGIN_DAY, 0f); Global.gApp.gSystemMgr.GetQuestMgr().QuestChange(FilterTypeConstVal.CONSTIOUS_LOGIN, 0f); Global.gApp.gSystemMgr.GetQuestMgr().QuestChange(FilterTypeConstVal.TEMP_CONSTIOUS_LOGIN, 1f); if (Language == null || Language.Equals(GameConstVal.EmepyStr)) { Language = UiTools.GetLanguage(); } }
private void LoadContent_Button(ContentManager Content) { //generate the pass turn button and assign a method to it. Texture2D passTurnButtonTexture = Content.Load <Texture2D>("PreparationTurn/EndTurnButton"); Texture2D hoverTexture = Content.Load <Texture2D>("PreparationTurn/EndTurnButtonHovered"); passTurnButton = new SinglePressSpriteButton(WindowTools.PaddingToPixelCoordinate(0.5f, 0.6f, 0, 0) - (0.5f * uiScale * UiTools.BoundsToVector(passTurnButtonTexture.Bounds)), passTurnButtonTexture, hoverTexture, UiTools.CreateBoolMask(passTurnButtonTexture), uiScale); passTurnButton.buttonPressed += HandlePassTurnButtonPress; }
public override void Initialize() { overlayRectangle = UiTools.GeneratePixelTexture(graphicsDevice); }
public void Draw(SpriteBatch spriteBatch, Color textColor) { spriteBatch.Begin(samplerState: SamplerState.PointClamp); //draw underlying alpha box playerNameBox.Draw(spriteBatch); //calculate the size of the players name Vector2 nameSize = textFont.MeasureString(playerName); //calculate the position where the name needs to be drawn to be central // to the player name box. Vector2 namePos = playerNameBox.GetCentrePos() - 0.5f * nameSize; //draw the player name spriteBatch.DrawString(textFont, playerName, namePos, textColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); characterSpriteBox.Draw(spriteBatch); characterInfoBox.Draw(spriteBatch); //draw dividing lines divisorA.Draw(spriteBatch); divisorB.Draw(spriteBatch); //draw respective information about character if a character is selected if (characterType != null) { //draw selected character sprite Vector2 spritePos = characterSpriteBox.GetCentrePos() - 0.5f * spriteScale * UiTools.BoundsToVector(characterSprite.Bounds); spriteBatch.Draw(characterSprite, position: spritePos, scale: spriteScaleVector); //draw character name string chrName = characterType.Name; Vector2 basePos = characterInfoBox.GetPos() + new Vector2(characterInfoBox.DestinationRect.Width / 2, textPadding + textFont.MeasureString(chrName).Y / 2); namePos = basePos - textFont.MeasureString(chrName) / 2; spriteBatch.DrawString(textFont, chrName, namePos, textColor); string ability = $"Ability:"; Vector2 abilitySize = textFont.MeasureString(ability); Vector2 abilityPos = basePos + new Vector2(0, 5 * lineSpacing + textFont.MeasureString(chrName).Y / 2); spriteBatch.DrawString(textFont, ability, abilityPos - abilitySize / 2, Color.Red); //draw the ability description. // this is a long string being drawn to a small box, so // the text is wrapped according to the width of the box. // (See uitools for how text wrapping works). float drawGap = lineSpacing + textFont.MeasureString(abilityDescription).Y / 2; Vector2 linesOrigin = abilityPos + new Vector2(0, abilitySize.Y / 2 + lineSpacing); for (int i = 0; i < descriptionLines.Length; i++) { spriteBatch.DrawString(textFont, descriptionLines[i], linesOrigin + new Vector2(0, i * drawGap) - textFont.MeasureString(descriptionLines[i]) / 2, Color.White); } } spriteBatch.End(); }
private void FovText_TextChanged(object sender, EventArgs e) { bool failed = false; ProjTarget.FOV = UiTools.ParseAndValidateDouble(FovText, ProjTarget.FOV, ref failed); }
public void Draw(SpriteBatch spriteBatch, Texture2D vsAiIcon, Texture2D vsPlayerIcon) { //draw underlying alpha box textBox.Draw(spriteBatch); //calculate the size of the text Vector2 textSize = textFont.MeasureString(text); //calculate the position where the text needs to be drawn to be central // to the text box. Vector2 textPos = textBox.GetCentrePos() - 0.5f * new Vector2(textSize.X, textSize.Y); //draw the text spriteBatch.DrawString(textFont, text, textPos, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); //draw the underlying alpha boxes for each round. foreach (RectBox box in stageIconBoxes) { box.Draw(spriteBatch); } //draw dividing line divisorA.Draw(spriteBatch); //draw respective information about each round. for (int i = 0; i < stage.Length; i++) { if (stage.Rounds[i] == Stage.RoundTypes.vsAi) { spriteBatch.Draw(vsAiIcon, position: stageIconBoxes[i].GetCentrePos() - 0.5f * spriteScale * UiTools.BoundsToVector(vsAiIcon.Bounds), scale: spriteScaleVector, color: (i < stageIndex - 1)? Color.Gray : Color.White ); } else { spriteBatch.Draw(vsPlayerIcon, position: stageIconBoxes[i].GetCentrePos() - 0.5f * spriteScale * UiTools.BoundsToVector(vsPlayerIcon.Bounds), scale: spriteScaleVector, color: (i < stageIndex - 1) ? Color.DarkRed : Color.Red ); } } }
public void Draw(SpriteBatch spriteBatch, Player owner, UnitShop.ShopEntry[] entries, Dictionary <Type, Texture2D> unitSprites, Texture2D moneyIcon, SpriteFont textFont) { //pass in the information about shop entries -- draw for each one. //draw underlying alpha box for the box containing text. textBox.Draw(spriteBatch); //calculate the size of the text Vector2 textSize = textFont.MeasureString(text); //calculate the position where the text needs to be drawn to be central // to the text box. Vector2 textPos = textBox.GetCentrePos() - 0.5f * textSize; //draw the text spriteBatch.DrawString(textFont, text, textPos, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); foreach (UnitShopButton box in unitBoxes) { box.Draw(spriteBatch, owner, entries); } //draw respective information about each entry for (int i = 0; i < entries.Length; i++) { UnitShop.ShopEntry entry = entries[i]; UnitShopButton boxDrawingTo = unitBoxes[i]; Vector2 boxPos = boxDrawingTo.GetPos(); Texture2D unitSprite = unitSprites[entry.unitType]; spriteBatch.Draw(unitSprite, position: boxPos + new Vector2(width / 6, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(unitSprite.Bounds), scale: spriteScaleVector ); if (entry.Sold) { Vector2 size = textFont.MeasureString(soldText); Vector2 pos = boxPos + new Vector2(width / 3, (boxDrawingTo.GetHeight() - size.Y) / 2); spriteBatch.DrawString(textFont, soldText, pos, Color.White); } else if (owner.IsBenchFull()) { Vector2 size = textFont.MeasureString(fullText); Vector2 pos = boxPos + new Vector2(width / 3, (boxDrawingTo.GetHeight() - size.Y) / 2); spriteBatch.DrawString(textFont, fullText, pos, Color.White); } else { string text = $"Buy: {entry.cost}"; Vector2 size = textFont.MeasureString(text); Vector2 pos = boxPos + new Vector2(width / 3, (boxDrawingTo.GetHeight() - size.Y) / 2); spriteBatch.DrawString(textFont, text, pos, Color.White); spriteBatch.Draw(moneyIcon, position: boxPos + new Vector2(width / 3 + width / 15 + size.X, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(moneyIcon.Bounds), scale: spriteScaleVector ); } } //draw dividing line divisorA.Draw(spriteBatch); }
private void PosZText_TextChanged(object sender, EventArgs e) { bool failed = false; TransTarget.Z = UiTools.ParseAndValidateDouble(PosZText, TransTarget.Z, ref failed); }
private void OffAxisYText_TextChanged(object sender, EventArgs e) { bool failed = false; ProjTarget.YOffset = UiTools.ParseAndValidateDouble(OffAxisYText, ProjTarget.YOffset, ref failed); }
private void Draw_Units(SpriteBatch spriteBatch) { //draw bench units for (int x = (int)bench.Size.X - 1; x >= 0; x--) { //get unit on current bench tile iter Unit unit = turnPlayer.GetBenchUnits()[x]; if (unit != null) { //draw if not picked up if (GetUnitFromTileData(pickedUpTileData) != unit || !pickedUpTileData.Item2) { Texture2D unitTexture = unit.GetSprite(unitSprites); Vector2 pos = bench.Tiles[x, 0].GetCentrePixelCoordinate(boardScale) - new Vector2(boardScale * (unitTexture.Width / 2), unitTexture.Height * boardScale); spriteBatch.Draw(unitTexture, position: pos, scale: boardScaleVector); Draw_AugmentIcon(spriteBatch, unit, pos, unitTexture); } } } //draw units on the board - must be done from back of the grid to front // to preserve perspective. foreach (Unit unit in grid.Units.OrderByDescending(i => i.CubeCoordinate.Z).ThenBy(i => i.CubeCoordinate.Y)) { Vector2 tileCoordinate = CoordConverter.CubeToOffset(unit.CubeCoordinate); if (turnPlayer.IsPointInHalf(tileCoordinate, false)) { if (GetUnitFromTileData(pickedUpTileData) != unit || !pickedUpTileData.Item2) { Texture2D unitTexture = unit.GetSprite(unitSprites); Vector2 pos = grid.Tiles[(int)tileCoordinate.X, (int)tileCoordinate.Y].GetCentrePixelCoordinate(boardScale) - new Vector2(boardScale * (unitTexture.Width / 2), unitTexture.Height * boardScale); spriteBatch.Draw(unitTexture, position: pos, scale: boardScaleVector); Draw_AugmentIcon(spriteBatch, unit, pos, unitTexture); } } } //draw the picked up unit hovering over the mouse position if (pickedUpTileData.Item2) { Unit toDraw = GetUnitFromTileData(pickedUpTileData); Texture2D texture = toDraw.GetSprite(unitSprites); Vector2 pos = InputManager.Instance.MousePos - boardScale / 2 * UiTools.BoundsToVector(texture.Bounds); spriteBatch.Draw(texture, position: pos, scale: boardScaleVector ); Draw_AugmentIcon(spriteBatch, toDraw, pos, texture); } }
private void AspectText_TextChanged(object sender, EventArgs e) { bool failed = false; ProjTarget.Aspect = UiTools.ParseAndValidateDouble(AspectText, ProjTarget.Aspect, ref failed); }
private void RotXText_TextChanged(object sender, EventArgs e) { bool failed = false; TransTarget.Pitch = UiTools.ParseAndValidateDouble(PitchText, TransTarget.Pitch, ref failed); }
public void Draw(SpriteBatch spriteBatch, BattleTurn.ActionArgs[] actions, Player[] players, DrawParams textures) { //pass in the information about actions -- draw for each one. This information does not need to be stored here too. //draw underlying alpha box for the box containing text. textBox.Draw(spriteBatch); //calculate the size of the text Vector2 nameSize = textFont.MeasureString(text); //calculate the position where the text needs to be drawn to be central // to the text box. Vector2 namePos = textBox.GetCentrePos() - 0.5f * new Vector2(nameSize.X, nameSize.Y); //draw the text spriteBatch.DrawString(textFont, text, namePos, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); foreach (RectBox box in actionBoxes) { box.Draw(spriteBatch); } //draw respective information about each action for (int i = 0; i < actions.Length; i++) { BattleTurn.ActionArgs action = actions[i]; RectBox boxDrawingTo = actionBoxes[i]; Vector2 boxPos = boxDrawingTo.GetPos(); Color boxColor = (action.ActingUnit.OwnerId == 3) ? Color.Gray : players.Where(player => player.Id == action.ActingUnit.OwnerId).First().Colour; //set the color to Ai color/player color //draw a coloured block to specify which player the acting unit belongs to. //Using a single pixel texture instead of a non-disposable object (say my RectBox class for instance) // eliminates memory leak issues. spriteBatch.Draw(emptyRect, new Rectangle(boxDrawingTo.GetPos().ToPoint(), new Point(10, actionBoxHeight)), color: boxColor); Texture2D actingUnitSprite = action.ActingUnit.GetSprite(textures.unitSprites); //draw the units involved in each action, and the icons displaying the type of action. if (action.IsAttack) { //draw the attacking unit spriteBatch.Draw(actingUnitSprite, position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(actingUnitSprite.Bounds), scale: spriteScaleVector ); //draw the attack icon spriteBatch.Draw(textures.attackIcon, position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2), scale: iconScaleVector ); //draw the target unit Texture2D targetUnitSprite = action.TargetUnit.GetSprite(textures.unitSprites); spriteBatch.Draw(targetUnitSprite, position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(targetUnitSprite.Bounds), scale: spriteScaleVector ); //draw the defense icon spriteBatch.Draw(textures.defenseIcon, position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - iconScale * new Vector2(textures.defenseIcon.Width, 0), scale: iconScaleVector ); //draw the skull icon if the target unit died as a result of the action. if (action.TargetFainted) { spriteBatch.Draw(textures.skullIcon, position: boxPos + new Vector2(3.5f * width / 5, boxDrawingTo.GetHeight() / 2) - iconScale / 2 * UiTools.BoundsToVector(textures.skullIcon.Bounds), scale: iconScaleVector * 2 ); } } else if (action.IsMove) { //draw acting unit spriteBatch.Draw(actingUnitSprite, position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(actingUnitSprite.Bounds), scale: spriteScaleVector ); //draw move icon spriteBatch.Draw(textures.moveIcon, position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2), scale: iconScaleVector ); //draw target unit Texture2D targetUnitSprite = action.TargetUnit.GetSprite(textures.unitSprites); spriteBatch.Draw(targetUnitSprite, position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(targetUnitSprite.Bounds), scale: spriteScaleVector ); //draw targetting icon spriteBatch.Draw(textures.targetIcon, position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - iconScale * new Vector2(textures.targetIcon.Width, 0), scale: iconScaleVector ); } else //(No move) { //Draw the unit trying to act spriteBatch.Draw(actingUnitSprite, position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(actingUnitSprite.Bounds), scale: spriteScaleVector ); //Draw no act icon (cant move) spriteBatch.Draw(textures.noMoveIcon, position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2), scale: iconScaleVector ); } } //draw dividing line divisorA.Draw(spriteBatch); }
public override void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(samplerState: SamplerState.PointClamp); graphicsDevice.Clear(Color.Black); Vector2 pos = WindowTools.PaddingToPixelCoordinate(0.5f, 0.4f, 0, 0) - (uiScale / 2 * UiTools.BoundsToVector(nextTurnPlayer.CharacterSprite.Bounds)); spriteBatch.Draw( texture: boundary, position: pos - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: nextTurnPlayer.Colour ); spriteBatch.Draw( texture: nextTurnPlayer.CharacterSprite, position: pos, scale: uiScaleVector); //draw pass turn button if (passTurnButton.IsHovered) { spriteBatch.Draw(texture: passTurnButton.HoverTexture, position: passTurnButton.Position, scale: passTurnButton.ScaleVector); } else { spriteBatch.Draw(texture: passTurnButton.ButtonTexture, position: passTurnButton.Position, scale: passTurnButton.ScaleVector); } spriteBatch.DrawString( bebasSmall, "Begin", passTurnButton.MidPoint - bebasSmall.MeasureString("Begin") / 2 + new Vector2(0f, 3f), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0); spriteBatch.DrawString( bebas, text, WindowTools.PaddingToPixelCoordinate(0.5f, 0.20f, 0, 0) - 0.35f * bebas.MeasureString(text) / 2, Color.White, 0f, Vector2.Zero, 0.35f, SpriteEffects.None, 0); spriteBatch.End(); }
private void RotYText_TextChanged(object sender, EventArgs e) { bool failed = false; TransTarget.Heading = UiTools.ParseAndValidateDouble(HeadingText, TransTarget.Heading, ref failed); }
private void RotZText_TextChanged(object sender, EventArgs e) { bool failed = false; TransTarget.Roll = UiTools.ParseAndValidateDouble(RollText, TransTarget.Roll, ref failed); }
public override void Draw(SpriteBatch spriteBatch) { //base: draw the overlay. base.Draw(spriteBatch); spriteBatch.Begin(samplerState: SamplerState.PointClamp); //draw a string telling the player how to continue/quit. spriteBatch.DrawString(font, newGameText, newGamePos, Color.Green ); //draw a string to show who won. string winText = $"Player {winner.Id + 1} Wins!"; spriteBatch.DrawString(largeFont, winText, WindowTools.PaddingToPixelCoordinate(0.5f, 0.05f, 0, 0) - new Vector2(largeFont.MeasureString(winText).X / 2, 0), winner.Colour ); //draw the final score alongside each character sprite. Vector2 spriteOffset = uiScale / 2 * UiTools.BoundsToVector(winner.CharacterSprite.Bounds); Vector2 pos = WindowTools.PaddingToPixelCoordinate(0.5f, 0.4f, 0, 0); //(character sprites) spriteBatch.Draw( texture: boundary, position: pos - spriteOffset - sepDistance - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: winner.Colour ); spriteBatch.Draw( texture: winner.CharacterSprite, position: pos - spriteOffset - sepDistance, scale: uiScaleVector); spriteBatch.Draw( texture: boundary, position: pos - spriteOffset + sepDistance + new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: loser.Colour ); spriteBatch.Draw( texture: loser.CharacterSprite, position: pos - spriteOffset + sepDistance, scale: uiScaleVector); //(score) string text = $"{winner.WinProgress} - {loser.WinProgress}"; Vector2 size = font.MeasureString(text); spriteBatch.DrawString(font, text, pos - size / 2, Color.White ); spriteBatch.End(); }